Retain CSP configuration in ServerConfig constructor. (#12755)

Without this change, CliIndexer would not apply custom CSP headers
and would revert to the default.
This commit is contained in:
Gian Merlino 2022-07-08 06:49:14 -07:00 committed by GitHub
parent 4574dea5e9
commit 378fea9517
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -87,6 +87,7 @@ public class ServerConfig
this.allowedHttpMethods = allowedHttpMethods;
this.showDetailedJettyErrors = showDetailedJettyErrors;
this.errorResponseTransformStrategy = errorResponseTransformStrategy;
this.contentSecurityPolicy = contentSecurityPolicy;
}
public ServerConfig()

View File

@ -61,7 +61,7 @@ public class ServerConfigTest
ImmutableList.of(HttpMethod.OPTIONS),
true,
new AllowedRegexErrorResponseTransformStrategy(ImmutableList.of(".*")),
defaultConfig.getContentSecurityPolicy()
"my-cool-policy"
);
String modifiedConfigJson = OBJECT_MAPPER.writeValueAsString(modifiedConfig);
ServerConfig modifiedConfig2 = OBJECT_MAPPER.readValue(modifiedConfigJson, ServerConfig.class);
@ -72,6 +72,8 @@ public class ServerConfigTest
Assert.assertTrue(modifiedConfig2.isEnableForwardedRequestCustomizer());
Assert.assertEquals(1, modifiedConfig2.getAllowedHttpMethods().size());
Assert.assertTrue(modifiedConfig2.getAllowedHttpMethods().contains(HttpMethod.OPTIONS));
Assert.assertEquals("my-cool-policy", modifiedConfig.getContentSecurityPolicy());
Assert.assertEquals("my-cool-policy", modifiedConfig2.getContentSecurityPolicy());
}
@Test