Search in sources :

Example 31 with SignedDomain

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

the class S3ChangeLogStoreTest method testNoOpMethods.

@Test
public void testNoOpMethods() {
    S3ChangeLogStore store = new S3ChangeLogStore();
    store.removeLocalDomain("iaas.athenz");
    store.saveLocalDomain("iaas.athenz", new SignedDomain());
    store.saveLocalDomain("iaas.athenz", new JWSDomain());
}
Also used : JWSDomain(com.yahoo.athenz.zms.JWSDomain) SignedDomain(com.yahoo.athenz.zms.SignedDomain) Test(org.testng.annotations.Test)

Example 32 with SignedDomain

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

the class S3ChangeLogStoreTest method testGetUpdatedSignedDomainsWithChange.

@Test
public void testGetUpdatedSignedDomainsWithChange() throws IOException {
    MockS3ChangeLogStore store = new MockS3ChangeLogStore();
    ArrayList<S3ObjectSummary> objectList = new ArrayList<>();
    S3ObjectSummary objectSummary = new S3ObjectSummary();
    objectSummary.setKey("iaas");
    objectSummary.setLastModified(new Date(100));
    objectList.add(objectSummary);
    objectSummary = new S3ObjectSummary();
    objectSummary.setKey("iaas.athenz");
    objectSummary.setLastModified(new Date(200));
    objectList.add(objectSummary);
    // we'll also include an invalid domain that should be skipped
    objectSummary = new S3ObjectSummary();
    objectSummary.setKey("unknown");
    objectSummary.setLastModified(new Date(200));
    objectList.add(objectSummary);
    ObjectListing objectListing = mock(ObjectListing.class);
    when(objectListing.getObjectSummaries()).thenReturn(objectList);
    when(objectListing.isTruncated()).thenReturn(false);
    when(store.awsS3Client.listObjects(any(ListObjectsRequest.class))).thenReturn(objectListing);
    InputStream is = new FileInputStream("src/test/resources/iaas.json");
    MockS3ObjectInputStream s3Is = new MockS3ObjectInputStream(is, null);
    S3Object object = mock(S3Object.class);
    when(object.getObjectContent()).thenReturn(s3Is);
    when(store.awsS3Client.getObject("s3-unit-test-bucket-name", "iaas")).thenReturn(object);
    when(store.awsS3Client.getObject("s3-unit-test-bucket-name", "iaas.athenz")).thenReturn(object);
    // set the last modification time to return one of the domains
    store.lastModTime = (new Date(150)).getTime();
    StringBuilder lastModTimeBuffer = new StringBuilder(512);
    SignedDomains signedDomains = store.getUpdatedSignedDomains(lastModTimeBuffer);
    assertTrue(lastModTimeBuffer.length() > 0);
    List<SignedDomain> domainList = signedDomains.getDomains();
    assertEquals(domainList.size(), 1);
    DomainData domainData = domainList.get(0).getDomain();
    assertNotNull(domainData);
    assertEquals(domainData.getName(), "iaas");
    is.close();
}
Also used : S3ObjectInputStream(com.amazonaws.services.s3.model.S3ObjectInputStream) DomainData(com.yahoo.athenz.zms.DomainData) ObjectListing(com.amazonaws.services.s3.model.ObjectListing) S3ObjectSummary(com.amazonaws.services.s3.model.S3ObjectSummary) SignedDomains(com.yahoo.athenz.zms.SignedDomains) ListObjectsRequest(com.amazonaws.services.s3.model.ListObjectsRequest) SignedDomain(com.yahoo.athenz.zms.SignedDomain) S3Object(com.amazonaws.services.s3.model.S3Object) Test(org.testng.annotations.Test)

Example 33 with SignedDomain

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

the class InstanceProviderManagerTest method testGetClassProvider.

@Test
public void testGetClassProvider() {
    SignedDomain signedDomain = createSignedDomainClassEndpoint("coretech", "weather", true, true);
    store.processSignedDomain(signedDomain, false);
    InstanceProviderManager provider = new InstanceProviderManager(store, null, null, null, null);
    InstanceProvider client = provider.getProvider("coretech.weather", new HostnameResolver() {
    });
    assertNotNull(client);
    client.close();
}
Also used : HostnameResolver(com.yahoo.athenz.common.server.dns.HostnameResolver) SignedDomain(com.yahoo.athenz.zms.SignedDomain) InstanceProvider(com.yahoo.athenz.instance.provider.InstanceProvider) Test(org.testng.annotations.Test)

Example 34 with SignedDomain

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

the class InstanceProviderManagerTest method testGetProviderClientInvalidDomain.

@Test
public void testGetProviderClientInvalidDomain() {
    SignedDomain signedDomain = createSignedDomainHttpsEndpoint("coretech", "weather", true, true);
    store.processSignedDomain(signedDomain, false);
    InstanceProviderManager provider = new InstanceProviderManager(store, null, null, null, null);
    InstanceProvider client = provider.getProvider("coretech2.weather", null);
    assertNull(client);
}
Also used : SignedDomain(com.yahoo.athenz.zms.SignedDomain) InstanceProvider(com.yahoo.athenz.instance.provider.InstanceProvider) Test(org.testng.annotations.Test)

Example 35 with SignedDomain

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

the class InstanceProviderManagerTest method testGetProviderClientInvalidService.

@Test
public void testGetProviderClientInvalidService() {
    SignedDomain signedDomain = createSignedDomainHttpsEndpoint("coretech", "weather", true, true);
    store.processSignedDomain(signedDomain, false);
    InstanceProviderManager provider = new InstanceProviderManager(store, null, null, null, null);
    InstanceProvider client = provider.getProvider("coretech.weather2", null);
    assertNull(client);
}
Also used : SignedDomain(com.yahoo.athenz.zms.SignedDomain) InstanceProvider(com.yahoo.athenz.instance.provider.InstanceProvider) 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