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);
}
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);
}
}
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"));
}
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);
}
}
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);
}
}
Aggregations