use of com.sequenceiq.environment.api.v1.environment.model.request.aws.S3GuardRequestParameters in project cloudbreak by hortonworks.
the class EnvironmentApiConverterTest method createAwsRequest.
private AwsEnvironmentParameters createAwsRequest() {
S3GuardRequestParameters s3GuardRequestParameters = new S3GuardRequestParameters();
s3GuardRequestParameters.setDynamoDbTableName("my-table");
AwsEnvironmentParameters awsEnvironmentParameters = new AwsEnvironmentParameters();
awsEnvironmentParameters.setS3guard(s3GuardRequestParameters);
awsEnvironmentParameters.setAwsDiskEncryptionParameters(AwsDiskEncryptionParameters.builder().withEncryptionKeyArn("dummy-key-arn").build());
return awsEnvironmentParameters;
}
use of com.sequenceiq.environment.api.v1.environment.model.request.aws.S3GuardRequestParameters in project cloudbreak by hortonworks.
the class AwsCloudProvider method setS3Guard.
@Override
public EnvironmentTestDto setS3Guard(EnvironmentTestDto environmentTestDto, String tableName) {
AwsEnvironmentParameters awsEnvironmentParameters = new AwsEnvironmentParameters();
S3GuardRequestParameters s3GuardRequestParameters = new S3GuardRequestParameters();
s3GuardRequestParameters.setDynamoDbTableName(tableName);
awsEnvironmentParameters.setS3guard(s3GuardRequestParameters);
return environmentTestDto.withAws(awsEnvironmentParameters);
}
use of com.sequenceiq.environment.api.v1.environment.model.request.aws.S3GuardRequestParameters in project cloudbreak by hortonworks.
the class CloudStorageManifesterTest method whenEnvironmentHasLoggingEnabledThenShouldApplyAsLogIdentity.
@Test
public void whenEnvironmentHasLoggingEnabledThenShouldApplyAsLogIdentity() {
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
mockFileSystemResponseForCloudbreakClient();
SdxCluster sdxCluster = new SdxCluster();
SdxClusterRequest sdxClusterRequest = new SdxClusterRequest();
sdxCluster.setInitiatorUserCrn(USER_CRN);
sdxCluster.setClusterName("sdx-cluster");
SdxCloudStorageRequest cloudStorageRequest = new SdxCloudStorageRequest();
cloudStorageRequest.setBaseLocation("s3a://example-path");
cloudStorageRequest.setFileSystemType(FileSystemType.S3);
S3CloudStorageV1Parameters s3Params = new S3CloudStorageV1Parameters();
s3Params.setInstanceProfile("instance:profile");
cloudStorageRequest.setS3(s3Params);
sdxClusterRequest.setCloudStorage(cloudStorageRequest);
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
environment.setCloudPlatform("AWS");
TelemetryResponse telemetryResponse = new TelemetryResponse();
LoggingResponse loggingResponse = new LoggingResponse();
S3CloudStorageV1Parameters s3CloudStorageV1Parameters = new S3CloudStorageV1Parameters();
s3CloudStorageV1Parameters.setInstanceProfile("logprofile");
loggingResponse.setS3(s3CloudStorageV1Parameters);
telemetryResponse.setLogging(loggingResponse);
AwsEnvironmentParameters awsEnvironmentParameters = new AwsEnvironmentParameters();
S3GuardRequestParameters s3GuardRequestParameters = new S3GuardRequestParameters();
s3GuardRequestParameters.setDynamoDbTableName("table");
awsEnvironmentParameters.setS3guard(s3GuardRequestParameters);
environment.setAws(awsEnvironmentParameters);
environment.setTelemetry(telemetryResponse);
ClusterV4Request clusterV4Request = new ClusterV4Request();
clusterV4Request.setBlueprintName(exampleBlueprintName);
CloudStorageRequest cloudStorageConfigReq = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.initCloudStorageRequest(environment, clusterV4Request, sdxCluster, sdxClusterRequest));
StorageLocationBase singleRequest = cloudStorageConfigReq.getLocations().iterator().next();
assertEquals(2, cloudStorageConfigReq.getIdentities().size());
assertEquals(1, cloudStorageConfigReq.getIdentities().stream().filter(r -> r.getType().equals(CloudIdentityType.ID_BROKER)).collect(Collectors.toSet()).size());
assertEquals(1, cloudStorageConfigReq.getIdentities().stream().filter(r -> r.getType().equals(CloudIdentityType.LOG)).collect(Collectors.toSet()).size());
assertEquals("table", cloudStorageConfigReq.getAws().getS3Guard().getDynamoTableName());
assertEquals(1, cloudStorageConfigReq.getLocations().size());
assertEquals(CloudStorageCdpService.RANGER_AUDIT, singleRequest.getType());
assertEquals("ranger/example-path", singleRequest.getValue());
verify(storageValidationService).validateCloudStorage("AWS", cloudStorageRequest);
}
use of com.sequenceiq.environment.api.v1.environment.model.request.aws.S3GuardRequestParameters in project cloudbreak by hortonworks.
the class EnvironmentValidatorServiceTest method testValidateAwsEnvironmentRequestNoDynamoTable.
@Test
void testValidateAwsEnvironmentRequestNoDynamoTable() {
when(credentialService.getCloudPlatformByCredential(anyString(), anyString(), any())).thenReturn("AWS");
EnvironmentRequest request = new EnvironmentRequest();
request.setCredentialName("aws-credential");
AwsEnvironmentParameters aws = new AwsEnvironmentParameters();
aws.setS3guard(new S3GuardRequestParameters());
request.setAws(aws);
ValidationResult result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.validateAwsEnvironmentRequest(request));
assertTrue(result.hasError());
assertEquals("S3Guard Dynamo DB table name is not found in environment request.", result.getErrors().get(0));
}
use of com.sequenceiq.environment.api.v1.environment.model.request.aws.S3GuardRequestParameters in project cloudbreak by hortonworks.
the class EnvironmentValidatorServiceTest method testValidateAwsEnvironmentRequestValid.
@Test
void testValidateAwsEnvironmentRequestValid() {
when(credentialService.getCloudPlatformByCredential(anyString(), anyString(), any())).thenReturn("AWS");
EnvironmentRequest request = new EnvironmentRequest();
request.setCredentialName("aws-credential");
AwsEnvironmentParameters aws = new AwsEnvironmentParameters();
S3GuardRequestParameters s3GuardRequestParameters = new S3GuardRequestParameters();
s3GuardRequestParameters.setDynamoDbTableName("table");
aws.setS3guard(s3GuardRequestParameters);
request.setAws(aws);
ValidationResult result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.validateAwsEnvironmentRequest(request));
assertFalse(result.hasError());
}
Aggregations