Search in sources :

Example 11 with SignedDomains

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);
}
Also used : ListObjectsRequest(com.amazonaws.services.s3.model.ListObjectsRequest) ArrayList(java.util.ArrayList) ObjectListing(com.amazonaws.services.s3.model.ObjectListing) S3ObjectSummary(com.amazonaws.services.s3.model.S3ObjectSummary) SignedDomains(com.yahoo.athenz.zms.SignedDomains) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 12 with SignedDomains

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");
}
Also used : ZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore) SignedDomain(com.yahoo.athenz.zms.SignedDomain) ArrayList(java.util.ArrayList) DomainData(com.yahoo.athenz.zms.DomainData) SignedDomains(com.yahoo.athenz.zms.SignedDomains) ZMSClient(com.yahoo.athenz.zms.ZMSClient) Test(org.testng.annotations.Test)

Example 13 with SignedDomains

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;
}
Also used : AmazonS3(com.amazonaws.services.s3.AmazonS3) SignedDomain(com.yahoo.athenz.zms.SignedDomain) SignedDomains(com.yahoo.athenz.zms.SignedDomains)

Aggregations

SignedDomains (com.yahoo.athenz.zms.SignedDomains)13 SignedDomain (com.yahoo.athenz.zms.SignedDomain)10 ArrayList (java.util.ArrayList)9 Test (org.testng.annotations.Test)8 ListObjectsRequest (com.amazonaws.services.s3.model.ListObjectsRequest)4 ObjectListing (com.amazonaws.services.s3.model.ObjectListing)4 S3ObjectSummary (com.amazonaws.services.s3.model.S3ObjectSummary)4 DomainData (com.yahoo.athenz.zms.DomainData)4 ZMSFileChangeLogStore (com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore)4 ZMSClient (com.yahoo.athenz.zms.ZMSClient)3 AmazonS3 (com.amazonaws.services.s3.AmazonS3)2 S3Object (com.amazonaws.services.s3.model.S3Object)2 S3ObjectInputStream (com.amazonaws.services.s3.model.S3ObjectInputStream)2 ZMSClientException (com.yahoo.athenz.zms.ZMSClientException)2 MockZMSFileChangeLogStore (com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore)2 Date (java.util.Date)2 Role (com.yahoo.athenz.zms.Role)1 RoleMember (com.yahoo.athenz.zms.RoleMember)1 DataCache (com.yahoo.athenz.zts.cache.DataCache)1 MemberRole (com.yahoo.athenz.zts.cache.MemberRole)1