Search in sources :

Example 1 with AdminUser

use of com.thoughtworks.go.config.AdminUser in project gocd by gocd.

the class StageApprovalAuthorizationTest method shouldAuthorizeUserCruiseIfUserIsAuthorisedToOperateAutoStage.

@Test
public void shouldAuthorizeUserCruiseIfUserIsAuthorisedToOperateAutoStage() throws Exception {
    CONFIG_HELPER.addSecurityWithAdminConfig();
    CONFIG_HELPER.setOperatePermissionForStage(PIPELINE_NAME, STAGE_NAME, "cruise");
    StageConfig stage = StageConfigMother.custom("ft", new Approval(new AuthConfig(new AdminUser(new CaseInsensitiveString("cruise")))));
    PipelineConfig pipeline = CONFIG_HELPER.addStageToPipeline(PIPELINE_NAME, stage);
    assertThat(securityService.hasOperatePermissionForStage(CaseInsensitiveString.str(pipeline.name()), CaseInsensitiveString.str(stage.name()), "cruise"), is(true));
    assertThat(securityService.hasOperatePermissionForStage(PIPELINE_NAME, STAGE_NAME, "anyone"), is(false));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) AdminUser(com.thoughtworks.go.config.AdminUser) AuthConfig(com.thoughtworks.go.config.AuthConfig) Approval(com.thoughtworks.go.config.Approval) StageConfig(com.thoughtworks.go.config.StageConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.jupiter.api.Test)

Example 2 with AdminUser

use of com.thoughtworks.go.config.AdminUser in project gocd by gocd.

the class AdminsConfigRepresenter method fromJSON.

public static AdminsConfig fromJSON(JsonReader jsonReader) {
    AdminsConfig adminsConfig = new AdminsConfig();
    jsonReader.readArrayIfPresent("users", users -> {
        users.forEach(user -> adminsConfig.add(new AdminUser(new CaseInsensitiveString(user.getAsString()))));
    });
    jsonReader.readArrayIfPresent("roles", roles -> {
        roles.forEach(role -> adminsConfig.add(new AdminRole(new CaseInsensitiveString(role.getAsString()))));
    });
    return adminsConfig;
}
Also used : AdminUser(com.thoughtworks.go.config.AdminUser) AdminRole(com.thoughtworks.go.config.AdminRole) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) AdminsConfig(com.thoughtworks.go.config.AdminsConfig)

Example 3 with AdminUser

use of com.thoughtworks.go.config.AdminUser in project gocd by gocd.

the class StageAuthorizationRepresenter method fromJSON.

public static AuthConfig fromJSON(JsonReader jsonReader) {
    AuthConfig authConfig = new AuthConfig();
    jsonReader.readArrayIfPresent("roles", roles -> {
        roles.forEach(role -> {
            authConfig.add(new AdminRole(new CaseInsensitiveString(role.getAsString())));
        });
    });
    jsonReader.readArrayIfPresent("users", users -> {
        users.forEach(user -> {
            authConfig.add(new AdminUser(new CaseInsensitiveString(user.getAsString())));
        });
    });
    return authConfig;
}
Also used : AdminUser(com.thoughtworks.go.config.AdminUser) AuthConfig(com.thoughtworks.go.config.AuthConfig) AdminRole(com.thoughtworks.go.config.AdminRole) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 4 with AdminUser

use of com.thoughtworks.go.config.AdminUser in project gocd by gocd.

the class StageAuthorizationRepresenter method fromJSON.

public static AuthConfig fromJSON(JsonReader jsonReader) {
    AuthConfig authConfig = new AuthConfig();
    jsonReader.readArrayIfPresent("roles", roles -> {
        roles.forEach(role -> {
            authConfig.add(new AdminRole(new CaseInsensitiveString(role.getAsString())));
        });
    });
    jsonReader.readArrayIfPresent("users", users -> {
        users.forEach(user -> {
            authConfig.add(new AdminUser(new CaseInsensitiveString(user.getAsString())));
        });
    });
    return authConfig;
}
Also used : AdminUser(com.thoughtworks.go.config.AdminUser) AuthConfig(com.thoughtworks.go.config.AuthConfig) AdminRole(com.thoughtworks.go.config.AdminRole) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 5 with AdminUser

use of com.thoughtworks.go.config.AdminUser in project gocd by gocd.

the class StageAuthorizationRepresenter method fromJSON.

public static AuthConfig fromJSON(JsonReader jsonReader) {
    AuthConfig authConfig = new AuthConfig();
    jsonReader.readArrayIfPresent("roles", roles -> {
        roles.forEach(role -> {
            authConfig.add(new AdminRole(new CaseInsensitiveString(role.getAsString())));
        });
    });
    jsonReader.readArrayIfPresent("users", users -> {
        users.forEach(user -> {
            authConfig.add(new AdminUser(new CaseInsensitiveString(user.getAsString())));
        });
    });
    return authConfig;
}
Also used : AdminUser(com.thoughtworks.go.config.AdminUser) AuthConfig(com.thoughtworks.go.config.AuthConfig) AdminRole(com.thoughtworks.go.config.AdminRole) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Aggregations

AdminUser (com.thoughtworks.go.config.AdminUser)5 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)5 AdminRole (com.thoughtworks.go.config.AdminRole)4 AuthConfig (com.thoughtworks.go.config.AuthConfig)4 AdminsConfig (com.thoughtworks.go.config.AdminsConfig)1 Approval (com.thoughtworks.go.config.Approval)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 StageConfig (com.thoughtworks.go.config.StageConfig)1 Test (org.junit.jupiter.api.Test)1