Search in sources :

Example 1 with DebugKerberosAuthority

use of com.yahoo.athenz.common.server.debug.DebugKerberosAuthority in project athenz by yahoo.

the class DebugKerberosAuthorityTest method testDebugKerberosAuthoritySysProp.

@Test
public void testDebugKerberosAuthoritySysProp() {
    System.setProperty(DebugKerberosAuthority.ATHENZ_PROP_USER_NAME, "tiesto");
    Authority authority = new DebugKerberosAuthority();
    assertNotNull(authority);
    authority.initialize();
    assertEquals(authority.getDomain(), USER_DOMAIN);
    assertEquals(authority.getHeader(), DebugKerberosAuthority.KRB_HEADER);
    // invalid authenticate values
    assertNull(authority.authenticate(null, "6.21.20.16", "GET", null));
    assertNull(authority.authenticate("abc", "6.21.20.16", "GET", null));
    assertNull(authority.authenticate(KRB_TOKEN, "6.21.20.16", "GET", null));
    // valid values
    Principal prnc = authority.authenticate(DebugKerberosAuthority.TOKEN_PREFIX + " " + KRB_TOKEN, "6.21.20.16", "GET", null);
    assertNotNull(prnc);
    assertEquals(prnc.getDomain(), USER_DOMAIN);
    assertEquals(prnc.getName(), "tiesto");
    assertEquals(prnc.getCredentials(), KRB_TOKEN);
    assertNull(prnc.getRoles());
    // now use debug token that contains user name
    String token = DebugKerberosAuthority.TOKEN_PREFIX + " " + DebugKerberosAuthority.TOKEN_DEBUG_USER_FIELD + "jamesdean";
    prnc = authority.authenticate(token, "6.21.20.16", "GET", null);
    assertNotNull(prnc);
    assertEquals(prnc.getDomain(), USER_DOMAIN);
    assertEquals(prnc.getName(), "jamesdean");
    assertEquals(prnc.getCredentials(), DebugKerberosAuthority.TOKEN_DEBUG_USER_FIELD + "jamesdean");
    assertNull(prnc.getRoles());
    System.clearProperty(DebugKerberosAuthority.ATHENZ_PROP_USER_NAME);
}
Also used : DebugKerberosAuthority(com.yahoo.athenz.common.server.debug.DebugKerberosAuthority) Authority(com.yahoo.athenz.auth.Authority) Principal(com.yahoo.athenz.auth.Principal) DebugKerberosAuthority(com.yahoo.athenz.common.server.debug.DebugKerberosAuthority) Test(org.testng.annotations.Test)

Example 2 with DebugKerberosAuthority

use of com.yahoo.athenz.common.server.debug.DebugKerberosAuthority in project athenz by yahoo.

the class DebugKerberosAuthorityTest method testDebugKerberosAuthority.

@Test
public void testDebugKerberosAuthority() {
    Authority authority = new DebugKerberosAuthority();
    assertNotNull(authority);
    authority.initialize();
    assertEquals(authority.getDomain(), USER_DOMAIN);
    assertEquals(authority.getHeader(), DebugKerberosAuthority.KRB_HEADER);
    // invalid authenticate values
    assertNull(authority.authenticate(null, "6.21.20.16", "GET", null));
    assertNull(authority.authenticate("abc", "6.21.20.16", "GET", null));
    assertNull(authority.authenticate(KRB_TOKEN, "6.21.20.16", "GET", null));
    // valid values
    Principal prnc = authority.authenticate(DebugKerberosAuthority.TOKEN_PREFIX + " " + KRB_TOKEN, "6.21.20.16", "GET", null);
    assertNotNull(prnc);
    assertEquals(prnc.getDomain(), USER_DOMAIN);
    assertEquals(prnc.getName(), "anonymous");
    assertEquals(prnc.getCredentials(), KRB_TOKEN);
    assertNull(prnc.getRoles());
}
Also used : DebugKerberosAuthority(com.yahoo.athenz.common.server.debug.DebugKerberosAuthority) Authority(com.yahoo.athenz.auth.Authority) Principal(com.yahoo.athenz.auth.Principal) DebugKerberosAuthority(com.yahoo.athenz.common.server.debug.DebugKerberosAuthority) Test(org.testng.annotations.Test)

Aggregations

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