Skip to content

Commit

Permalink
GEOS-9198: improved tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarto committed May 8, 2019
1 parent e6ac66f commit 0b74e06
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class AuthenticationKeyFilterConfig extends SecurityFilterConfig
private String authKeyParamName = KeyAuthenticationToken.DEFAULT_URL_PARAM;
private String userGroupServiceName;
private Map<String, String> mapperParameters;
private boolean allowEnvParametrization = false;

@Override
public boolean providesAuthenticationEntryPoint() {
Expand Down Expand Up @@ -82,10 +81,6 @@ public void setMapperParameters(Map<String, String> mapperParameters) {
this.mapperParameters = mapperParameters;
}

public void setAllowEnvParametrization(boolean allowEnvParametrization) {
this.allowEnvParametrization = allowEnvParametrization;
}

@Override
public SecurityConfig clone(boolean allowEnvParametrization) {
AuthenticationKeyFilterConfig target =
Expand All @@ -100,7 +95,8 @@ public SecurityConfig clone(boolean allowEnvParametrization) {
String key = param.getKey();
Object value = param.getValue();

if (gsEnvironment != null && isEnvParametrizationAllowed()) {
if (gsEnvironment != null
&& GeoServerEnvironment.ALLOW_ENV_PARAMETRIZATION) {
value = gsEnvironment.resolveValue(value);
}

Expand All @@ -112,8 +108,4 @@ public SecurityConfig clone(boolean allowEnvParametrization) {

return target;
}

protected boolean isEnvParametrizationAllowed() {
return allowEnvParametrization || GeoServerEnvironment.ALLOW_ENV_PARAMETRIZATION;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Map.Entry;
import java.util.Properties;
import javax.servlet.http.HttpServletResponse;
import org.geoserver.data.test.SystemTestData;
import org.geoserver.platform.GeoServerEnvironment;
import org.geoserver.platform.GeoServerExtensions;
import org.geoserver.security.auth.AbstractAuthenticationProviderTest;
Expand Down Expand Up @@ -105,12 +106,19 @@ public HTTPResponse post(URL url, InputStream in, String arg) throws IOException
@Override
protected void setUpSpring(List<String> springContextLocations) {
try {
System.setProperty("ALLOW_ENV_PARAMETRIZATION", "true");
super.setUpSpring(springContextLocations);
} catch (Exception e) {
// pass
}
}

@Override
protected void onTearDown(SystemTestData testData) throws Exception {
super.onTearDown(testData);
System.clearProperty("ALLOW_ENV_PARAMETRIZATION");
}

@Override
protected void onSetUp(org.geoserver.data.test.SystemTestData testData) throws Exception {
super.onSetUp(testData);
Expand Down Expand Up @@ -149,7 +157,6 @@ public void testMapperParametersFromEnv() throws Exception {
String filterName = "testAuthKeyParams2";

AuthenticationKeyFilterConfig config = new AuthenticationKeyFilterConfig();
config.setAllowEnvParametrization(true);
config.setClassName(GeoServerAuthenticationKeyFilter.class.getName());
config.setName(filterName);
config.setUserGroupServiceName("ug1");
Expand Down

0 comments on commit 0b74e06

Please sign in to comment.