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));
}
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();
}
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();
}
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();
}
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();
}
Aggregations