Search in sources :

Example 6 with Policy

use of com.thoughtworks.go.config.policy.Policy in project gocd by gocd.

the class PermissionsServiceIntegrationTest method definePolicy.

private void definePolicy(CruiseConfig cruiseConfig, String type, String resource1, String resource2) {
    Role role = new RoleConfig("gocd", new RoleUser(SessionUtils.currentUsername().getUsername()));
    Policy policy = new Policy();
    policy.add(new Allow("view", type, resource1));
    policy.add(new Allow("administer", type, resource2));
    role.setPolicy(policy);
    cruiseConfig.server().security().getRoles().add(role);
}
Also used : Policy(com.thoughtworks.go.config.policy.Policy) Allow(com.thoughtworks.go.config.policy.Allow)

Aggregations

Policy (com.thoughtworks.go.config.policy.Policy)6 Allow (com.thoughtworks.go.config.policy.Allow)5 Test (org.junit.jupiter.api.Test)3 JsonParseException (com.google.gson.JsonParseException)1 JsonReader (com.thoughtworks.go.api.representers.JsonReader)1 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 Role (com.thoughtworks.go.config.Role)1 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)1