PrincipalAuthority implements Authority, AuthorityKeyStore { @Override public void initialize() { } PrincipalAuthority(); @Override String getID(); @Override void initialize(); @Override String getDomain(); @Override String getHeader(); @Override String getAuthenticateChallenge(); @Override Principal authenticate(String signedToken, String remoteAddr, String httpMethod,
            StringBuilder errMsg); @Override void setKeyStore(KeyStore keyStore); static final String HTTP_HEADER; static final String ATHENZ_AUTH_CHALLENGE; static final String ATHENZ_PROP_PRINCIPAL_HEADER; }
@Test public void testGetCredSource() { PrincipalAuthority authority = new PrincipalAuthority(); authority.initialize(); assertEquals(CredSource.HEADER, authority.getCredSource()); }
@Test public void testInitialize() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { Class<PrincipalAuthority> c = PrincipalAuthority.class; PrincipalAuthority principalAuthority = new PrincipalAuthority(); System.setProperty(PrincipalAuthority.ATHENZ_PROP_TOKEN_OFFSET, "-1"); principalAuthority.initialize(); Field f1 = c.getDeclaredField("allowedOffset"); f1.setAccessible(true); int m = (Integer) f1.get(principalAuthority); assertEquals(m, 300); assertEquals(principalAuthority.userDomain, "user"); }