Search in sources :

Example 1 with RoleUser

use of com.thoughtworks.go.config.RoleUser 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 RoleUser

use of com.thoughtworks.go.config.RoleUser 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)

Aggregations

RoleConfig (com.thoughtworks.go.config.RoleConfig)2 RoleUser (com.thoughtworks.go.config.RoleUser)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 StageConfig (com.thoughtworks.go.config.StageConfig)1 Test (org.junit.Test)1