}
@Test
public void testRoleConfig() throws IOException {
SecurityRoleServiceConfig config = createRoleConfig(XMLRoleService.DEFAULT_NAME,
MemoryRoleService.class, GeoServerRole.ADMIN_ROLE.getAuthority());
SecurityConfigValidator validator = new SecurityConfigValidator(getSecurityManager());
try {
config.setName(null);
validator.validateRemoveRoleService(config);
fail("no name should fail");
//getSecurityManager().removeRoleService(config) ;
} catch (SecurityConfigException ex) {
assertEquals( NAME_REQUIRED,ex.getId());
assertEquals(0,ex.getArgs().length);
}
config.setName("abcd");
for (GeoServerRole role : GeoServerRole.SystemRoles) {
config.setAdminRoleName(role.getAuthority());
try {
validator.validateAddRoleService(config);
fail("reserved role name should fail");
//getSecurityManager().saveRoleService(config);
} catch (SecurityConfigException ex) {
assertEquals( RESERVED_ROLE_NAME,ex.getId());
assertEquals(role.getAuthority(),ex.getArgs()[0]);
}
}
for (GeoServerRole role : GeoServerRole.SystemRoles) {
config.setGroupAdminRoleName(role.getAuthority());
try {
validator.validateAddRoleService(config);
fail("resoerved role name should fail");
//getSecurityManager().saveRoleService(config);
} catch (SecurityConfigException ex) {
assertEquals( RESERVED_ROLE_NAME,ex.getId());
assertEquals(role.getAuthority(),ex.getArgs()[0]);
}
}
try {
config.setName(XMLRoleService.DEFAULT_NAME);
validator.validateRemoveRoleService(config);
fail("role service active should fail");
//getSecurityManager().removeRoleService(config) ;
} catch (SecurityConfigException ex) {
assertEquals( ROLE_SERVICE_ACTIVE_$1,ex.getId());