use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testPublicThrowDeniedCaseSensitive.
@Test
public void testPublicThrowDeniedCaseSensitive() {
String action = "THrow2";
String angResource = "angler:StufF2";
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 testWildcardManageRiversKernAllowed.
@Test
public void testWildcardManageRiversKernAllowed() {
String action = "manage";
String angResource = "angler:RiversKernCounty";
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);
// 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 testTokenExpired.
@Test
public void testTokenExpired() {
String action = "REad";
String angResource = "ANGler:stuff";
StringBuilder roleName = new StringBuilder();
RoleToken tokenMock = Mockito.mock(RoleToken.class);
// too old
Mockito.when(tokenMock.getExpiryTime()).thenReturn(1L);
AccessCheckStatus status = AuthZpeClient.allowAccess(tokenMock, angResource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.DENY_ROLETOKEN_EXPIRED);
}
use of com.yahoo.athenz.zpe.AuthZpeClient.AccessCheckStatus in project athenz by yahoo.
the class TestAuthZpe method testPublicUknActDenied.
@Test
public void testPublicUknActDenied() {
String action = "WRiteREad";
String angResource = "angler:stuff";
StringBuilder roleName = new StringBuilder();
AccessCheckStatus status = AuthZpeClient.allowAccess(rToken0AnglerPublic, angResource, 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 testValidAccessResourceCaseSensitive.
@Test
public void testValidAccessResourceCaseSensitive() {
String action = "AccesS2";
String angResource = "angler:TableS.BlaH2";
StringBuilder roleName = new StringBuilder();
AccessCheckStatus status = AuthZpeClient.allowAccess(rToken0AnglerPachinko, angResource, action, roleName);
Assert.assertEquals(status, AccessCheckStatus.ALLOW);
Assert.assertEquals(roleName.toString(), "pachinko");
}
Aggregations