use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testPublicReadAllowedMixCaseActionResource.
@Test
public void testPublicReadAllowedMixCaseActionResource() {
String action = "REad";
String angResource = "ANGler:stuff";
StringBuilder roleName = new StringBuilder();
AccessCheckStatus status = AuthZpeClient.allowAccess(rToken0AnglerPublic, angResource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
status = AuthZpeClient.allowAccess(rToken0AnglerPublic.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 testPublicReadDomainEmpty.
@Test
public void testPublicReadDomainEmpty() {
String action = "read";
String angResource = "empty:stuff";
AccessCheckStatus status = AuthZpeClient.allowAccess(rToken0EmptyPublic.getSignedToken(), angResource, action);
Assert.assertEquals(status, AccessCheckStatus.DENY_DOMAIN_EMPTY);
// multi tokens test
List<String> tokenList = new ArrayList<>();
tokenList.add(rToken0AnglerPublic.getSignedToken());
tokenList.add(rToken0EmptyPublic.getSignedToken());
StringBuilder roleName = new StringBuilder();
status = AuthZpeClient.allowAccess(tokenList, angResource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.DENY_DOMAIN_EMPTY);
Assert.assertEquals(roleName.toString(), "");
}
use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testAllowAccessMatchRegexDenied.
@Test
public void testAllowAccessMatchRegexDenied() {
String action = "regex";
String resource = "angler:nhllosangeleskingsA";
/* extra A after kings */
StringBuilder roleName = new StringBuilder();
AccessCheckStatus status = AuthZpeClient.allowAccess(rToken0AnglerRegex, resource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.DENY_NO_MATCH);
}
use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testWildcardManagePondsVenturaAllowed.
@Test
public void testWildcardManagePondsVenturaAllowed() {
String action = "manage";
String angResource = "angler:pondsKernCounty";
List<String> roles = new ArrayList<>();
roles.add("managerventuraco");
// 1000 sec expiry
RoleToken rtoken = createRoleToken("angler", roles, "0", 1000);
StringBuilder roleName = new StringBuilder(256);
AccessCheckStatus status = AuthZpeClient.allowAccess(rtoken, angResource, action, roleName);
// Ventura county manager is allowed to manage Kern county ponds
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
Assert.assertEquals(roleName.toString(), "manager*");
}
use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testAllowAccessMatchRegexInvalidRange1.
@Test
public void testAllowAccessMatchRegexInvalidRange1() {
String action = "full_regex";
String resource = "angler:corea";
StringBuilder roleName = new StringBuilder();
AccessCheckStatus status = AuthZpeClient.allowAccess(rToken0AnglerRegex, resource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.DENY_NO_MATCH);
}
Aggregations