use of com.thoughtworks.go.config.RoleConfig in project gocd by gocd.
the class GoCDRoleConfigRepresenter method fromJSON.
public static RoleConfig fromJSON(JsonReader jsonReader) {
RoleConfig model = new RoleConfig();
if (jsonReader == null) {
return model;
}
jsonReader.readArrayIfPresent("users", users -> {
users.forEach(user -> model.addUser(new RoleUser(user.getAsString())));
});
return model;
}
use of com.thoughtworks.go.config.RoleConfig in project gocd by gocd.
the class StageApprovalAuthorizationTest method shouldAuthorizeIfRoleIsInApprovalList.
@Test
public void shouldAuthorizeIfRoleIsInApprovalList() throws Exception {
CONFIG_HELPER.addSecurityWithAdminConfig();
CONFIG_HELPER.addRole(new RoleConfig(new CaseInsensitiveString("adminRole"), new RoleUser(new CaseInsensitiveString("tester"))));
StageConfig stage = StageConfigMother.custom("test", authConfigWithAdminRole);
PipelineConfig pipeline = CONFIG_HELPER.addStageToPipeline(PIPELINE_NAME, stage);
assertThat("User tester should have permission on test stage", securityService.hasOperatePermissionForStage(CaseInsensitiveString.str(pipeline.name()), CaseInsensitiveString.str(stage.name()), "tester"), is(true));
}
use of com.thoughtworks.go.config.RoleConfig in project gocd by gocd.
the class RoleConfigUpdateCommandTest method shouldRaiseErrorWhenUpdatingNonExistentRole.
@Test
public void shouldRaiseErrorWhenUpdatingNonExistentRole() throws Exception {
cruiseConfig.server().security().getRoles().clear();
RoleConfigCommand command = new RoleConfigUpdateCommand(null, new RoleConfig(new CaseInsensitiveString("foo")), null, null, new HttpLocalizedOperationResult(), null, null);
thrown.expect(RoleNotFoundException.class);
command.update(cruiseConfig);
}
Aggregations