Search in sources :

Example 1 with RoleConfig

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;
}
Also used : RoleConfig(com.thoughtworks.go.config.RoleConfig) RoleUser(com.thoughtworks.go.config.RoleUser)

Example 2 with RoleConfig

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));
}
Also used : RoleConfig(com.thoughtworks.go.config.RoleConfig) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) RoleUser(com.thoughtworks.go.config.RoleUser) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) StageConfig(com.thoughtworks.go.config.StageConfig) Test(org.junit.Test)

Example 3 with RoleConfig

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);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) RoleConfig(com.thoughtworks.go.config.RoleConfig) PluginRoleConfig(com.thoughtworks.go.config.PluginRoleConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

RoleConfig (com.thoughtworks.go.config.RoleConfig)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 RoleUser (com.thoughtworks.go.config.RoleUser)2 Test (org.junit.Test)2 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)1 StageConfig (com.thoughtworks.go.config.StageConfig)1 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)1