validator.validateFilterConfig(config);
}
@Test
public void testRoleFilterConfigValidation() throws Exception{
RoleFilterConfig config = new RoleFilterConfig();
config.setClassName(GeoServerRoleFilter.class.getName());
config.setName("testRoleFilter");
GeoServerSecurityManager secMgr = getSecurityManager();
FilterConfigValidator validator = new FilterConfigValidator(secMgr);
try {
validator.validateFilterConfig(config);
fail("no header attribute should fail");
} catch (FilterConfigException ex){
assertEquals(FilterConfigException.HEADER_ATTRIBUTE_NAME_REQUIRED,ex.getId());
assertEquals(0,ex.getArgs().length);
}
config.setHttpResponseHeaderAttrForIncludedRoles("roles");
config.setRoleConverterName("unknown");
try {
validator.validateFilterConfig(config);
fail("unkonwn role converter should fail");
} catch (FilterConfigException ex){
assertEquals(FilterConfigException.UNKNOWN_ROLE_CONVERTER,ex.getId());
assertEquals(1,ex.getArgs().length);
assertEquals("unknown",ex.getArgs()[0]);
}
config.setRoleConverterName(null);
validator.validateFilterConfig(config);
}