use of com.yahoo.athenz.zms.JWSDomain in project athenz by yahoo.
the class ChangeLogStoreTest method testChangeLogStore.
@Test
public void testChangeLogStore() {
ChangeLogStore store = new ChangeLogStore() {
@Override
public SignedDomain getLocalSignedDomain(String domainName) {
return null;
}
@Override
public SignedDomain getServerSignedDomain(String domainName) {
return null;
}
@Override
public void removeLocalDomain(String domainName) {
}
@Override
public void saveLocalDomain(String domainName, SignedDomain signedDomain) {
}
@Override
public List<String> getLocalDomainList() {
return null;
}
@Override
public Set<String> getServerDomainList() {
return null;
}
@Override
public SignedDomains getServerDomainModifiedList() {
return null;
}
@Override
public SignedDomains getUpdatedSignedDomains(StringBuilder lastModTimeBuffer) {
return null;
}
@Override
public void setLastModificationTimestamp(String lastModTime) {
}
@Override
public boolean supportsFullRefresh() {
return false;
}
};
assertNull(store.getLocalJWSDomain("domain"));
assertNull(store.getServerJWSDomain("domain"));
assertNull(store.getUpdatedJWSDomains(null));
store.saveLocalDomain("domain", new JWSDomain());
store.setRequestConditions(true);
store.setRequestConditions(false);
store.setJWSDomainSupport(true);
store.setJWSDomainSupport(false);
}
use of com.yahoo.athenz.zms.JWSDomain in project athenz by yahoo.
the class S3ChangeLogStore method getUpdatedJWSDomains.
@Override
public List<JWSDomain> getUpdatedJWSDomains(StringBuilder lastModTimeBuffer) {
// get the updated domain list and fetch each one individually
AmazonS3 s3 = getS3Client();
List<String> domains = getUpdatedDomainList(s3, lastModTimeBuffer);
List<JWSDomain> jwsDomainList = new ArrayList<>();
for (String domain : domains) {
JWSDomain jwsDomain = getJWSDomain(s3, domain);
if (jwsDomain != null) {
jwsDomainList.add(jwsDomain);
}
}
return jwsDomainList;
}
use of com.yahoo.athenz.zms.JWSDomain in project athenz by yahoo.
the class S3ChangeLogStoreTest method testGetUpdatedJWSDomainsWithChange1.
@Test
public void testGetUpdatedJWSDomainsWithChange1() 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.jws");
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);
List<JWSDomain> jwsDomains = store.getUpdatedJWSDomains(lastModTimeBuffer);
assertTrue(lastModTimeBuffer.length() > 0);
assertEquals(jwsDomains.size(), 1);
is.close();
}
use of com.yahoo.athenz.zms.JWSDomain 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.JWSDomain in project athenz by yahoo.
the class S3ChangeLogStoreTest method testGetUpdatedJWSDomainsNoChanges.
@Test
public void testGetUpdatedJWSDomainsNoChanges() {
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);
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);
List<JWSDomain> jwsDomains = store.getUpdatedJWSDomains(lastModTimeBuffer);
assertTrue(lastModTimeBuffer.length() > 0);
assertEquals(jwsDomains.size(), 0);
}
Aggregations