use of com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest in project cloudbreak by hortonworks.
the class CloudStorageLocationValidatorTest method validateAbfs.
@Test
public void validateAbfs() {
when(environmentLogging.getAdlsGen2()).thenReturn(adlsGen2);
when(adlsGen2.getType()).thenReturn(FileSystemType.ADLS_GEN_2);
ObjectStorageMetadataRequest request = ObjectStorageMetadataRequest.builder().withCloudPlatform(CLOUD_PLATFORM).withCredential(CLOUD_CREDENTIAL).withObjectStoragePath(BUCKET_NAME).build();
ObjectStorageMetadataResponse response = ObjectStorageMetadataResponse.builder().withRegion(ENV_REGION).withStatus(ResponseStatus.OK).build();
when(cloudProviderServicesEndpoint.getObjectStorageMetaData(eq(request))).thenReturn(response);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
underTest.validate(ABFS_OBJECT_PATH, environment, validationResultBuilder);
assertFalse(validationResultBuilder.build().hasError());
}
use of com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest in project cloudbreak by hortonworks.
the class CloudStorageLocationValidatorTest method validateNoProtocol.
@Test
public void validateNoProtocol() {
ObjectStorageMetadataRequest request = ObjectStorageMetadataRequest.builder().withCloudPlatform(CLOUD_PLATFORM).withCredential(CLOUD_CREDENTIAL).withObjectStoragePath(BUCKET_NAME).build();
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
ObjectStorageMetadataResponse response = ObjectStorageMetadataResponse.builder().withRegion(ENV_REGION).withStatus(ResponseStatus.OK).build();
when(cloudProviderServicesEndpoint.getObjectStorageMetaData(eq(request))).thenReturn(response);
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
underTest.validate(OBJECT_PATH, environment, validationResultBuilder);
assertFalse(validationResultBuilder.build().hasError());
}
use of com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest in project cloudbreak by hortonworks.
the class CloudStorageLocationValidatorTest method validateS3.
@Test
public void validateS3() {
when(environmentLogging.getS3()).thenReturn(s3);
when(s3.getType()).thenReturn(FileSystemType.S3);
ObjectStorageMetadataRequest request = ObjectStorageMetadataRequest.builder().withCloudPlatform(CLOUD_PLATFORM).withCredential(CLOUD_CREDENTIAL).withObjectStoragePath(BUCKET_NAME).build();
ObjectStorageMetadataResponse response = ObjectStorageMetadataResponse.builder().withRegion(ENV_REGION).withStatus(ResponseStatus.OK).build();
when(cloudProviderServicesEndpoint.getObjectStorageMetaData(eq(request))).thenReturn(response);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
underTest.validate(S3_OBJECT_PATH, environment, validationResultBuilder);
assertFalse(validationResultBuilder.build().hasError());
}
use of com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest in project cloudbreak by hortonworks.
the class CloudStorageLocationValidator method validate.
public void validate(String storageLocation, FileSystemType fileSystemType, DetailedEnvironmentResponse environment, ValidationResultBuilder resultBuilder) {
String bucketName = getBucketName(fileSystemType, storageLocation);
Credential credential = getCredential(environment);
CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(credential);
ObjectStorageMetadataRequest request = createObjectStorageMetadataRequest(environment.getCloudPlatform(), cloudCredential, bucketName);
ObjectStorageMetadataResponse response = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> cloudProviderServicesV4Endopint.getObjectStorageMetaData(request));
resultBuilder.ifError(() -> response.getStatus() == ResponseStatus.OK && !environment.getLocation().getName().equals(response.getRegion()), String.format("Object storage location [%s] of bucket '%s' must match environment location [%s]", response.getRegion(), bucketName, environment.getLocation().getName()));
}
use of com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest in project cloudbreak by hortonworks.
the class AwsObjectStorageConnectorTest method getObjectStorageMetadataAccessDenied.
@Test
public void getObjectStorageMetadataAccessDenied() {
AmazonS3Exception exception = new AmazonS3Exception(ERROR_MESSAGE);
exception.setStatusCode(403);
when(s3Client.getBucketLocation(BUCKET_NAME)).thenThrow(exception);
ObjectStorageMetadataRequest request = ObjectStorageMetadataRequest.builder().withObjectStoragePath(BUCKET_NAME).build();
ObjectStorageMetadataResponse result = underTest.getObjectStorageMetadata(request);
verify(s3Client).getBucketLocation(BUCKET_NAME);
assertNull(result.getRegion());
assertEquals(ResponseStatus.ACCESS_DENIED, result.getStatus());
}
Aggregations