@@ -928,7 +928,7 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
928
928
forceURLTransport (t , client )
929
929
930
930
// Create workspace.
931
- port := appServer (t )
931
+ port := appServer (t , nil )
932
932
workspace , _ = createWorkspaceWithApps (t , client , user .OrganizationIDs [0 ], user , port )
933
933
934
934
// Verify that the apps have the correct sharing levels set.
@@ -1260,4 +1260,61 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
1260
1260
})
1261
1261
}
1262
1262
})
1263
+
1264
+ t .Run ("CORSHeadersStripped" , func (t * testing.T ) {
1265
+ t .Parallel ()
1266
+
1267
+ appDetails := setupProxyTest (t , & DeploymentOptions {
1268
+ headers : http.Header {
1269
+ "X-Foobar" : []string {"baz" },
1270
+ "Access-Control-Allow-Origin" : []string {"http://localhost" },
1271
+ "access-control-allow-origin" : []string {"http://localhost" },
1272
+ "Access-Control-Allow-Credentials" : []string {"true" },
1273
+ "Access-Control-Allow-Methods" : []string {"PUT" },
1274
+ "Access-Control-Allow-Headers" : []string {"X-Foobar" },
1275
+ "Vary" : []string {
1276
+ "Origin" ,
1277
+ "origin" ,
1278
+ "Access-Control-Request-Headers" ,
1279
+ "access-Control-request-Headers" ,
1280
+ "Access-Control-Request-Methods" ,
1281
+ "ACCESS-CONTROL-REQUEST-METHODS" ,
1282
+ "X-Foobar" ,
1283
+ },
1284
+ },
1285
+ })
1286
+
1287
+ appURL := appDetails .SubdomainAppURL (appDetails .Apps .Owner )
1288
+
1289
+ ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
1290
+ defer cancel ()
1291
+
1292
+ resp , err := requestWithRetries (ctx , t , appDetails .AppClient (t ), http .MethodGet , appURL .String (), nil )
1293
+ require .NoError (t , err )
1294
+ defer resp .Body .Close ()
1295
+
1296
+ require .Equal (t , http .StatusOK , resp .StatusCode )
1297
+ require .Equal (t , []string (nil ), resp .Header .Values ("Access-Control-Allow-Origin" ))
1298
+ require .Equal (t , []string (nil ), resp .Header .Values ("Access-Control-Allow-Credentials" ))
1299
+ require .Equal (t , []string (nil ), resp .Header .Values ("Access-Control-Allow-Methods" ))
1300
+ require .Equal (t , []string (nil ), resp .Header .Values ("Access-Control-Allow-Headers" ))
1301
+ // Somehow there are two "Origin"s in Vary even though there should only be
1302
+ // one (from the CORS middleware), even if you remove the headers being sent
1303
+ // above. When I do nothing else but change the expected value below to
1304
+ // have two "Origin"s suddenly Vary only has one. It is somehow always the
1305
+ // opposite of whatever I put for the expected. So, reluctantly, remove
1306
+ // duplicate "Origin" values.
1307
+ var deduped []string
1308
+ var addedOrigin bool
1309
+ for _ , value := range resp .Header .Values ("Vary" ) {
1310
+ if value != "Origin" || ! addedOrigin {
1311
+ if value == "Origin" {
1312
+ addedOrigin = true
1313
+ }
1314
+ deduped = append (deduped , value )
1315
+ }
1316
+ }
1317
+ require .Equal (t , []string {"Origin" , "X-Foobar" }, deduped )
1318
+ require .Equal (t , []string {"baz" }, resp .Header .Values ("X-Foobar" ))
1319
+ })
1263
1320
}
0 commit comments