use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testAllowAccessMatchRegexInvalidRange2.
@Test
public void testAllowAccessMatchRegexInvalidRange2() {
String action = "full_regex";
String resource = "angler:coreb";
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 testPublicReadDomainNotFound.
@Test
public void testPublicReadDomainNotFound() {
String action = "read";
String angResource = "CoreTech:stuff";
AccessCheckStatus status = AuthZpeClient.allowAccess(rToken0CoreTechPublic.getSignedToken(), angResource, action);
Assert.assertEquals(status, AccessCheckStatus.DENY_DOMAIN_NOT_FOUND);
// multi tokens test
List<String> tokenList = new ArrayList<>();
tokenList.add(rToken0AnglerPublic.getSignedToken());
tokenList.add(rToken0CoreTechPublic.getSignedToken());
StringBuilder roleName = new StringBuilder();
status = AuthZpeClient.allowAccess(tokenList, angResource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.DENY_DOMAIN_NOT_FOUND);
Assert.assertEquals(roleName.toString(), "");
}
use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testAllowAccessMatchRegexInvalidOr1.
@Test
public void testAllowAccessMatchRegexInvalidOr1() {
String action = "full_regex";
String resource = "angler:coretech";
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 testAllowAccessMatchRegexInvalidOr2.
@Test
public void testAllowAccessMatchRegexInvalidOr2() {
String action = "full_regex";
String resource = "angler:corecommit";
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 testPublicReadExpiredRoleToken.
@Test
public void testPublicReadExpiredRoleToken() {
String action = "read";
String angResource = "angler:stuff";
try {
Thread.sleep(3000);
} catch (Exception ignored) {
}
// the roletoken validate return false regardless if the token is
// invalid due to expiry or invalid signature. So we'll only
// the expired roletoken if we add it to the cache and then
// try to use it again, but the cache clear test case sets
// the timeout to 1secs so as soon as it's added, within a
// second it's removed, so we can't wait until it's expired to
// test again. so for know we'll just get invalid token
AccessCheckStatus status = AuthZpeClient.allowAccess(rToken0AnglerExpirePublic.getSignedToken(), angResource, action);
Assert.assertEquals(status, AccessCheckStatus.DENY_ROLETOKEN_EXPIRED);
// multi tokens test
List<String> tokenList = new ArrayList<>();
tokenList.add(rToken0AnglerPublic.getSignedToken());
// add the expired one in
tokenList.add(rToken0AnglerExpirePublic.getSignedToken());
StringBuilder roleName = new StringBuilder();
status = AuthZpeClient.allowAccess(tokenList, angResource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
Assert.assertEquals(roleName.toString(), "public");
}
Aggregations