use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testPublicThrowDenied.
@Test
public void testPublicThrowDenied() {
String action = "THrow";
String angResource = "angler:stuff";
StringBuilder roleName = new StringBuilder();
AccessCheckStatus status = AuthZpeClient.allowAccess(rToken0AnglerPublic, angResource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.DENY);
}
use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testAllowAccessMatchEqualAllowed.
@Test
public void testAllowAccessMatchEqualAllowed() {
String action = "compare";
String resource = "angler:compare";
StringBuilder roleName = new StringBuilder();
AccessCheckStatus status = AuthZpeClient.allowAccess(rToken0AnglerRegex, resource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
Assert.assertEquals(roleName.toString(), "matchcompare");
// multi tokens test
List<String> tokenList = new ArrayList<>();
tokenList.add(rToken0AnglerExpirePublic.getSignedToken());
tokenList.add(rToken0AnglerRegex.getSignedToken());
tokenList.add(rToken0AnglerPublic.getSignedToken());
tokenList.add(rToken0CoreTechPublic.getSignedToken());
roleName = new StringBuilder();
status = AuthZpeClient.allowAccess(tokenList, resource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
Assert.assertEquals(roleName.toString(), "matchcompare");
}
use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testWildcardManagePondsKernDenied.
@Test
public void testWildcardManagePondsKernDenied() {
String action = "manage";
String angResource = "angler:pondsVenturaCounty";
List<String> roles = new ArrayList<>();
roles.add("managerkernco");
// 1000 sec expiry
RoleToken rtoken = createRoleToken("angler", roles, "0", 1000);
StringBuilder roleName = new StringBuilder(256);
AccessCheckStatus status = AuthZpeClient.allowAccess(rtoken, angResource, action, roleName);
// Kern county manager not allowed to manage Ventura county ponds
Assert.assertEquals(status, AccessCheckStatus.DENY);
}
use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testWildcardManagePondsAllowedTokenString.
@Test
public void testWildcardManagePondsAllowedTokenString() {
String action = "manage";
String angResource = "angler:pondsKernCounty";
List<String> roles = new ArrayList<>();
roles.add("managerkernco");
roles.add("managerventuraco");
// 1000 sec expiry
RoleToken rtoken = createRoleToken("angler", roles, "0", 1000);
AccessCheckStatus status = AuthZpeClient.allowAccess(rtoken.getSignedToken(), angResource, action);
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
}
use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testPublicWriteAllowedMixCaseActionResource.
@Test
public void testPublicWriteAllowedMixCaseActionResource() {
String action = "WRite";
String angResource = "angLEr:STUff";
StringBuilder roleName = new StringBuilder();
AccessCheckStatus status = AuthZpeClient.allowAccess(rToken0AnglerPublic, angResource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
}
Aggregations