Search in sources :

Example 21 with CloudStore

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

the class CloudStoreTest method testGetSshKeyReqType.

@Test
public void testGetSshKeyReqType() {
    CloudStore cloudStore = new CloudStore(null);
    final String req = "{\"principals\":[\"localhost\"],\"pubkey\":\"ssh-rsa AAAs\"" + ",\"reqip\":\"10.10.10.10\",\"requser\":\"user\",\"certtype\":\"host\",\"transid\":\"0\"}";
    assertEquals(cloudStore.getSshKeyReqType(req), "host");
    final String req2 = "{\"principals\":[\"localhost\"],\"pubkey\":\"ssh-rsa AAAs\"" + ",\"reqip\":\"10.10.10.10\",\"requser\":\"user\",\"certtype2\":\"host\",\"transid\":\"0\"}";
    assertNull(cloudStore.getSshKeyReqType(req2));
    final String req3 = "{invalid-json";
    assertNull(cloudStore.getSshKeyReqType(req3));
}
Also used : CloudStore(com.yahoo.athenz.zts.store.CloudStore) Test(org.testng.annotations.Test)

Example 22 with CloudStore

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

the class CloudStoreTest method testParseIamRoleInfo.

@Test
public void testParseIamRoleInfo() {
    CloudStore store = new CloudStore(null);
    assertTrue(store.parseIamRoleInfo(AWS_IAM_ROLE_INFO));
    assertEquals(store.awsRole, "athenz.zts");
    store.close();
}
Also used : CloudStore(com.yahoo.athenz.zts.store.CloudStore) Test(org.testng.annotations.Test)

Example 23 with CloudStore

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

the class CloudStoreTest method testParseInstanceProfileArnInvalidPrefix.

@Test
public void testParseInstanceProfileArnInvalidPrefix() {
    CloudStore store = new CloudStore(null);
    // invalid starting prefix
    assertFalse(store.parseInstanceProfileArn("arn:aws:iam:111111111111:instance-profile/athenz.zts,athenz"));
    assertFalse(store.parseInstanceProfileArn("arn:aws:iam2:111111111111:instance-profile/athenz.zts,athenz"));
    assertFalse(store.parseInstanceProfileArn("instance-profile/athenz.zts,athenz"));
    store.close();
}
Also used : CloudStore(com.yahoo.athenz.zts.store.CloudStore) Test(org.testng.annotations.Test)

Example 24 with CloudStore

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

the class CloudStoreTest method testGetMetaDataFailureStatus.

@Test
public void testGetMetaDataFailureStatus() 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/iam-info")).thenReturn(response);
    assertNull(store.getMetaData("/iam-info"));
    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 25 with CloudStore

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

the class CloudStoreTest method testGetAssumeRoleRequest.

@Test
public void testGetAssumeRoleRequest() {
    CloudStore store = new CloudStore(null);
    AssumeRoleRequest req = store.getAssumeRoleRequest("1234", "admin", "sys.auth.zts");
    assertEquals("arn:aws:iam::1234:role/admin", req.getRoleArn());
    assertEquals("sys.auth.zts", req.getRoleSessionName());
    store.close();
}
Also used : AssumeRoleRequest(com.amazonaws.services.securitytoken.model.AssumeRoleRequest) 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