use of com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsEnvironmentParameters 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.AwsEnvironmentParameters 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());
}
use of com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsEnvironmentParameters in project cloudbreak by hortonworks.
the class EnvironmentValidatorServiceTest method testValidateAwsEnvironmentNoS3GuardParams.
@Test
void testValidateAwsEnvironmentNoS3GuardParams() {
when(credentialService.getCloudPlatformByCredential(anyString(), anyString(), any())).thenReturn("AWS");
EnvironmentRequest request = new EnvironmentRequest();
request.setCredentialName("aws-credential");
request.setAws(new AwsEnvironmentParameters());
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.AwsEnvironmentParameters in project cloudbreak by hortonworks.
the class InstanceTemplateParameterConverterTest method createDetailedEnvironmentResponseForAwsEncryption.
private DetailedEnvironmentResponse createDetailedEnvironmentResponseForAwsEncryption(boolean withAws, boolean withResourceEncryption, String environmentEncryptionKey) {
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
if (withAws) {
AwsEnvironmentParameters parameters = new AwsEnvironmentParameters();
environment.setAws(parameters);
if (withResourceEncryption && ENVIRONMENT_ENCRYPTION_KEY != null) {
AwsDiskEncryptionParameters encryption = new AwsDiskEncryptionParameters();
parameters.setAwsDiskEncryptionParameters(encryption);
encryption.setEncryptionKeyArn(environmentEncryptionKey);
}
}
return environment;
}
use of com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsEnvironmentParameters in project cloudbreak by hortonworks.
the class EnvironmentValidatorService method validateAwsEnvironmentRequest.
public ValidationResult validateAwsEnvironmentRequest(EnvironmentRequest environmentRequest) {
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
String accountId = ThreadBasedUserCrnProvider.getAccountId();
String cloudPlatform = credentialService.getCloudPlatformByCredential(environmentRequest.getCredentialName(), accountId, ENVIRONMENT);
resultBuilder.ifError(() -> !AWS.name().equalsIgnoreCase(cloudPlatform), "Environment request is not for cloud platform AWS.");
resultBuilder.ifError(() -> StringUtils.isBlank(Optional.ofNullable(environmentRequest.getAws()).map(AwsEnvironmentParameters::getS3guard).map(S3GuardRequestParameters::getDynamoDbTableName).orElse(null)), "S3Guard Dynamo DB table name is not found in environment request.");
return resultBuilder.build();
}
Aggregations