use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class CloudStorageValidatorTest method validateEnvironmentRequestCloudStorageValidationDisabled.
@Test
public void validateEnvironmentRequestCloudStorageValidationDisabled() {
when(environment.getCloudStorageValidation()).thenReturn(CloudStorageValidation.DISABLED);
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.validate(new CloudStorageRequest(), environment, validationResultBuilder));
assertFalse(validationResultBuilder.build().hasError());
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class CloudStorageLocationValidatorTest method validateAccessDenied.
@Test
public void validateAccessDenied() {
ObjectStorageMetadataRequest request = ObjectStorageMetadataRequest.builder().withCloudPlatform(CLOUD_PLATFORM).withCredential(CLOUD_CREDENTIAL).withObjectStoragePath(BUCKET_NAME).build();
ObjectStorageMetadataResponse response = ObjectStorageMetadataResponse.builder().withStatus(ResponseStatus.ACCESS_DENIED).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(OBJECT_PATH, environment, validationResultBuilder);
assertFalse(validationResultBuilder.build().hasError());
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class CloudStorageLocationValidatorTest method validateError.
@Test
public void validateError() {
ObjectStorageMetadataRequest request = ObjectStorageMetadataRequest.builder().withCloudPlatform(CLOUD_PLATFORM).withCredential(CLOUD_CREDENTIAL).withObjectStoragePath(BUCKET_NAME).build();
ObjectStorageMetadataResponse response = ObjectStorageMetadataResponse.builder().withRegion(OTHER_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(OBJECT_PATH, environment, validationResultBuilder);
ValidationResult result = validationResultBuilder.build();
assertTrue(result.hasError());
assertEquals(String.format("Object storage location [%s] of bucket '%s' must match environment location [%s].", OTHER_REGION, BUCKET_NAME, ENV_REGION), result.getErrors().get(0));
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder 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.validation.ValidationResult.ValidationResultBuilder 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());
}
Aggregations