use of com.yahoo.athenz.zms.SignedDomains in project athenz by yahoo.
the class S3ChangeLogStoreTest method testGetUpdatedSignedDomainsNoChanges.
@Test
public void testGetUpdatedSignedDomainsNoChanges() {
MockS3ChangeLogStore store = new MockS3ChangeLogStore(null);
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);
ObjectListing objectListing = mock(ObjectListing.class);
when(objectListing.getObjectSummaries()).thenReturn(objectList);
when(objectListing.isTruncated()).thenReturn(false);
when(store.awsS3Client.listObjects(any(ListObjectsRequest.class))).thenReturn(objectListing);
// set the last modification time to not return any of the domains
store.lastModTime = (new Date(250)).getTime();
StringBuilder lastModTimeBuffer = new StringBuilder(512);
SignedDomains signedDomains = store.getUpdatedSignedDomains(lastModTimeBuffer);
assertTrue(lastModTimeBuffer.length() > 0);
assertEquals(signedDomains.getDomains().size(), 0);
}
use of com.yahoo.athenz.zms.SignedDomains in project athenz by yahoo.
the class ZMSFileChangeLogStoreTest method getSignedDomainList.
@Test
public void getSignedDomainList() {
ZMSFileChangeLogStore fstore = new ZMSFileChangeLogStore(FSTORE_PATH, null, null);
ZMSClient zmsClient = Mockito.mock(ZMSClient.class);
List<SignedDomain> domains = new ArrayList<>();
DomainData domData = new DomainData().setName("athenz");
SignedDomain domain = new SignedDomain().setDomain(domData);
domains.add(domain);
SignedDomains domainList = new SignedDomains().setDomains(domains);
Mockito.when(zmsClient.getSignedDomains("athenz", null, null, null)).thenReturn(domainList);
List<SignedDomain> returnList = fstore.getSignedDomainList(zmsClient, domainList);
assertEquals(returnList.size(), 1);
assertEquals(returnList.get(0).getDomain().getName(), "athenz");
}
use of com.yahoo.athenz.zms.SignedDomains in project athenz by yahoo.
the class S3ChangeLogStore method getUpdatedSignedDomains.
@Override
public SignedDomains getUpdatedSignedDomains(StringBuilder lastModTimeBuffer) {
// get the updated domain list and fetch each one individually
AmazonS3 s3 = getS3Client();
List<String> domains = getUpdatedDomainList(s3, lastModTimeBuffer);
List<SignedDomain> signedDomainList = new ArrayList<>();
for (String domain : domains) {
SignedDomain signedDomain = getSignedDomain(s3, domain);
if (signedDomain != null) {
signedDomainList.add(signedDomain);
}
}
SignedDomains signedDomains = new SignedDomains();
signedDomains.setDomains(signedDomainList);
return signedDomains;
}
Aggregations