Search in sources :

Example 81 with ValidationResultBuilder

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));
}
Also used : ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) SpiFileSystem(com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.Test)

Example 82 with ValidationResultBuilder

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));
}
Also used : ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) SpiFileSystem(com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.Test)

Example 83 with ValidationResultBuilder

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());
}
Also used : ObjectStorageMetadataResponse(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataResponse) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) ObjectStorageMetadataRequest(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest) Test(org.junit.jupiter.api.Test)

Example 84 with ValidationResultBuilder

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());
}
Also used : CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) Test(org.junit.jupiter.api.Test)

Example 85 with ValidationResultBuilder

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());
}
Also used : CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)169 Test (org.junit.jupiter.api.Test)107 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)67 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)62 EnvironmentValidationDto (com.sequenceiq.environment.environment.dto.EnvironmentValidationDto)35 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)33 AzureParams (com.sequenceiq.environment.network.dto.AzureParams)33 Test (org.junit.Test)20 SpiFileSystem (com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem)16 Environment (com.sequenceiq.environment.environment.domain.Environment)11 ObjectStorageMetadataRequest (com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest)10 ObjectStorageMetadataResponse (com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataResponse)10 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)10 Credential (com.sequenceiq.environment.credential.domain.Credential)10 Region (com.sequenceiq.environment.environment.domain.Region)9 PlatformResourceRequest (com.sequenceiq.environment.platformresource.PlatformResourceRequest)9 EnvironmentCreationDto (com.sequenceiq.environment.environment.dto.EnvironmentCreationDto)7 InstanceProfile (com.amazonaws.services.identitymanagement.model.InstanceProfile)6 Role (com.amazonaws.services.identitymanagement.model.Role)6 GatewayTopologyV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request)6