@@ -40,6 +40,7 @@ func Test_ResolveRequest(t *testing.T) {
40
40
// Users can access unhealthy and initializing apps (as of 2024-02).
41
41
appNameUnhealthy = "app-unhealthy"
42
42
appNameInitializing = "app-initializing"
43
+ appNameEndsInS = "app-ends-in-s"
43
44
44
45
// This agent will never connect, so it will never become "connected".
45
46
// Users cannot access unhealthy agents.
@@ -166,6 +167,12 @@ func Test_ResolveRequest(t *testing.T) {
166
167
Threshold : 1000 ,
167
168
},
168
169
},
170
+ {
171
+ Slug : appNameEndsInS ,
172
+ DisplayName : appNameEndsInS ,
173
+ SharingLevel : proto .AppSharingLevel_OWNER ,
174
+ Url : appURL ,
175
+ },
169
176
},
170
177
},
171
178
{
@@ -644,6 +651,62 @@ func Test_ResolveRequest(t *testing.T) {
644
651
require .Equal (t , "http://127.0.0.1:9090" , token .AppURL )
645
652
})
646
653
654
+ t .Run ("PortSubdomainHTTPSS" , func (t * testing.T ) {
655
+ t .Parallel ()
656
+
657
+ req := (workspaceapps.Request {
658
+ AccessMethod : workspaceapps .AccessMethodSubdomain ,
659
+ BasePath : "/" ,
660
+ UsernameOrID : me .Username ,
661
+ WorkspaceNameOrID : workspace .Name ,
662
+ AgentNameOrID : agentName ,
663
+ AppSlugOrPort : "9090ss" ,
664
+ }).Normalize ()
665
+
666
+ rw := httptest .NewRecorder ()
667
+ r := httptest .NewRequest ("GET" , "/" , nil )
668
+ r .Header .Set (codersdk .SessionTokenHeader , client .SessionToken ())
669
+
670
+ _ , ok := workspaceapps .ResolveRequest (rw , r , workspaceapps.ResolveRequestOptions {
671
+ Logger : api .Logger ,
672
+ SignedTokenProvider : api .WorkspaceAppsProvider ,
673
+ DashboardURL : api .AccessURL ,
674
+ PathAppBaseURL : api .AccessURL ,
675
+ AppHostname : api .AppHostname ,
676
+ AppRequest : req ,
677
+ })
678
+ // should parse as app and fail to find app "9090ss"
679
+ require .False (t , ok )
680
+ })
681
+
682
+ t .Run ("SubdomainEndsInS" , func (t * testing.T ) {
683
+ t .Parallel ()
684
+
685
+ req := (workspaceapps.Request {
686
+ AccessMethod : workspaceapps .AccessMethodSubdomain ,
687
+ BasePath : "/" ,
688
+ UsernameOrID : me .Username ,
689
+ WorkspaceNameOrID : workspace .Name ,
690
+ AgentNameOrID : agentName ,
691
+ AppSlugOrPort : appNameEndsInS ,
692
+ }).Normalize ()
693
+
694
+ rw := httptest .NewRecorder ()
695
+ r := httptest .NewRequest ("GET" , "/" , nil )
696
+ r .Header .Set (codersdk .SessionTokenHeader , client .SessionToken ())
697
+
698
+ token , ok := workspaceapps .ResolveRequest (rw , r , workspaceapps.ResolveRequestOptions {
699
+ Logger : api .Logger ,
700
+ SignedTokenProvider : api .WorkspaceAppsProvider ,
701
+ DashboardURL : api .AccessURL ,
702
+ PathAppBaseURL : api .AccessURL ,
703
+ AppHostname : api .AppHostname ,
704
+ AppRequest : req ,
705
+ })
706
+ require .True (t , ok )
707
+ require .Equal (t , req .AppSlugOrPort , token .AppSlugOrPort )
708
+ })
709
+
647
710
t .Run ("Terminal" , func (t * testing.T ) {
648
711
t .Parallel ()
649
712
0 commit comments