use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testInvalidAccessResource.
@Test
public void testInvalidAccessResource() {
String action = "ACCESS";
String angResource = "angler:tables.blahblah";
StringBuilder roleName = new StringBuilder();
AccessCheckStatus status = AuthZpeClient.allowAccess(rToken0AnglerPachinko, angResource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.DENY_NO_MATCH);
Assert.assertEquals(roleName.toString(), "");
}
use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testPublicReadAllowed.
@Test
public void testPublicReadAllowed() {
String action = "read";
String angResource = "angler:stuff";
AccessCheckStatus 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 testMultipleTokens.
@Test
public void testMultipleTokens() {
String action = "REad";
StringBuilder roleName = new StringBuilder();
String resource = "sports.NFL_DB";
AccessCheckStatus status = AuthZpeClient.allowAccess(rToken0SportsAdmin, resource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
Assert.assertEquals(roleName.toString(), "admin");
// multi tokens test
List<String> tokenList = new ArrayList<>();
tokenList.add(rToken0SportsAdmin.getSignedToken());
tokenList.add(rToken0CoreTechPublic.getSignedToken());
roleName = new StringBuilder();
status = AuthZpeClient.allowAccess(tokenList, resource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
Assert.assertEquals(roleName.toString(), "admin");
// multi tokens test with duplicate tokens
tokenList = new ArrayList<>();
tokenList.add(rToken0SportsAdmin.getSignedToken());
tokenList.add(rToken0SportsAdmin.getSignedToken());
roleName = new StringBuilder();
status = AuthZpeClient.allowAccess(tokenList, resource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
Assert.assertEquals(roleName.toString(), "admin");
}
use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testMultipleTokenListEmpty.
@Test
public void testMultipleTokenListEmpty() {
String action = "REad";
String resource = "sports.NFL_DB";
StringBuilder roleName = new StringBuilder();
// multi token list - empty
List<String> tokenList = new ArrayList<>();
AccessCheckStatus status = AuthZpeClient.allowAccess(tokenList, 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 testAllowAccessMatchRegexAllowed.
@Test
public void testAllowAccessMatchRegexAllowed() {
String action = "regex";
String resource = "angler:nhllosangeleskings";
StringBuilder roleName = new StringBuilder();
AccessCheckStatus status = AuthZpeClient.allowAccess(rToken0AnglerRegex, resource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
Assert.assertEquals(roleName.toString(), "matchregex");
// 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(), "matchregex");
}
Aggregations