@Override
    public Result apply(String action, Class<? extends Validatable> aClass, String resource, String resourceToOperateWithin) {
        if (matchesAction(action) && matchesType(aClass) && matchesResource(resource)) {
            return Result.ALLOW;
        }

        if (isRequestForElasticAgentProfiles(aClass) && matchesAction(action) && matchesResource(resourceToOperateWithin)) {
            return Result.ALLOW;
        }

        return Result.SKIP;
    }
@Test
    void forAdministerOfWildcardDefinedClusterProfile() {
        Allow directive = new Allow("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.ALLOW);
        assertThat(viewAllElasticAgentProfilesUnderTeam2).isEqualTo(Result.SKIP);

        assertThat(viewAllClusterProfiles).isEqualTo(Result.SKIP);
        assertThat(viewTeam1ClusterProfile).isEqualTo(Result.ALLOW);
        assertThat(viewTeam2ClusterProfile).isEqualTo(Result.SKIP);

        assertThat(administerAllElasticAgentProfiles).isEqualTo(Result.SKIP);
        assertThat(administerAllElasticAgentProfilesUnderTeam1).isEqualTo(Result.ALLOW);
        assertThat(administerAllElasticAgentProfilesUnderTeam2).isEqualTo(Result.SKIP);

        assertThat(administerAllClusterProfiles).isEqualTo(Result.SKIP);
        assertThat(administerTeam1ClusterProfile).isEqualTo(Result.ALLOW);
        assertThat(administerTeam2ClusterProfile).isEqualTo(Result.SKIP);
    }