@@ -32,7 +32,12 @@ import (
3232
3333// Run runs the entire workspace app test suite against deployments minted
3434// 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 ) {
3641 setupProxyTest := func (t * testing.T , opts * DeploymentOptions ) * Details {
3742 return setupProxyTestWithFactory (t , factory , opts )
3843 }
@@ -109,12 +114,12 @@ func Run(t *testing.T, factory DeploymentFactory) {
109114
110115 t .Run ("SignedTokenQueryParameter" , func (t * testing.T ) {
111116 t .Parallel ()
112-
113- appDetails := setupProxyTest (t , nil )
114- if appDetails .AppHostIsPrimary {
117+ if appHostIsPrimary {
115118 t .Skip ("Tickets are not used for terminal requests on the primary." )
116119 }
117120
121+ appDetails := setupProxyTest (t , nil )
122+
118123 u := * appDetails .PathAppBaseURL
119124 if u .Scheme == "http" {
120125 u .Scheme = "ws"
@@ -197,7 +202,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
197202 t .Run ("LoginWithoutAuthOnPrimary" , func (t * testing.T ) {
198203 t .Parallel ()
199204
200- if ! appDetails . AppHostIsPrimary {
205+ if ! appHostIsPrimary {
201206 t .Skip ("This test only applies when testing apps on the primary." )
202207 }
203208
@@ -222,7 +227,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
222227 t .Run ("LoginWithoutAuthOnProxy" , func (t * testing.T ) {
223228 t .Parallel ()
224229
225- if appDetails . AppHostIsPrimary {
230+ if appHostIsPrimary {
226231 t .Skip ("This test only applies when testing apps on workspace proxies." )
227232 }
228233
@@ -448,7 +453,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
448453 for _ , c := range cases {
449454 c := c
450455
451- if c .name == "Path" && appDetails . AppHostIsPrimary {
456+ if c .name == "Path" && appHostIsPrimary {
452457 // Workspace application auth does not apply to path apps
453458 // served from the primary access URL as no smuggling needs
454459 // to take place (they're already logged in with a session
@@ -599,16 +604,15 @@ func Run(t *testing.T, factory DeploymentFactory) {
599604 // --app-hostname is not set by the admin.
600605 t .Run ("WorkspaceAppsProxySubdomainPassthrough" , func (t * testing.T ) {
601606 t .Parallel ()
602-
607+ if ! appHostIsPrimary {
608+ t .Skip ("app hostname does not serve API" )
609+ }
603610 // No Hostname set.
604611 appDetails := setupProxyTest (t , & DeploymentOptions {
605612 AppHost : "" ,
606613 DisableSubdomainApps : true ,
607614 noWorkspace : true ,
608615 })
609- if ! appDetails .AppHostIsPrimary {
610- t .Skip ("app hostname does not serve API" )
611- }
612616
613617 ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
614618 defer cancel ()
@@ -1031,7 +1035,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
10311035 require .NoError (t , err , msg )
10321036
10331037 expectedPath := "/login"
1034- if ! isPathApp || ! appDetails . AppHostIsPrimary {
1038+ if ! isPathApp || ! appHostIsPrimary {
10351039 expectedPath = "/api/v2/applications/auth-redirect"
10361040 }
10371041 assert .Equal (t , expectedPath , location .Path , "should not have access, expected redirect to applicable login endpoint. " + msg )
0 commit comments