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);
}
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());
}
Aggregations