@@ -349,6 +349,51 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
349
349
require .Equal (t , http .StatusOK , resp .StatusCode )
350
350
})
351
351
352
+ t .Run ("ProxiesHTTPS" , func (t * testing.T ) {
353
+ t .Parallel ()
354
+
355
+ appDetails := setupProxyTest (t , & DeploymentOptions {
356
+ ServeHTTPS : true ,
357
+ })
358
+
359
+ ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
360
+ defer cancel ()
361
+
362
+ u := appDetails .PathAppURL (appDetails .Apps .Owner )
363
+ resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , u .String (), nil )
364
+ require .NoError (t , err )
365
+ defer resp .Body .Close ()
366
+ body , err := io .ReadAll (resp .Body )
367
+ require .NoError (t , err )
368
+ require .Equal (t , proxyTestAppBody , string (body ))
369
+ require .Equal (t , http .StatusOK , resp .StatusCode )
370
+
371
+ var appTokenCookie * http.Cookie
372
+ for _ , c := range resp .Cookies () {
373
+ if c .Name == codersdk .DevURLSignedAppTokenCookie {
374
+ appTokenCookie = c
375
+ break
376
+ }
377
+ }
378
+ require .NotNil (t , appTokenCookie , "no signed app token cookie in response" )
379
+ require .Equal (t , appTokenCookie .Path , u .Path , "incorrect path on app token cookie" )
380
+
381
+ // Ensure the signed app token cookie is valid.
382
+ appTokenClient := appDetails .AppClient (t )
383
+ appTokenClient .SetSessionToken ("" )
384
+ appTokenClient .HTTPClient .Jar , err = cookiejar .New (nil )
385
+ require .NoError (t , err )
386
+ appTokenClient .HTTPClient .Jar .SetCookies (u , []* http.Cookie {appTokenCookie })
387
+
388
+ resp , err = requestWithRetries (ctx , t , appTokenClient , http .MethodGet , u .String (), nil )
389
+ require .NoError (t , err )
390
+ defer resp .Body .Close ()
391
+ body , err = io .ReadAll (resp .Body )
392
+ require .NoError (t , err )
393
+ require .Equal (t , proxyTestAppBody , string (body ))
394
+ require .Equal (t , http .StatusOK , resp .StatusCode )
395
+ })
396
+
352
397
t .Run ("BlocksMe" , func (t * testing.T ) {
353
398
t .Parallel ()
354
399
@@ -762,6 +807,50 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
762
807
require .Equal (t , http .StatusOK , resp .StatusCode )
763
808
})
764
809
810
+ t .Run ("ProxiesHTTPS" , func (t * testing.T ) {
811
+ t .Parallel ()
812
+
813
+ appDetails := setupProxyTest (t , & DeploymentOptions {
814
+ ServeHTTPS : true ,
815
+ })
816
+ ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
817
+ defer cancel ()
818
+
819
+ u := appDetails .SubdomainAppURL (appDetails .Apps .Owner )
820
+ resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , u .String (), nil )
821
+ require .NoError (t , err )
822
+ defer resp .Body .Close ()
823
+ body , err := io .ReadAll (resp .Body )
824
+ require .NoError (t , err )
825
+ require .Equal (t , proxyTestAppBody , string (body ))
826
+ require .Equal (t , http .StatusOK , resp .StatusCode )
827
+
828
+ var appTokenCookie * http.Cookie
829
+ for _ , c := range resp .Cookies () {
830
+ if c .Name == codersdk .DevURLSignedAppTokenCookie {
831
+ appTokenCookie = c
832
+ break
833
+ }
834
+ }
835
+ require .NotNil (t , appTokenCookie , "no signed token cookie in response" )
836
+ require .Equal (t , appTokenCookie .Path , "/" , "incorrect path on signed token cookie" )
837
+
838
+ // Ensure the signed app token cookie is valid.
839
+ appTokenClient := appDetails .AppClient (t )
840
+ appTokenClient .SetSessionToken ("" )
841
+ appTokenClient .HTTPClient .Jar , err = cookiejar .New (nil )
842
+ require .NoError (t , err )
843
+ appTokenClient .HTTPClient .Jar .SetCookies (u , []* http.Cookie {appTokenCookie })
844
+
845
+ resp , err = requestWithRetries (ctx , t , appTokenClient , http .MethodGet , u .String (), nil )
846
+ require .NoError (t , err )
847
+ defer resp .Body .Close ()
848
+ body , err = io .ReadAll (resp .Body )
849
+ require .NoError (t , err )
850
+ require .Equal (t , proxyTestAppBody , string (body ))
851
+ require .Equal (t , http .StatusOK , resp .StatusCode )
852
+ })
853
+
765
854
t .Run ("ProxiesPort" , func (t * testing.T ) {
766
855
t .Parallel ()
767
856
@@ -928,8 +1017,8 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
928
1017
forceURLTransport (t , client )
929
1018
930
1019
// Create workspace.
931
- port := appServer (t , nil )
932
- workspace , _ = createWorkspaceWithApps (t , client , user .OrganizationIDs [0 ], user , port )
1020
+ port := appServer (t , nil , false )
1021
+ workspace , _ = createWorkspaceWithApps (t , client , user .OrganizationIDs [0 ], user , port , false )
933
1022
934
1023
// Verify that the apps have the correct sharing levels set.
935
1024
workspaceBuild , err := client .WorkspaceBuild (ctx , workspace .LatestBuild .ID )
0 commit comments