Search in sources :

Example 26 with SignedDomain

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

the class DataStoreTest method testProcessLocalDomain.

@Test
public void testProcessLocalDomain() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null);
    store.loadZMSPublicKeys();
    SignedDomain signedDomain = createSignedDomain("coretech", "weather");
    store.processDomain(signedDomain, true);
    store = new DataStore(clogStore, null);
    boolean result = store.processLocalDomain("coretech");
    assertTrue(result);
    assertNotNull(store.getDomainData("coretech"));
}
Also used : ZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) SignedDomain(com.yahoo.athenz.zms.SignedDomain) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) Test(org.testng.annotations.Test)

Example 27 with SignedDomain

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

the class DataStoreTest method testProcessDomainUpdatesFromZMSNoTagHeader.

@Test
public void testProcessDomainUpdatesFromZMSNoTagHeader() {
    ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
    DataStore store = new DataStore(clogStore, null);
    ((MockZMSFileChangeLogStore) store.changeLogStore).setTagHeader(null);
    SignedDomain signedDomain = createSignedDomain("coretech", "weather");
    List<SignedDomain> domains = new ArrayList<>();
    domains.add(signedDomain);
    SignedDomains signedDomains = new SignedDomains();
    signedDomains.setDomains(domains);
    ((MockZMSFileChangeLogStore) store.changeLogStore).setSignedDomains(signedDomains);
    boolean result = store.processDomainUpdates();
    assertFalse(result);
}
Also used : ZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) SignedDomain(com.yahoo.athenz.zms.SignedDomain) ArrayList(java.util.ArrayList) SignedDomains(com.yahoo.athenz.zms.SignedDomains) MockZMSFileChangeLogStore(com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore) Test(org.testng.annotations.Test)

Example 28 with SignedDomain

use of com.yahoo.athenz.zms.SignedDomain 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);
}
Also used : ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) JWSDomain(com.yahoo.athenz.zms.JWSDomain) SignedDomain(com.yahoo.athenz.zms.SignedDomain) Test(org.testng.annotations.Test)

Example 29 with SignedDomain

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

the class S3ChangeLogStoreTest method testGetSignedDomainInternal.

@Test
public void testGetSignedDomainInternal() throws IOException {
    MockS3ChangeLogStore store = new MockS3ChangeLogStore();
    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);
    SignedDomain signedDomain = store.getSignedDomain(store.awsS3Client, "iaas");
    assertNotNull(signedDomain);
    DomainData domainData = signedDomain.getDomain();
    assertNotNull(domainData);
    assertEquals(domainData.getName(), "iaas");
    is.close();
}
Also used : S3ObjectInputStream(com.amazonaws.services.s3.model.S3ObjectInputStream) SignedDomain(com.yahoo.athenz.zms.SignedDomain) DomainData(com.yahoo.athenz.zms.DomainData) S3Object(com.amazonaws.services.s3.model.S3Object) Test(org.testng.annotations.Test)

Example 30 with SignedDomain

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

the class S3ChangeLogStoreTest method testGetSignedDomainException.

@Test
public void testGetSignedDomainException() throws IOException {
    MockS3ChangeLogStore store = new MockS3ChangeLogStore();
    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);
    // first call we return null, second call we return success
    when(store.awsS3Client.getObject("s3-unit-test-bucket-name", "iaas")).thenThrow(new AmazonServiceException("test")).thenReturn(object);
    SignedDomain signedDomain = store.getLocalSignedDomain("iaas");
    assertNotNull(signedDomain);
    DomainData domainData = signedDomain.getDomain();
    assertNotNull(domainData);
    assertEquals(domainData.getName(), "iaas");
    is.close();
}
Also used : S3ObjectInputStream(com.amazonaws.services.s3.model.S3ObjectInputStream) AmazonServiceException(com.amazonaws.AmazonServiceException) SignedDomain(com.yahoo.athenz.zms.SignedDomain) DomainData(com.yahoo.athenz.zms.DomainData) S3Object(com.amazonaws.services.s3.model.S3Object) 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