use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class AzureIDBrokerObjectStorageValidatorTest method testValidateObjectStorageWithNoRoleAssignments.
@Test
public void testValidateObjectStorageWithNoRoleAssignments() {
SpiFileSystem fileSystem = setupSpiFileSystem(false);
new RoleASsignmentBuilder(client);
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
underTest.validateObjectStorage(client, fileSystem, "", null, null, resultBuilder);
ValidationResult validationResult = resultBuilder.build();
assertTrue(validationResult.hasError());
assertEquals(2, validationResult.getErrors().size());
assertEquals(validationResult.getErrors().get(1), "There are no role assignments for the given Azure subscription. " + "Please check if you've used the correct Identity when setting up Data Access.");
assertEquals(validationResult.getErrors().get(0), String.format("Identity with id %s has no role assignment. " + "Please check if you've used the correct Identity when setting up Data Access.", ASSUMER_IDENTITY));
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class AzureIDBrokerObjectStorageValidatorTest method testValidateObjectStorageNonExistingAssumerIdentity.
@Test
public void testValidateObjectStorageNonExistingAssumerIdentity() {
SpiFileSystem fileSystem = setupSpiFileSystem(false);
new RoleASsignmentBuilder(client).withAssignment(LOG_IDENTITY_PRINCIPAL_ID, STORAGE_RESOURCE_GROUP_NAME);
when(client.getIdentityById(ASSUMER_IDENTITY)).thenReturn(null);
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
underTest.validateObjectStorage(client, fileSystem, "", null, null, resultBuilder);
ValidationResult validationResult = resultBuilder.build();
assertTrue(validationResult.hasError());
assertEquals(1, validationResult.getErrors().size());
String actual = validationResult.getErrors().get(0);
assertEquals(actual, String.format("Assumer Identity with id %s does not exist in the given Azure subscription. " + "Please check if you've used the correct Identity when setting up Data Access.", ASSUMER_IDENTITY));
}
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");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
underTest.validate(OBJECT_PATH, FileSystemType.S3, environment, validationResultBuilder);
assertFalse(validationResultBuilder.build().hasError());
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class CloudStorageValidatorTest method validateEnvironmentRequestCloudStorageValidationNoEntitlement.
@Test
public void validateEnvironmentRequestCloudStorageValidationNoEntitlement() {
when(environment.getCloudStorageValidation()).thenReturn(CloudStorageValidation.ENABLED);
when(entitlementService.cloudStorageValidationEnabled(any())).thenReturn(false);
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 CloudStorageValidatorTest method validateEnvironmentRequestCloudStorageValidationMissingEntitlement.
@Test
public void validateEnvironmentRequestCloudStorageValidationMissingEntitlement() {
when(environment.getCloudStorageValidation()).thenReturn(CloudStorageValidation.ENABLED);
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.validate(new CloudStorageRequest(), environment, validationResultBuilder)));
assertFalse(validationResultBuilder.build().hasError());
}
Aggregations