Search in sources :

Example 21 with ValidationResultBuilder

use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.

the class CloudStorageLocationValidatorTest method validateS3.

@Test
public void validateS3() {
    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");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
    underTest.validate(S3_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 22 with ValidationResultBuilder

use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.

the class CloudStorageLocationValidatorTest method validateWasb.

@Test
public void validateWasb() {
    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");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
    underTest.validate(WASB_OBJECT_PATH, FileSystemType.WASB, 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 23 with ValidationResultBuilder

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();
    ObjectStorageMetadataResponse response = ObjectStorageMetadataResponse.builder().withRegion(ENV_REGION).withStatus(ResponseStatus.OK).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 24 with ValidationResultBuilder

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");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
    underTest.validate(OBJECT_PATH, FileSystemType.S3, 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));
}
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) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test)

Example 25 with ValidationResultBuilder

use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.

the class CloudStorageValidatorTest method validateEnvironmentRequestCloudStorageValidation.

@Test
public void validateEnvironmentRequestCloudStorageValidation() {
    when(environment.getCloudStorageValidation()).thenReturn(CloudStorageValidation.ENABLED);
    when(environment.getCredential()).thenReturn(new CredentialResponse());
    when(secretService.getByResponse(any())).thenReturn("secret");
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    when(credentialToCloudCredentialConverter.convert(any())).thenReturn(new CloudCredential("id", "name", Map.of("secretKey", "thisshouldnotappearinlog"), "acc", false));
    when(entitlementService.cloudStorageValidationEnabled(any())).thenReturn(true);
    when(cloudProviderServicesV4Endopint.validateObjectStorage(any())).thenReturn(new ObjectStorageValidateResponse());
    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) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) ObjectStorageValidateResponse(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageValidateResponse) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) 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