Search in sources :

Example 41 with Principal

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();
}
Also used : SimplePrincipal(com.yahoo.athenz.auth.impl.SimplePrincipal) Principal(com.yahoo.athenz.auth.Principal) Test(org.testng.annotations.Test)

Example 42 with Principal

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();
}
Also used : SimplePrincipal(com.yahoo.athenz.auth.impl.SimplePrincipal) Principal(com.yahoo.athenz.auth.Principal) Test(org.testng.annotations.Test)

Example 43 with Principal

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");
}
Also used : SimplePrincipal(com.yahoo.athenz.auth.impl.SimplePrincipal) Principal(com.yahoo.athenz.auth.Principal) Test(org.testng.annotations.Test)

Example 44 with Principal

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();
}
Also used : SimplePrincipal(com.yahoo.athenz.auth.impl.SimplePrincipal) Principal(com.yahoo.athenz.auth.Principal) Test(org.testng.annotations.Test)

Example 45 with Principal

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();
}
Also used : SimplePrincipal(com.yahoo.athenz.auth.impl.SimplePrincipal) Principal(com.yahoo.athenz.auth.Principal) Test(org.testng.annotations.Test)

Aggregations

Principal (com.yahoo.athenz.auth.Principal)258 SimplePrincipal (com.yahoo.athenz.auth.impl.SimplePrincipal)218 Test (org.testng.annotations.Test)168 Authority (com.yahoo.athenz.auth.Authority)66 PrincipalAuthority (com.yahoo.athenz.auth.impl.PrincipalAuthority)52 ArrayList (java.util.ArrayList)35 SignedDomain (com.yahoo.athenz.zms.SignedDomain)33 BeforeTest (org.testng.annotations.BeforeTest)17 AthenzDomain (com.yahoo.athenz.zms.store.AthenzDomain)14 SimpleServiceIdentityProvider (com.yahoo.athenz.auth.impl.SimpleServiceIdentityProvider)13 AuditLogMsgBuilder (com.yahoo.athenz.common.server.log.AuditLogMsgBuilder)13 IOException (java.io.IOException)13 PrincipalToken (com.yahoo.athenz.auth.token.PrincipalToken)12 HttpServletRequest (javax.servlet.http.HttpServletRequest)12 KeyStore (com.yahoo.athenz.auth.KeyStore)11 UnsupportedEncodingException (java.io.UnsupportedEncodingException)10 WebApplicationException (javax.ws.rs.WebApplicationException)10 X509Certificate (java.security.cert.X509Certificate)9 ServiceIdentityProvider (com.yahoo.athenz.auth.ServiceIdentityProvider)8 CertificateAuthority (com.yahoo.athenz.auth.impl.CertificateAuthority)8