Search in sources :

Example 1 with DebugPrincipalAuthority

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());
}
Also used : DebugPrincipalAuthority(com.yahoo.athenz.common.server.debug.DebugPrincipalAuthority) Authority(com.yahoo.athenz.auth.Authority) DebugPrincipalAuthority(com.yahoo.athenz.common.server.debug.DebugPrincipalAuthority) Principal(com.yahoo.athenz.auth.Principal) Test(org.testng.annotations.Test)

Aggregations

Authority (com.yahoo.athenz.auth.Authority)1 Principal (com.yahoo.athenz.auth.Principal)1 DebugPrincipalAuthority (com.yahoo.athenz.common.server.debug.DebugPrincipalAuthority)1 Test (org.testng.annotations.Test)1