RoleAuthority implements Authority, AuthorityKeyStore { @Override public void initialize() { } RoleAuthority(); @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); final static String SYS_AUTH_DOMAIN; final static String ZTS_SERVICE_NAME; static final String HTTP_HEADER; static final String ATHENZ_AUTH_CHALLENGE; static final String ATHENZ_PROP_ROLE_HEADER; }
@Test public void testInitialize() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { Class<RoleAuthority> c = RoleAuthority.class; RoleAuthority roleAuthority = new RoleAuthority(); System.setProperty(RoleAuthority.ATHENZ_PROP_TOKEN_OFFSET, "-1"); roleAuthority.initialize(); Field f1 = c.getDeclaredField("allowedOffset"); f1.setAccessible(true); int m = (Integer) f1.get(roleAuthority); assertEquals(m,300); assertEquals(roleAuthority.userDomain,"user"); }