use of com.yahoo.athenz.zts.store.CloudStore in project athenz by yahoo.
the class CloudStoreTest method testUpdateAccountDelete.
@Test
public void testUpdateAccountDelete() {
CloudStore store = new CloudStore(null);
// set the account to 1234
store.updateAccount("iaas", "1234");
assertEquals("1234", store.getCloudAccount("iaas"));
// delete the account with null
store.updateAccount("iaas", null);
assertNull(store.getCloudAccount("iaas"));
// update the account value
store.updateAccount("iaas", "1235");
assertEquals("1235", store.getCloudAccount("iaas"));
// delete the account with empty string
store.updateAccount("iaas", "");
assertNull(store.getCloudAccount("iaas"));
store.close();
}
use of com.yahoo.athenz.zts.store.CloudStore in project athenz by yahoo.
the class CloudStoreTest method testGetMetaDataNullResponse.
@Test
public void testGetMetaDataNullResponse() 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(200);
Mockito.when(response.getContentAsString()).thenReturn(null);
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 testFetchRoleCredentialsNoCreds.
@Test
public void testFetchRoleCredentialsNoCreds() throws InterruptedException, ExecutionException, TimeoutException {
CloudStore store = new CloudStore(null);
store.awsRole = "athenz.zts";
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/meta-data/iam/security-credentials/athenz.zts")).thenReturn(response);
assertFalse(store.fetchRoleCredentials());
store.close();
}
use of com.yahoo.athenz.zts.store.CloudStore in project athenz by yahoo.
the class CloudStoreTest method testLoadBootMetaDataInvalidDocumentParse.
@Test
public void testLoadBootMetaDataInvalidDocumentParse() 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(200);
Mockito.when(response.getContentAsString()).thenReturn("{\"accountId\":\"012345678901\"}");
store.setHttpClient(httpClient);
Mockito.when(httpClient.GET("http://169.254.169.254/latest/dynamic/instance-identity/document")).thenReturn(response);
assertFalse(store.loadBootMetaData());
store.close();
}
use of com.yahoo.athenz.zts.store.CloudStore in project athenz by yahoo.
the class CloudStoreTest method testLoadBootMetaDataInvalidIamInfoGet.
@Test
public void testLoadBootMetaDataInvalidIamInfoGet() 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(404);
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();
}
Aggregations