use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testAdminThrowAllowed.
@Test
public void testAdminThrowAllowed() {
String action = "THrow";
String angResource = "angler:stuff";
StringBuilder roleName = new StringBuilder();
AccessCheckStatus status = AuthZpeClient.allowAccess(rToken0AnglerAdmin, angResource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
}
use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testAllowAccessMatchAllAccessToken.
@Test
public void testAllowAccessMatchAllAccessToken() throws IOException {
String action = "all";
String resource = "angler:stuff";
StringBuilder roleName = new StringBuilder();
Path path = Paths.get("src/test/resources/mtls_token_spec.cert");
String certStr = new String(Files.readAllBytes(path));
X509Certificate cert = Crypto.loadX509Certificate(certStr);
AccessCheckStatus status = AuthZpeClient.allowAccess(accessToken0AnglerRegex, cert, null, resource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
Assert.assertEquals(roleName.toString(), "matchall");
// second time for the same token we should get from the cache
status = AuthZpeClient.allowAccess(accessToken0AnglerRegex, resource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
Assert.assertEquals(roleName.toString(), "matchall");
// now we're going to include the Bearer part
status = AuthZpeClient.allowAccess("Bearer " + accessToken0AnglerRegex, resource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
Assert.assertEquals(roleName.toString(), "matchall");
}
use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testAllowAccessMatchAllAccessTokenNoRoleName.
@Test
public void testAllowAccessMatchAllAccessTokenNoRoleName() throws IOException {
String action = "all";
String resource = "angler:stuff";
Path path = Paths.get("src/test/resources/mtls_token_spec.cert");
String certStr = new String(Files.readAllBytes(path));
X509Certificate cert = Crypto.loadX509Certificate(certStr);
AccessCheckStatus status = AuthZpeClient.allowAccess(accessToken0AnglerRegex, cert, null, resource, action);
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
// second time for the same token we should get from the cache
status = AuthZpeClient.allowAccess(accessToken0AnglerRegex, resource, action);
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
// now we're going to include the Bearer part
status = AuthZpeClient.allowAccess("Bearer " + accessToken0AnglerRegex, resource, action);
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
}
use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testAllowAccessCertHashMismatch.
@Test
public void testAllowAccessCertHashMismatch() throws IOException {
String action = "all";
String resource = "angler:stuff";
StringBuilder roleName = new StringBuilder();
Path path = Paths.get("src/test/resources/mtls_token_mismatch.cert");
String certStr = new String(Files.readAllBytes(path));
X509Certificate cert = Crypto.loadX509Certificate(certStr);
AccessCheckStatus status = AuthZpeClient.allowAccess(accessToken0AnglerRegex, cert, null, resource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.DENY_CERT_HASH_MISMATCH);
}
use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testPublicReadMismatchDomain.
@Test
public void testPublicReadMismatchDomain() {
String action = "read";
String angResource = "anglerTest:stuff";
AccessCheckStatus status = AuthZpeClient.allowAccess(rToken0AnglerPublic.getSignedToken(), angResource, action);
Assert.assertEquals(status, AccessCheckStatus.DENY_DOMAIN_MISMATCH);
// 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_MISMATCH);
Assert.assertEquals(roleName.toString(), "");
}
Aggregations