Search in sources :

Example 6 with CloudAccessConfigs

use of com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfigs in project cloudbreak by hortonworks.

the class AwsPlatformResourcesTest method collectAccessConfigsWhenUserGetServiceExceptionToGetInfoThenItShouldReturnEmptyList.

@Test
public void collectAccessConfigsWhenUserGetServiceExceptionToGetInfoThenItShouldReturnEmptyList() throws Exception {
    BadRequestException badRequestException = new BadRequestException("BadRequestException problem.");
    when(awsClient.createAmazonIdentityManagement(any(AwsCredentialView.class))).thenReturn(amazonCFClient);
    when(amazonCFClient.listInstanceProfiles()).thenThrow(badRequestException);
    thrown.expect(CloudConnectorException.class);
    thrown.expectMessage("Could not get instance profile roles from Amazon: BadRequestException problem.");
    CloudAccessConfigs cloudAccessConfigs = underTest.accessConfigs(new CloudCredential(1L, "aws-credential"), region("London"), new HashMap<>());
    Assert.assertEquals(0, cloudAccessConfigs.getCloudAccessConfigs().size());
}
Also used : AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.view.AwsCredentialView) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) BadRequestException(javax.ws.rs.BadRequestException) CloudAccessConfigs(com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfigs) Test(org.junit.Test)

Example 7 with CloudAccessConfigs

use of com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfigs in project cloudbreak by hortonworks.

the class AwsPlatformResourcesTest method collectAccessConfigsWhenUserGetAmazonExceptionToGetInfoThenItShouldReturnEmptyList.

@Test
public void collectAccessConfigsWhenUserGetAmazonExceptionToGetInfoThenItShouldReturnEmptyList() throws Exception {
    AmazonServiceException amazonServiceException = new AmazonServiceException("Amazon problem.");
    amazonServiceException.setStatusCode(404);
    amazonServiceException.setErrorMessage("Amazon problem.");
    when(awsClient.createAmazonIdentityManagement(any(AwsCredentialView.class))).thenReturn(amazonCFClient);
    when(amazonCFClient.listInstanceProfiles()).thenThrow(amazonServiceException);
    thrown.expect(CloudConnectorException.class);
    thrown.expectMessage("Could not get instance profile roles from Amazon: Amazon problem.");
    CloudAccessConfigs cloudAccessConfigs = underTest.accessConfigs(new CloudCredential(1L, "aws-credential"), region("London"), new HashMap<>());
    Assert.assertEquals(0, cloudAccessConfigs.getCloudAccessConfigs().size());
}
Also used : AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.view.AwsCredentialView) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) AmazonServiceException(com.amazonaws.AmazonServiceException) CloudAccessConfigs(com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfigs) Test(org.junit.Test)

Aggregations

CloudAccessConfigs (com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfigs)7 AwsCredentialView (com.sequenceiq.cloudbreak.cloud.aws.view.AwsCredentialView)5 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)4 Test (org.junit.Test)4 AmazonServiceException (com.amazonaws.AmazonServiceException)3 InstanceProfile (com.amazonaws.services.identitymanagement.model.InstanceProfile)2 ListInstanceProfilesResult (com.amazonaws.services.identitymanagement.model.ListInstanceProfilesResult)2 AmazonIdentityManagement (com.amazonaws.services.identitymanagement.AmazonIdentityManagement)1 GetPlatformCloudAccessConfigsRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudAccessConfigsRequest)1 GetPlatformCloudAccessConfigsResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudAccessConfigsResult)1 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)1 CloudAccessConfig (com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfig)1 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 PlatformResourceRequest (com.sequenceiq.cloudbreak.domain.PlatformResourceRequest)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 BadRequestException (javax.ws.rs.BadRequestException)1