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));
}
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;
}
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;
}
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;
}
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;
}
Aggregations