@@ -32,7 +32,12 @@ import (
32
32
33
33
// Run runs the entire workspace app test suite against deployments minted
34
34
// by the provided factory.
35
- func Run (t * testing.T , factory DeploymentFactory ) {
35
+ //
36
+ // appHostIsPrimary is true if the app host is also the primary coder API
37
+ // server. This disables any tests that test API passthrough or rely on the
38
+ // app server not being the API server.
39
+ // nolint:revive
40
+ func Run (t * testing.T , appHostIsPrimary bool , factory DeploymentFactory ) {
36
41
setupProxyTest := func (t * testing.T , opts * DeploymentOptions ) * Details {
37
42
return setupProxyTestWithFactory (t , factory , opts )
38
43
}
@@ -109,12 +114,12 @@ func Run(t *testing.T, factory DeploymentFactory) {
109
114
110
115
t .Run ("SignedTokenQueryParameter" , func (t * testing.T ) {
111
116
t .Parallel ()
112
-
113
- appDetails := setupProxyTest (t , nil )
114
- if appDetails .AppHostIsPrimary {
117
+ if appHostIsPrimary {
115
118
t .Skip ("Tickets are not used for terminal requests on the primary." )
116
119
}
117
120
121
+ appDetails := setupProxyTest (t , nil )
122
+
118
123
u := * appDetails .PathAppBaseURL
119
124
if u .Scheme == "http" {
120
125
u .Scheme = "ws"
@@ -197,7 +202,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
197
202
t .Run ("LoginWithoutAuthOnPrimary" , func (t * testing.T ) {
198
203
t .Parallel ()
199
204
200
- if ! appDetails . AppHostIsPrimary {
205
+ if ! appHostIsPrimary {
201
206
t .Skip ("This test only applies when testing apps on the primary." )
202
207
}
203
208
@@ -222,7 +227,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
222
227
t .Run ("LoginWithoutAuthOnProxy" , func (t * testing.T ) {
223
228
t .Parallel ()
224
229
225
- if appDetails . AppHostIsPrimary {
230
+ if appHostIsPrimary {
226
231
t .Skip ("This test only applies when testing apps on workspace proxies." )
227
232
}
228
233
@@ -448,7 +453,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
448
453
for _ , c := range cases {
449
454
c := c
450
455
451
- if c .name == "Path" && appDetails . AppHostIsPrimary {
456
+ if c .name == "Path" && appHostIsPrimary {
452
457
// Workspace application auth does not apply to path apps
453
458
// served from the primary access URL as no smuggling needs
454
459
// to take place (they're already logged in with a session
@@ -599,16 +604,15 @@ func Run(t *testing.T, factory DeploymentFactory) {
599
604
// --app-hostname is not set by the admin.
600
605
t .Run ("WorkspaceAppsProxySubdomainPassthrough" , func (t * testing.T ) {
601
606
t .Parallel ()
602
-
607
+ if ! appHostIsPrimary {
608
+ t .Skip ("app hostname does not serve API" )
609
+ }
603
610
// No Hostname set.
604
611
appDetails := setupProxyTest (t , & DeploymentOptions {
605
612
AppHost : "" ,
606
613
DisableSubdomainApps : true ,
607
614
noWorkspace : true ,
608
615
})
609
- if ! appDetails .AppHostIsPrimary {
610
- t .Skip ("app hostname does not serve API" )
611
- }
612
616
613
617
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
614
618
defer cancel ()
@@ -1031,7 +1035,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
1031
1035
require .NoError (t , err , msg )
1032
1036
1033
1037
expectedPath := "/login"
1034
- if ! isPathApp || ! appDetails . AppHostIsPrimary {
1038
+ if ! isPathApp || ! appHostIsPrimary {
1035
1039
expectedPath = "/api/v2/applications/auth-redirect"
1036
1040
}
1037
1041
assert .Equal (t , expectedPath , location .Path , "should not have access, expected redirect to applicable login endpoint. " + msg )
0 commit comments