@@ -115,7 +115,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
115
115
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
116
116
defer cancel ()
117
117
118
- resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , appDetails .PathAppURL (appDetails .OwnerApp ).String (), nil )
118
+ resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , appDetails .PathAppURL (appDetails .Apps . Owner ).String (), nil )
119
119
require .NoError (t , err )
120
120
defer resp .Body .Close ()
121
121
require .Equal (t , http .StatusUnauthorized , resp .StatusCode )
@@ -127,7 +127,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
127
127
t .Run ("LoginWithoutAuthOnPrimary" , func (t * testing.T ) {
128
128
t .Parallel ()
129
129
130
- if ! appDetails .AppHostServesAPI {
130
+ if ! appDetails .AppHostIsPrimary {
131
131
t .Skip ("This test only applies when testing apps on the primary." )
132
132
}
133
133
@@ -137,7 +137,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
137
137
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
138
138
defer cancel ()
139
139
140
- u := appDetails .PathAppURL (appDetails .OwnerApp ).String ()
140
+ u := appDetails .PathAppURL (appDetails .Apps . Owner ).String ()
141
141
resp , err := requestWithRetries (ctx , t , unauthedClient , http .MethodGet , u , nil )
142
142
require .NoError (t , err )
143
143
defer resp .Body .Close ()
@@ -152,7 +152,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
152
152
t .Run ("LoginWithoutAuthOnProxy" , func (t * testing.T ) {
153
153
t .Parallel ()
154
154
155
- if appDetails .AppHostServesAPI {
155
+ if appDetails .AppHostIsPrimary {
156
156
t .Skip ("This test only applies when testing apps on workspace proxies." )
157
157
}
158
158
@@ -162,7 +162,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
162
162
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
163
163
defer cancel ()
164
164
165
- u := appDetails .PathAppURL (appDetails .OwnerApp )
165
+ u := appDetails .PathAppURL (appDetails .Apps . Owner )
166
166
resp , err := requestWithRetries (ctx , t , unauthedClient , http .MethodGet , u .String (), nil )
167
167
require .NoError (t , err )
168
168
defer resp .Body .Close ()
@@ -196,7 +196,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
196
196
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
197
197
defer cancel ()
198
198
199
- resp , err := requestWithRetries (ctx , t , userAppClient , http .MethodGet , appDetails .PathAppURL (appDetails .OwnerApp ).String (), nil )
199
+ resp , err := requestWithRetries (ctx , t , userAppClient , http .MethodGet , appDetails .PathAppURL (appDetails .Apps . Owner ).String (), nil )
200
200
require .NoError (t , err )
201
201
defer resp .Body .Close ()
202
202
require .Equal (t , http .StatusNotFound , resp .StatusCode )
@@ -208,7 +208,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
208
208
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
209
209
defer cancel ()
210
210
211
- u := appDetails .PathAppURL (appDetails .OwnerApp )
211
+ u := appDetails .PathAppURL (appDetails .Apps . Owner )
212
212
u .Path = strings .TrimSuffix (u .Path , "/" )
213
213
resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , u .String (), nil )
214
214
require .NoError (t , err )
@@ -222,7 +222,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
222
222
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
223
223
defer cancel ()
224
224
225
- u := appDetails .PathAppURL (appDetails .OwnerApp )
225
+ u := appDetails .PathAppURL (appDetails .Apps . Owner )
226
226
u .RawQuery = ""
227
227
resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , u .String (), nil )
228
228
require .NoError (t , err )
@@ -239,7 +239,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
239
239
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
240
240
defer cancel ()
241
241
242
- u := appDetails .PathAppURL (appDetails .OwnerApp )
242
+ u := appDetails .PathAppURL (appDetails .Apps . Owner )
243
243
resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , u .String (), nil )
244
244
require .NoError (t , err )
245
245
defer resp .Body .Close ()
@@ -280,7 +280,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
280
280
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
281
281
defer cancel ()
282
282
283
- app := appDetails .OwnerApp
283
+ app := appDetails .Apps . Owner
284
284
app .Username = codersdk .Me
285
285
286
286
resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , appDetails .PathAppURL (app ).String (), nil )
@@ -299,7 +299,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
299
299
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
300
300
defer cancel ()
301
301
302
- resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , appDetails .PathAppURL (appDetails .OwnerApp ).String (), nil , func (r * http.Request ) {
302
+ resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , appDetails .PathAppURL (appDetails .Apps . Owner ).String (), nil , func (r * http.Request ) {
303
303
r .Header .Set ("Cf-Connecting-IP" , "1.1.1.1" )
304
304
})
305
305
require .NoError (t , err )
@@ -317,7 +317,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
317
317
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
318
318
defer cancel ()
319
319
320
- resp , err := appDetails .AppClient (t ).Request (ctx , http .MethodGet , appDetails .PathAppURL (appDetails .FakeApp ).String (), nil )
320
+ resp , err := appDetails .AppClient (t ).Request (ctx , http .MethodGet , appDetails .PathAppURL (appDetails .Apps . Fake ).String (), nil )
321
321
require .NoError (t , err )
322
322
defer resp .Body .Close ()
323
323
require .Equal (t , http .StatusBadGateway , resp .StatusCode )
@@ -329,7 +329,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
329
329
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
330
330
defer cancel ()
331
331
332
- resp , err := appDetails .AppClient (t ).Request (ctx , http .MethodGet , appDetails .PathAppURL (appDetails .PortApp ).String (), nil )
332
+ resp , err := appDetails .AppClient (t ).Request (ctx , http .MethodGet , appDetails .PathAppURL (appDetails .Apps . Port ).String (), nil )
333
333
require .NoError (t , err )
334
334
defer resp .Body .Close ()
335
335
// TODO(@deansheather): This should be 400. There's a todo in the
@@ -354,7 +354,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
354
354
}{
355
355
{
356
356
name : "Subdomain" ,
357
- appURL : appDetails .SubdomainAppURL (appDetails .OwnerApp ),
357
+ appURL : appDetails .SubdomainAppURL (appDetails .Apps . Owner ),
358
358
verifyCookie : func (t * testing.T , c * http.Cookie ) {
359
359
// TODO(@dean): fix these asserts, they don't seem to
360
360
// work. I wonder if Go strips the domain from the
@@ -365,7 +365,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
365
365
},
366
366
{
367
367
name : "Path" ,
368
- appURL : appDetails .PathAppURL (appDetails .OwnerApp ),
368
+ appURL : appDetails .PathAppURL (appDetails .Apps . Owner ),
369
369
verifyCookie : func (t * testing.T , c * http.Cookie ) {
370
370
// TODO(@dean): fix these asserts, they don't seem to
371
371
// work. I wonder if Go strips the domain from the
@@ -378,7 +378,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
378
378
for _ , c := range cases {
379
379
c := c
380
380
381
- if c .name == "Path" && appDetails .AppHostServesAPI {
381
+ if c .name == "Path" && appDetails .AppHostIsPrimary {
382
382
// Workspace application auth does not apply to path apps
383
383
// served from the primary access URL as no smuggling needs
384
384
// to take place (they're already logged in with a session
@@ -536,7 +536,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
536
536
DisableSubdomainApps : true ,
537
537
noWorkspace : true ,
538
538
})
539
- if ! appDetails .AppHostServesAPI {
539
+ if ! appDetails .AppHostIsPrimary {
540
540
t .Skip ("app hostname does not serve API" )
541
541
}
542
542
@@ -604,7 +604,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
604
604
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
605
605
defer cancel ()
606
606
607
- resp , err := requestWithRetries (ctx , t , userAppClient , http .MethodGet , appDetails .SubdomainAppURL (appDetails .OwnerApp ).String (), nil )
607
+ resp , err := requestWithRetries (ctx , t , userAppClient , http .MethodGet , appDetails .SubdomainAppURL (appDetails .Apps . Owner ).String (), nil )
608
608
require .NoError (t , err )
609
609
defer resp .Body .Close ()
610
610
require .Equal (t , http .StatusNotFound , resp .StatusCode )
@@ -616,7 +616,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
616
616
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
617
617
defer cancel ()
618
618
619
- u := appDetails .SubdomainAppURL (appDetails .OwnerApp )
619
+ u := appDetails .SubdomainAppURL (appDetails .Apps . Owner )
620
620
u .Path = ""
621
621
u .RawQuery = ""
622
622
resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , u .String (), nil )
@@ -626,7 +626,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
626
626
627
627
loc , err := resp .Location ()
628
628
require .NoError (t , err )
629
- require .Equal (t , appDetails .SubdomainAppURL (appDetails .OwnerApp ).Path , loc .Path )
629
+ require .Equal (t , appDetails .SubdomainAppURL (appDetails .Apps . Owner ).Path , loc .Path )
630
630
})
631
631
632
632
t .Run ("RedirectsWithQuery" , func (t * testing.T ) {
@@ -635,7 +635,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
635
635
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
636
636
defer cancel ()
637
637
638
- u := appDetails .SubdomainAppURL (appDetails .OwnerApp )
638
+ u := appDetails .SubdomainAppURL (appDetails .Apps . Owner )
639
639
u .RawQuery = ""
640
640
resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , u .String (), nil )
641
641
require .NoError (t , err )
@@ -644,7 +644,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
644
644
645
645
loc , err := resp .Location ()
646
646
require .NoError (t , err )
647
- require .Equal (t , appDetails .SubdomainAppURL (appDetails .OwnerApp ).RawQuery , loc .RawQuery )
647
+ require .Equal (t , appDetails .SubdomainAppURL (appDetails .Apps . Owner ).RawQuery , loc .RawQuery )
648
648
})
649
649
650
650
t .Run ("Proxies" , func (t * testing.T ) {
@@ -653,7 +653,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
653
653
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
654
654
defer cancel ()
655
655
656
- u := appDetails .SubdomainAppURL (appDetails .OwnerApp )
656
+ u := appDetails .SubdomainAppURL (appDetails .Apps . Owner )
657
657
resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , u .String (), nil )
658
658
require .NoError (t , err )
659
659
defer resp .Body .Close ()
@@ -694,7 +694,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
694
694
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
695
695
defer cancel ()
696
696
697
- resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , appDetails .SubdomainAppURL (appDetails .PortApp ).String (), nil )
697
+ resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , appDetails .SubdomainAppURL (appDetails .Apps . Port ).String (), nil )
698
698
require .NoError (t , err )
699
699
defer resp .Body .Close ()
700
700
body , err := io .ReadAll (resp .Body )
@@ -709,7 +709,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
709
709
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
710
710
defer cancel ()
711
711
712
- resp , err := appDetails .AppClient (t ).Request (ctx , http .MethodGet , appDetails .SubdomainAppURL (appDetails .FakeApp ).String (), nil )
712
+ resp , err := appDetails .AppClient (t ).Request (ctx , http .MethodGet , appDetails .SubdomainAppURL (appDetails .Apps . Fake ).String (), nil )
713
713
require .NoError (t , err )
714
714
defer resp .Body .Close ()
715
715
require .Equal (t , http .StatusBadGateway , resp .StatusCode )
@@ -721,7 +721,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
721
721
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
722
722
defer cancel ()
723
723
724
- app := appDetails .PortApp
724
+ app := appDetails .Apps . Port
725
725
app .AppSlugOrPort = strconv .Itoa (codersdk .WorkspaceAgentMinimumListeningPort - 1 )
726
726
resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , appDetails .SubdomainAppURL (app ).String (), nil )
727
727
require .NoError (t , err )
@@ -745,7 +745,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
745
745
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
746
746
defer cancel ()
747
747
748
- u := appDetails .SubdomainAppURL (appDetails .OwnerApp )
748
+ u := appDetails .SubdomainAppURL (appDetails .Apps . Owner )
749
749
t .Logf ("url: %s" , u )
750
750
751
751
resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , u .String (), nil )
@@ -768,7 +768,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
768
768
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
769
769
defer cancel ()
770
770
771
- u := appDetails .SubdomainAppURL (appDetails .OwnerApp )
771
+ u := appDetails .SubdomainAppURL (appDetails .Apps . Owner )
772
772
// Replace the -suffix with nothing.
773
773
u .Host = strings .Replace (u .Host , "-suffix" , "" , 1 )
774
774
t .Logf ("url: %s" , u )
@@ -790,7 +790,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
790
790
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
791
791
defer cancel ()
792
792
793
- u := appDetails .SubdomainAppURL (appDetails .OwnerApp )
793
+ u := appDetails .SubdomainAppURL (appDetails .Apps . Owner )
794
794
// Replace the -suffix with something else.
795
795
u .Host = strings .Replace (u .Host , "-suffix" , "-not-suffix" , 1 )
796
796
t .Logf ("url: %s" , u )
@@ -961,7 +961,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
961
961
require .NoError (t , err , msg )
962
962
963
963
expectedPath := "/login"
964
- if ! isPathApp || ! appDetails .AppHostServesAPI {
964
+ if ! isPathApp || ! appDetails .AppHostIsPrimary {
965
965
expectedPath = "/api/v2/applications/auth-redirect"
966
966
}
967
967
assert .Equal (t , expectedPath , location .Path , "should not have access, expected redirect to applicable login endpoint. " + msg )
@@ -1141,11 +1141,11 @@ func Run(t *testing.T, factory DeploymentFactory) {
1141
1141
}{
1142
1142
{
1143
1143
name : "ProxyPath" ,
1144
- u : appDetails .PathAppURL (appDetails .OwnerApp ),
1144
+ u : appDetails .PathAppURL (appDetails .Apps . Owner ),
1145
1145
},
1146
1146
{
1147
1147
name : "ProxySubdomain" ,
1148
- u : appDetails .SubdomainAppURL (appDetails .OwnerApp ),
1148
+ u : appDetails .SubdomainAppURL (appDetails .Apps . Owner ),
1149
1149
},
1150
1150
}
1151
1151
0 commit comments