Search in sources :

Example 1 with Deny

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

the class ClusterProfilesDenyDirectiveTest method forViewOfAllClusterProfiles.

@Test
void forViewOfAllClusterProfiles() {
    Deny directive = new Deny("view", "cluster_profile", "*");
    Result viewAllElasticAgentProfiles = directive.apply("view", ElasticProfile.class, "*", null);
    Result viewAllClusterProfiles = directive.apply("view", ClusterProfile.class, "*", null);
    Result administerAllElasticAgentProfiles = directive.apply("administer", ElasticProfile.class, "*", null);
    Result administerAllClusterProfiles = directive.apply("administer", ClusterProfile.class, "*", null);
    assertThat(viewAllElasticAgentProfiles).isEqualTo(Result.DENY);
    assertThat(viewAllClusterProfiles).isEqualTo(Result.DENY);
    assertThat(administerAllElasticAgentProfiles).isEqualTo(Result.SKIP);
    assertThat(administerAllClusterProfiles).isEqualTo(Result.SKIP);
}
Also used : Deny(com.thoughtworks.go.config.policy.Deny) Result(com.thoughtworks.go.config.policy.Result) Test(org.junit.jupiter.api.Test)

Example 2 with Deny

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

the class ClusterProfilesDenyDirectiveTest method forViewOfWildcardDefinedClusterProfile.

@Test
void forViewOfWildcardDefinedClusterProfile() {
    Deny directive = new Deny("view", "cluster_profile", "team1_*");
    Result viewAllElasticAgentProfiles = directive.apply("view", ElasticProfile.class, "*", null);
    Result viewAllElasticAgentProfilesUnderTeam1 = directive.apply("view", ElasticProfile.class, "*", "team1_uat");
    Result viewAllElasticAgentProfilesUnderTeam2 = directive.apply("view", ElasticProfile.class, "*", "team2_uat");
    Result viewAllClusterProfiles = directive.apply("view", ClusterProfile.class, "*", null);
    Result viewTeam1ClusterProfile = directive.apply("view", ClusterProfile.class, "team1_uat", null);
    Result viewTeam2ClusterProfile = directive.apply("view", ClusterProfile.class, "team2_uat", null);
    Result administerAllElasticAgentProfiles = directive.apply("administer", ElasticProfile.class, "*", null);
    Result administerAllElasticAgentProfilesUnderTeam1 = directive.apply("administer", ElasticProfile.class, "*", "team1_uat");
    Result administerAllElasticAgentProfilesUnderTeam2 = directive.apply("administer", ElasticProfile.class, "*", "team2_uat");
    Result administerAllClusterProfiles = directive.apply("administer", ClusterProfile.class, "*", null);
    Result administerTeam1ClusterProfile = directive.apply("administer", ClusterProfile.class, "team1_uat", null);
    Result administerTeam2ClusterProfile = directive.apply("administer", ClusterProfile.class, "team2_uat", null);
    assertThat(viewAllElasticAgentProfiles).isEqualTo(Result.SKIP);
    assertThat(viewAllElasticAgentProfilesUnderTeam1).isEqualTo(Result.DENY);
    assertThat(viewAllElasticAgentProfilesUnderTeam2).isEqualTo(Result.SKIP);
    assertThat(viewAllClusterProfiles).isEqualTo(Result.SKIP);
    assertThat(viewTeam1ClusterProfile).isEqualTo(Result.DENY);
    assertThat(viewTeam2ClusterProfile).isEqualTo(Result.SKIP);
    assertThat(administerAllElasticAgentProfiles).isEqualTo(Result.SKIP);
    assertThat(administerAllElasticAgentProfilesUnderTeam1).isEqualTo(Result.SKIP);
    assertThat(administerAllElasticAgentProfilesUnderTeam2).isEqualTo(Result.SKIP);
    assertThat(administerAllClusterProfiles).isEqualTo(Result.SKIP);
    assertThat(administerTeam1ClusterProfile).isEqualTo(Result.SKIP);
    assertThat(administerTeam2ClusterProfile).isEqualTo(Result.SKIP);
}
Also used : Deny(com.thoughtworks.go.config.policy.Deny) Result(com.thoughtworks.go.config.policy.Result) Test(org.junit.jupiter.api.Test)

Example 3 with Deny

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

the class ClusterProfilesDenyDirectiveTest method forAdministerOfAllClusterProfiles.

@Test
void forAdministerOfAllClusterProfiles() {
    Deny directive = new Deny("administer", "cluster_profile", "*");
    Result viewAllElasticAgentProfiles = directive.apply("view", ElasticProfile.class, "*", null);
    Result viewAllClusterProfiles = directive.apply("view", ClusterProfile.class, "*", null);
    Result administerAllElasticAgentProfiles = directive.apply("administer", ElasticProfile.class, "*", null);
    Result administerAllClusterProfiles = directive.apply("administer", ClusterProfile.class, "*", null);
    assertThat(viewAllElasticAgentProfiles).isEqualTo(Result.DENY);
    assertThat(viewAllClusterProfiles).isEqualTo(Result.DENY);
    assertThat(administerAllElasticAgentProfiles).isEqualTo(Result.DENY);
    assertThat(administerAllClusterProfiles).isEqualTo(Result.DENY);
}
Also used : Deny(com.thoughtworks.go.config.policy.Deny) Result(com.thoughtworks.go.config.policy.Result) Test(org.junit.jupiter.api.Test)

Example 4 with Deny

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

the class ClusterProfilesDenyDirectiveTest method forAdministerOfWildcardDefinedClusterProfile.

@Test
void forAdministerOfWildcardDefinedClusterProfile() {
    Deny directive = new Deny("administer", "cluster_profile", "team1_*");
    Result viewAllElasticAgentProfiles = directive.apply("view", ElasticProfile.class, "*", null);
    Result viewAllElasticAgentProfilesUnderTeam1 = directive.apply("view", ElasticProfile.class, "*", "team1_uat");
    Result viewAllElasticAgentProfilesUnderTeam2 = directive.apply("view", ElasticProfile.class, "*", "team2_uat");
    Result viewAllClusterProfiles = directive.apply("view", ClusterProfile.class, "*", null);
    Result viewTeam1ClusterProfile = directive.apply("view", ClusterProfile.class, "team1_uat", null);
    Result viewTeam2ClusterProfile = directive.apply("view", ClusterProfile.class, "team2_uat", null);
    Result administerAllElasticAgentProfiles = directive.apply("administer", ElasticProfile.class, "*", null);
    Result administerAllElasticAgentProfilesUnderTeam1 = directive.apply("administer", ElasticProfile.class, "*", "team1_uat");
    Result administerAllElasticAgentProfilesUnderTeam2 = directive.apply("administer", ElasticProfile.class, "*", "team2_uat");
    Result administerAllClusterProfiles = directive.apply("administer", ClusterProfile.class, "*", null);
    Result administerTeam1ClusterProfile = directive.apply("administer", ClusterProfile.class, "team1_uat", null);
    Result administerTeam2ClusterProfile = directive.apply("administer", ClusterProfile.class, "team2_uat", null);
    assertThat(viewAllElasticAgentProfiles).isEqualTo(Result.SKIP);
    assertThat(viewAllElasticAgentProfilesUnderTeam1).isEqualTo(Result.DENY);
    assertThat(viewAllElasticAgentProfilesUnderTeam2).isEqualTo(Result.SKIP);
    assertThat(viewAllClusterProfiles).isEqualTo(Result.SKIP);
    assertThat(viewTeam1ClusterProfile).isEqualTo(Result.DENY);
    assertThat(viewTeam2ClusterProfile).isEqualTo(Result.SKIP);
    assertThat(administerAllElasticAgentProfiles).isEqualTo(Result.SKIP);
    assertThat(administerAllElasticAgentProfilesUnderTeam1).isEqualTo(Result.DENY);
    assertThat(administerAllElasticAgentProfilesUnderTeam2).isEqualTo(Result.SKIP);
    assertThat(administerAllClusterProfiles).isEqualTo(Result.SKIP);
    assertThat(administerTeam1ClusterProfile).isEqualTo(Result.DENY);
    assertThat(administerTeam2ClusterProfile).isEqualTo(Result.SKIP);
}
Also used : Deny(com.thoughtworks.go.config.policy.Deny) Result(com.thoughtworks.go.config.policy.Result) Test(org.junit.jupiter.api.Test)

Aggregations

Deny (com.thoughtworks.go.config.policy.Deny)4 Result (com.thoughtworks.go.config.policy.Result)4 Test (org.junit.jupiter.api.Test)4