use of com.yahoo.athenz.auth.Principal in project athenz by yahoo.
the class ZTSClientTest method testIsExpiredTokenBiggerThanMax.
@Test
public void testIsExpiredTokenBiggerThanMax() {
Principal principal = SimplePrincipal.create("user_domain", "user", "v=S1;d=user_domain;n=user;s=sig", PRINCIPAL_AUTHORITY);
ZTSClient client = new ZTSClient("http://localhost:4080/", principal);
assertTrue(client.isExpiredToken(500, null, 300));
assertTrue(client.isExpiredToken(500, 200, 300));
client.close();
}
use of com.yahoo.athenz.auth.Principal in project athenz by yahoo.
the class ZTSClientTest method testAddPrincipalCredentialsSIAReset.
@Test
public void testAddPrincipalCredentialsSIAReset() {
ZTSClient client = new ZTSClient("http://localhost:4080", "coretech", "storage", siaMockProvider);
Principal principal = SimplePrincipal.create("user_domain", "user", "auth_creds", PRINCIPAL_AUTHORITY);
client.addPrincipalCredentials(principal, true);
assertNotNull(client);
client.close();
}
use of com.yahoo.athenz.auth.Principal in project athenz by yahoo.
the class ZTSClientTest method testConstructorPrincipalAndUrl.
@Test
public void testConstructorPrincipalAndUrl() {
Principal principal = SimplePrincipal.create("user_domain", "user", "auth_creds", PRINCIPAL_AUTHORITY);
ZTSClient client = new ZTSClient("http://localhost:4080/", principal);
assertNotNull(client);
assertNotNull(client.ztsClient);
assertEquals(client.principal, principal);
assertEquals(client.getZTSUrl(), "http://localhost:4080/zts/v1");
}
use of com.yahoo.athenz.auth.Principal in project athenz by yahoo.
the class ZTSClientTest method testLookupAwsCredInCacheNotPresent.
@Test
public void testLookupAwsCredInCacheNotPresent() {
Principal principal = SimplePrincipal.create("user_domain", "user", "auth_creds", PRINCIPAL_AUTHORITY);
ZTSClient client = new ZTSClient("http://localhost:4080/", principal);
String cacheKey = "p=auth_creds;d=coretech;r=Role1";
assertNull(client.lookupAwsCredInCache(cacheKey, null, null));
client.close();
}
use of com.yahoo.athenz.auth.Principal in project athenz by yahoo.
the class ZTSClientTest method testLookupAwsCredInCacheExpired.
@SuppressWarnings("static-access")
@Test
public void testLookupAwsCredInCacheExpired() {
Principal principal = SimplePrincipal.create("user_domain", "user", "auth_creds", PRINCIPAL_AUTHORITY);
ZTSClient client = new ZTSClient("http://localhost:4080/", principal);
String cacheKey = "p=auth_creds;d=coretech;r=Role1";
AWSTemporaryCredentials awsCred = new AWSTemporaryCredentials().setAccessKeyId("accesskey").setExpiration(Timestamp.fromMillis((System.currentTimeMillis() / 1000) + 1000L)).setSecretAccessKey("secretkey").setSessionToken("sesstoken");
client.AWS_CREDS_CACHE.put(cacheKey, awsCred);
assertNull(client.lookupAwsCredInCache(cacheKey, 3000, 4000));
assertNull(client.lookupAwsCredInCache(cacheKey, 500, 800));
client.AWS_CREDS_CACHE.clear();
client.close();
}
Aggregations