Search in sources :

Example 41 with CloudStore

use of com.yahoo.athenz.zts.store.CloudStore in project athenz by yahoo.

the class CloudStoreTest method testLoadBootMetaDataInvalidDocumentGet.

@Test
public void testLoadBootMetaDataInvalidDocumentGet() throws InterruptedException, ExecutionException, TimeoutException {
    CloudStore store = new CloudStore(null);
    HttpClient httpClient = Mockito.mock(HttpClient.class);
    ContentResponse response = Mockito.mock(ContentResponse.class);
    Mockito.when(response.getStatus()).thenReturn(404);
    store.setHttpClient(httpClient);
    Mockito.when(httpClient.GET("http://169.254.169.254/latest/dynamic/instance-identity/document")).thenReturn(response);
    assertFalse(store.loadBootMetaData());
    store.close();
}
Also used : CloudStore(com.yahoo.athenz.zts.store.CloudStore) ContentResponse(org.eclipse.jetty.client.api.ContentResponse) HttpClient(org.eclipse.jetty.client.HttpClient) Test(org.testng.annotations.Test)

Example 42 with CloudStore

use of com.yahoo.athenz.zts.store.CloudStore in project athenz by yahoo.

the class CloudStoreTest method testAssumeAWSRoleAWSNotEnabled.

@Test
public void testAssumeAWSRoleAWSNotEnabled() {
    CloudStore cloudStore = new CloudStore(null);
    try {
        cloudStore.assumeAWSRole("account", "sycner", "athenz.syncer");
        fail();
    } catch (ResourceException ex) {
        assertEquals(ex.getCode(), 500);
    }
    cloudStore.close();
}
Also used : CloudStore(com.yahoo.athenz.zts.store.CloudStore) ResourceException(com.yahoo.athenz.zts.ResourceException) Test(org.testng.annotations.Test)

Example 43 with CloudStore

use of com.yahoo.athenz.zts.store.CloudStore in project athenz by yahoo.

the class CloudStoreTest method testFetchRoleCredentialsNoRole.

@Test
public void testFetchRoleCredentialsNoRole() {
    CloudStore store = new CloudStore(null);
    store.awsRole = null;
    assertFalse(store.fetchRoleCredentials());
    store.awsRole = "";
    assertFalse(store.fetchRoleCredentials());
    store.close();
}
Also used : CloudStore(com.yahoo.athenz.zts.store.CloudStore) Test(org.testng.annotations.Test)

Example 44 with CloudStore

use of com.yahoo.athenz.zts.store.CloudStore in project athenz by yahoo.

the class CloudStoreTest method testUpdateAccountUpdate.

@Test
public void testUpdateAccountUpdate() {
    CloudStore store = new CloudStore(null);
    assertNull(store.getCloudAccount("iaas"));
    // set the account to 1234
    store.updateAccount("iaas", "1234");
    assertEquals("1234", store.getCloudAccount("iaas"));
    // update the account value
    store.updateAccount("iaas", "1235");
    assertEquals("1235", store.getCloudAccount("iaas"));
    store.close();
}
Also used : CloudStore(com.yahoo.athenz.zts.store.CloudStore) Test(org.testng.annotations.Test)

Example 45 with CloudStore

use of com.yahoo.athenz.zts.store.CloudStore in project athenz by yahoo.

the class CloudStoreTest method testParseInstanceInfo.

@Test
public void testParseInstanceInfo() {
    CloudStore store = new CloudStore(null);
    assertTrue(store.parseInstanceInfo(AWS_INSTANCE_DOCUMENT));
    assertEquals(store.awsRegion, "us-west-2");
    store.close();
}
Also used : CloudStore(com.yahoo.athenz.zts.store.CloudStore) Test(org.testng.annotations.Test)

Aggregations

CloudStore (com.yahoo.athenz.zts.store.CloudStore)45 Test (org.testng.annotations.Test)44 HttpClient (org.eclipse.jetty.client.HttpClient)17 ContentResponse (org.eclipse.jetty.client.api.ContentResponse)16 MockCloudStore (com.yahoo.athenz.zts.store.MockCloudStore)6 Principal (com.yahoo.athenz.auth.Principal)5 SimplePrincipal (com.yahoo.athenz.auth.impl.SimplePrincipal)5 SignedDomain (com.yahoo.athenz.zms.SignedDomain)5 ResourceException (com.yahoo.athenz.zts.ResourceException)5 BasicSessionCredentials (com.amazonaws.auth.BasicSessionCredentials)2 File (java.io.File)2 AssumeRoleRequest (com.amazonaws.services.securitytoken.model.AssumeRoleRequest)1 CertSigner (com.yahoo.athenz.common.server.cert.CertSigner)1 SelfCertSigner (com.yahoo.athenz.zts.cert.impl.SelfCertSigner)1 ChangeLogStore (com.yahoo.athenz.zts.store.ChangeLogStore)1 DataStore (com.yahoo.athenz.zts.store.DataStore)1 MockZMSFileChangeLogStore (com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore)1 ZMSFileChangeLogStore (com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore)1 PrivateKey (java.security.PrivateKey)1 X509Certificate (java.security.cert.X509Certificate)1