use of com.yahoo.athenz.zts.store.CloudStore in project athenz by yahoo.
the class CloudStoreTest method testLoadBootMetaDataInvalidIamInfoParse.
@Test
public void testLoadBootMetaDataInvalidIamInfoParse() throws InterruptedException, ExecutionException, TimeoutException {
CloudStore store = new CloudStore(null);
HttpClient httpClient = Mockito.mock(HttpClient.class);
ContentResponse responseDoc = Mockito.mock(ContentResponse.class);
Mockito.when(responseDoc.getStatus()).thenReturn(200);
Mockito.when(responseDoc.getContentAsString()).thenReturn(AWS_INSTANCE_DOCUMENT);
ContentResponse responseSig = Mockito.mock(ContentResponse.class);
Mockito.when(responseSig.getStatus()).thenReturn(200);
Mockito.when(responseSig.getContentAsString()).thenReturn("pkcs7-signature");
ContentResponse responseInfo = Mockito.mock(ContentResponse.class);
Mockito.when(responseInfo.getStatus()).thenReturn(200);
Mockito.when(responseInfo.getContentAsString()).thenReturn("{\"accountId\":\"012345678901\",\"InstanceProfileArn\":\"invalid\"}");
store.setHttpClient(httpClient);
Mockito.when(httpClient.GET("http://169.254.169.254/latest/dynamic/instance-identity/document")).thenReturn(responseDoc);
Mockito.when(httpClient.GET("http://169.254.169.254/latest/dynamic/instance-identity/pkcs7")).thenReturn(responseSig);
Mockito.when(httpClient.GET("http://169.254.169.254/latest/meta-data/iam/info")).thenReturn(responseInfo);
assertFalse(store.loadBootMetaData());
store.close();
}
use of com.yahoo.athenz.zts.store.CloudStore in project athenz by yahoo.
the class CloudStoreTest method testParseInstanceProfileArnInvalidProfile.
@Test
public void testParseInstanceProfileArnInvalidProfile() {
CloudStore store = new CloudStore(null);
// missing instance-profile part
assertFalse(store.parseInstanceProfileArn("arn:aws:iam::111111111111:instance-profile2/athenz.zts,athenz"));
assertFalse(store.parseInstanceProfileArn("arn:aws:iam::111111111111:instance/athenz.zts,athenz"));
store.close();
}
use of com.yahoo.athenz.zts.store.CloudStore in project athenz by yahoo.
the class CloudStoreTest method testParseIamRoleInfoInvalid.
@Test
public void testParseIamRoleInfoInvalid() {
CloudStore store = new CloudStore(null);
assertFalse(store.parseIamRoleInfo("some_invalid_doc"));
store.close();
}
use of com.yahoo.athenz.zts.store.CloudStore in project athenz by yahoo.
the class CloudStoreTest method testGetS3ClientNullCreds.
@Test
public void testGetS3ClientNullCreds() {
CloudStore store = new CloudStore(null);
store.awsEnabled = true;
store.credentials = null;
try {
store.getS3Client();
fail();
} catch (ResourceException ex) {
assertEquals(500, ex.getCode());
}
store.close();
}
use of com.yahoo.athenz.zts.store.CloudStore in project athenz by yahoo.
the class CloudStoreTest method testGetS3Client.
@Test
public void testGetS3Client() {
System.setProperty(ZTSConsts.ZTS_PROP_AWS_PUBLIC_CERT, "src/test/resources/aws_public.crt");
CloudStore store = new CloudStore(null);
store.credentials = new BasicSessionCredentials("accessKey", "secretKey", "token");
store.awsEnabled = true;
assertNotNull(store.getS3Client());
store.awsRegion = "us-west-2";
assertNotNull(store.getS3Client());
store.close();
}
Aggregations