Search in sources :

Example 41 with SignedDomain

use of com.yahoo.athenz.zms.SignedDomain in project athenz by yahoo.

the class ZTSImplTest method testGetTenantDomainsInvalidUser.

@Test
public void testGetTenantDomainsInvalidUser() {
    SignedDomain signedDomain = createSignedDomain("athenz.product", "weather.frontpage", "storage", true);
    store.processDomain(signedDomain, false);
    signedDomain = createTenantSignedDomain("weather.frontpage", "athenz.product", "storage");
    store.processDomain(signedDomain, false);
    SimplePrincipal principal = (SimplePrincipal) SimplePrincipal.create("hockey", "kings", "v=S1,d=hockey;n=kings;s=sig", 0, new PrincipalAuthority());
    ResourceContext context = createResourceContext(principal);
    TenantDomains tenantDomains = zts.getTenantDomains(context, "athenz.product", "user1099", null, null);
    assertNotNull(tenantDomains);
    assertEquals(tenantDomains.getTenantDomainNames().size(), 0);
}
Also used : SignedDomain(com.yahoo.athenz.zms.SignedDomain) SimplePrincipal(com.yahoo.athenz.auth.impl.SimplePrincipal) PrincipalAuthority(com.yahoo.athenz.auth.impl.PrincipalAuthority) Test(org.testng.annotations.Test)

Example 42 with SignedDomain

use of com.yahoo.athenz.zms.SignedDomain in project athenz by yahoo.

the class ZTSImplTest method testGetAWSTemporaryCredentialsNoCloudStore.

@Test
public void testGetAWSTemporaryCredentialsNoCloudStore() {
    SignedDomain signedDomain = createAwsSignedDomain("athenz.product", "1234");
    store.processDomain(signedDomain, false);
    SimplePrincipal principal = (SimplePrincipal) SimplePrincipal.create("hockey", "kings", "v=S1,d=hockey;n=kings;s=sig", 0, new PrincipalAuthority());
    ResourceContext context = createResourceContext(principal);
    try {
        zts.getAWSTemporaryCredentials(context, "athenz.product", "aws_role_name");
        fail();
    } catch (ResourceException ex) {
        assertEquals(ex.getCode(), 400);
    }
}
Also used : SignedDomain(com.yahoo.athenz.zms.SignedDomain) SimplePrincipal(com.yahoo.athenz.auth.impl.SimplePrincipal) PrincipalAuthority(com.yahoo.athenz.auth.impl.PrincipalAuthority) Test(org.testng.annotations.Test)

Example 43 with SignedDomain

use of com.yahoo.athenz.zms.SignedDomain in project athenz by yahoo.

the class ZTSImplTest method testGetHostServices.

@Test
public void testGetHostServices() {
    SignedDomain signedDomain = createSignedDomain("coretech", "weather", "storage", true);
    store.processDomain(signedDomain, false);
    SimplePrincipal principal = (SimplePrincipal) SimplePrincipal.create("hockey", "kings", "v=S1,d=hockey;n=kings;s=sig", 0, new PrincipalAuthority());
    ResourceContext context = createResourceContext(principal);
    HostServices hosts = zts.getHostServices(context, "host1");
    assertTrue(hosts.getNames().size() == 1);
    assertTrue(hosts.getNames().contains("coretech.storage"));
    hosts = zts.getHostServices(context, "host2");
    assertTrue(hosts.getNames().size() == 2);
    assertTrue(hosts.getNames().contains("coretech.storage"));
    assertTrue(hosts.getNames().contains("coretech.backup"));
    hosts = zts.getHostServices(context, "host3");
    assertTrue(hosts.getNames().size() == 1);
    assertTrue(hosts.getNames().contains("coretech.backup"));
}
Also used : SignedDomain(com.yahoo.athenz.zms.SignedDomain) SimplePrincipal(com.yahoo.athenz.auth.impl.SimplePrincipal) PrincipalAuthority(com.yahoo.athenz.auth.impl.PrincipalAuthority) Test(org.testng.annotations.Test)

Example 44 with SignedDomain

use of com.yahoo.athenz.zms.SignedDomain in project athenz by yahoo.

the class ZTSImplTest method testGetServiceIdentityInvalid.

@Test
public void testGetServiceIdentityInvalid() {
    SignedDomain signedDomain = createSignedDomain("coretech", "weather", "storage", true);
    store.processDomain(signedDomain, false);
    SimplePrincipal principal = (SimplePrincipal) SimplePrincipal.create("hockey", "kings", "v=S1,d=hockey;n=kings;s=sig", 0, new PrincipalAuthority());
    ResourceContext context = createResourceContext(principal);
    try {
        @SuppressWarnings("unused") com.yahoo.athenz.zts.ServiceIdentity svc = zts.getServiceIdentity(context, "coretech", "storage2");
        fail();
    } catch (ResourceException ex) {
        assertTrue(true);
    }
    try {
        @SuppressWarnings("unused") com.yahoo.athenz.zts.ServiceIdentity svc = zts.getServiceIdentity(context, "testDomain2", "storage");
        fail();
    } catch (ResourceException ex) {
        assertTrue(true);
    }
}
Also used : SignedDomain(com.yahoo.athenz.zms.SignedDomain) SimplePrincipal(com.yahoo.athenz.auth.impl.SimplePrincipal) PrincipalAuthority(com.yahoo.athenz.auth.impl.PrincipalAuthority) Test(org.testng.annotations.Test)

Example 45 with SignedDomain

use of com.yahoo.athenz.zms.SignedDomain in project athenz by yahoo.

the class ZTSImplTest method testGetPublicKeyEntryInvalidKeyId.

@Test
public void testGetPublicKeyEntryInvalidKeyId() {
    SignedDomain signedDomain = createSignedDomain("coretech", "weather", "storage", true);
    store.processDomain(signedDomain, false);
    SimplePrincipal principal = (SimplePrincipal) SimplePrincipal.create("hockey", "kings", "v=S1,d=hockey;n=kings;s=sig", 0, new PrincipalAuthority());
    ResourceContext context = createResourceContext(principal);
    // with null we get 400
    try {
        zts.getPublicKeyEntry(context, "coretech", "storage", null);
        fail();
    } catch (ResourceException ex) {
        assertEquals(ex.getCode(), 400);
    }
    // with nonexistent we get 404
    try {
        zts.getPublicKeyEntry(context, "coretech", "storage", "999999");
        fail();
    } catch (ResourceException ex) {
        assertEquals(ex.getCode(), 404);
    }
}
Also used : SignedDomain(com.yahoo.athenz.zms.SignedDomain) SimplePrincipal(com.yahoo.athenz.auth.impl.SimplePrincipal) PrincipalAuthority(com.yahoo.athenz.auth.impl.PrincipalAuthority) Test(org.testng.annotations.Test)

Aggregations

SignedDomain (com.yahoo.athenz.zms.SignedDomain)78 Test (org.testng.annotations.Test)68 SimplePrincipal (com.yahoo.athenz.auth.impl.SimplePrincipal)30 PrincipalAuthority (com.yahoo.athenz.auth.impl.PrincipalAuthority)16 ZMSFileChangeLogStore (com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore)16 InstanceProvider (com.yahoo.athenz.instance.provider.InstanceProvider)14 MockZMSFileChangeLogStore (com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore)14 DomainData (com.yahoo.athenz.zms.DomainData)13 ArrayList (java.util.ArrayList)13 S3Object (com.amazonaws.services.s3.model.S3Object)10 S3ObjectInputStream (com.amazonaws.services.s3.model.S3ObjectInputStream)10 Principal (com.yahoo.athenz.auth.Principal)10 SignedDomains (com.yahoo.athenz.zms.SignedDomains)10 ChangeLogStore (com.yahoo.athenz.zts.store.ChangeLogStore)9 DataStore (com.yahoo.athenz.zts.store.DataStore)9 HashSet (java.util.HashSet)7 AuditLogMsgBuilder (com.yahoo.athenz.common.server.log.AuditLogMsgBuilder)6 AuditLogger (com.yahoo.athenz.common.server.log.AuditLogger)6 DefaultAuditLogMsgBuilder (com.yahoo.athenz.common.server.log.impl.DefaultAuditLogMsgBuilder)6 DefaultAuditLogger (com.yahoo.athenz.common.server.log.impl.DefaultAuditLogger)6