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