use of com.yahoo.athenz.common.server.debug.DebugPrincipalAuthority in project athenz by yahoo.
the class DebugPrincipalAuthorityTest method testPrincipalAuthority.
@Test
public void testPrincipalAuthority() {
Authority principalAuthority = new com.yahoo.athenz.common.server.debug.DebugPrincipalAuthority();
assertNotNull(principalAuthority);
principalAuthority.initialize();
((DebugPrincipalAuthority) principalAuthority).setKeyStore(null);
assertNull(principalAuthority.getDomain());
assertEquals(principalAuthority.getHeader(), "Athenz-Principal-Auth");
// invalid authenticate values
assertNull(principalAuthority.authenticate(null, "10.11.12.13", "GET", null));
assertNull(principalAuthority.authenticate("abc", "10.11.12.13", "GET", null));
assertNull(principalAuthority.authenticate("v=S1;d=coretech;s=signature", "10.11.12.13", "GET", null));
assertNull(principalAuthority.authenticate("v=S1;n=storage;s=signature", "10.11.12.13", "GET", null));
// valid values
String token = "v=S1;d=coretech;n=storage;s=signature";
Principal p = principalAuthority.authenticate(token, "10.11.12.13", "GET", null);
assertNotNull(p);
assertEquals(p.getDomain(), "coretech");
assertEquals(p.getName(), "storage");
assertEquals(p.getCredentials(), token);
assertNull(p.getRoles());
}
Aggregations