@@ -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 ) {
3641setupProxyTest := func (t * testing.T ,opts * DeploymentOptions )* Details {
3742return setupProxyTestWithFactory (t ,factory ,opts )
3843}
@@ -109,12 +114,12 @@ func Run(t *testing.T, factory DeploymentFactory) {
109114
110115t .Run ("SignedTokenQueryParameter" ,func (t * testing.T ) {
111116t .Parallel ()
112-
113- appDetails := setupProxyTest (t ,nil )
114- if appDetails .AppHostIsPrimary {
117+ if appHostIsPrimary {
115118t .Skip ("Tickets are not used for terminal requests on the primary." )
116119}
117120
121+ appDetails := setupProxyTest (t ,nil )
122+
118123u := * appDetails .PathAppBaseURL
119124if u .Scheme == "http" {
120125u .Scheme = "ws"
@@ -197,7 +202,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
197202t .Run ("LoginWithoutAuthOnPrimary" ,func (t * testing.T ) {
198203t .Parallel ()
199204
200- if ! appDetails . AppHostIsPrimary {
205+ if ! appHostIsPrimary {
201206t .Skip ("This test only applies when testing apps on the primary." )
202207}
203208
@@ -222,7 +227,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
222227t .Run ("LoginWithoutAuthOnProxy" ,func (t * testing.T ) {
223228t .Parallel ()
224229
225- if appDetails . AppHostIsPrimary {
230+ if appHostIsPrimary {
226231t .Skip ("This test only applies when testing apps on workspace proxies." )
227232}
228233
@@ -448,7 +453,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
448453for _ ,c := range cases {
449454c := 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.
600605t .Run ("WorkspaceAppsProxySubdomainPassthrough" ,func (t * testing.T ) {
601606t .Parallel ()
602-
607+ if ! appHostIsPrimary {
608+ t .Skip ("app hostname does not serve API" )
609+ }
603610// No Hostname set.
604611appDetails := setupProxyTest (t ,& DeploymentOptions {
605612AppHost :"" ,
606613DisableSubdomainApps :true ,
607614noWorkspace :true ,
608615})
609- if ! appDetails .AppHostIsPrimary {
610- t .Skip ("app hostname does not serve API" )
611- }
612616
613617ctx ,cancel := context .WithTimeout (context .Background (),testutil .WaitLong )
614618defer cancel ()
@@ -1031,7 +1035,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
10311035require .NoError (t ,err ,msg )
10321036
10331037expectedPath := "/login"
1034- if ! isPathApp || ! appDetails . AppHostIsPrimary {
1038+ if ! isPathApp || ! appHostIsPrimary {
10351039expectedPath = "/api/v2/applications/auth-redirect"
10361040}
10371041assert .Equal (t ,expectedPath ,location .Path ,"should not have access, expected redirect to applicable login endpoint. " + msg )