Search in sources :

Example 1 with RoleBasedParameters

use of com.sequenceiq.environment.api.v1.credential.model.parameters.aws.RoleBasedParameters in project cloudbreak by hortonworks.

the class CredentialValidatorTest method testValidateAwsCredentialRequestValid.

@Test
void testValidateAwsCredentialRequestValid() {
    CredentialRequest request = new CredentialRequest();
    request.setCloudPlatform("AWS");
    AwsCredentialParameters aws = new AwsCredentialParameters();
    RoleBasedParameters roleBased = new RoleBasedParameters();
    roleBased.setRoleArn("arn");
    aws.setRoleBased(roleBased);
    request.setAws(aws);
    ValidationResult result = underTest.validateAwsCredentialRequest(request);
    assertFalse(result.hasError());
}
Also used : CredentialRequest(com.sequenceiq.environment.api.v1.credential.model.request.CredentialRequest) RoleBasedParameters(com.sequenceiq.environment.api.v1.credential.model.parameters.aws.RoleBasedParameters) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) AwsCredentialParameters(com.sequenceiq.environment.api.v1.credential.model.parameters.aws.AwsCredentialParameters) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with RoleBasedParameters

use of com.sequenceiq.environment.api.v1.credential.model.parameters.aws.RoleBasedParameters in project cloudbreak by hortonworks.

the class CredentialValidatorTest method testValidateAwsCredentialRequestNoArn.

@Test
void testValidateAwsCredentialRequestNoArn() {
    CredentialRequest request = new CredentialRequest();
    request.setCloudPlatform("AWS");
    AwsCredentialParameters aws = new AwsCredentialParameters();
    aws.setRoleBased(new RoleBasedParameters());
    request.setAws(aws);
    ValidationResult result = underTest.validateAwsCredentialRequest(request);
    assertTrue(result.hasError());
    assertEquals("Role ARN is not found in credential request.", result.getErrors().get(0));
}
Also used : CredentialRequest(com.sequenceiq.environment.api.v1.credential.model.request.CredentialRequest) RoleBasedParameters(com.sequenceiq.environment.api.v1.credential.model.parameters.aws.RoleBasedParameters) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) AwsCredentialParameters(com.sequenceiq.environment.api.v1.credential.model.parameters.aws.AwsCredentialParameters) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with RoleBasedParameters

use of com.sequenceiq.environment.api.v1.credential.model.parameters.aws.RoleBasedParameters in project cloudbreak by hortonworks.

the class AwsCredentialV1ParametersToAwsCredentialAttributesConverter method getRoleBased.

private RoleBasedParameters getRoleBased(RoleBasedCredentialAttributes source) {
    RoleBasedParameters roleBased = new RoleBasedParameters();
    roleBased.setRoleArn(source.getRoleArn());
    return roleBased;
}
Also used : RoleBasedParameters(com.sequenceiq.environment.api.v1.credential.model.parameters.aws.RoleBasedParameters)

Example 4 with RoleBasedParameters

use of com.sequenceiq.environment.api.v1.credential.model.parameters.aws.RoleBasedParameters in project cloudbreak by hortonworks.

the class CredentialValidator method validateAwsCredentialRequest.

public ValidationResult validateAwsCredentialRequest(CredentialRequest credentialRequest) {
    ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
    resultBuilder.ifError(() -> !CloudPlatform.AWS.name().equalsIgnoreCase(credentialRequest.getCloudPlatform()), "Credential request is not for AWS.");
    resultBuilder.ifError(() -> StringUtils.isBlank(Optional.ofNullable(credentialRequest.getAws()).map(AwsCredentialParameters::getRoleBased).map(RoleBasedParameters::getRoleArn).orElse(null)), "Role ARN is not found in credential request.");
    return resultBuilder.build();
}
Also used : ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) AwsCredentialParameters(com.sequenceiq.environment.api.v1.credential.model.parameters.aws.AwsCredentialParameters)

Example 5 with RoleBasedParameters

use of com.sequenceiq.environment.api.v1.credential.model.parameters.aws.RoleBasedParameters in project cloudbreak by hortonworks.

the class AwsCloudProvider method awsCredentialDetailsArn.

public AwsCredentialParameters awsCredentialDetailsArn() {
    AwsCredentialParameters parameters = new AwsCredentialParameters();
    RoleBasedParameters roleBasedCredentialParameters = new RoleBasedParameters();
    String roleArn = awsProperties.getCredential().getRoleArn();
    roleBasedCredentialParameters.setRoleArn(roleArn);
    parameters.setRoleBased(roleBasedCredentialParameters);
    return parameters;
}
Also used : RoleBasedParameters(com.sequenceiq.environment.api.v1.credential.model.parameters.aws.RoleBasedParameters) AwsCredentialParameters(com.sequenceiq.environment.api.v1.credential.model.parameters.aws.AwsCredentialParameters)

Aggregations

AwsCredentialParameters (com.sequenceiq.environment.api.v1.credential.model.parameters.aws.AwsCredentialParameters)4 RoleBasedParameters (com.sequenceiq.environment.api.v1.credential.model.parameters.aws.RoleBasedParameters)4 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)2 CredentialRequest (com.sequenceiq.environment.api.v1.credential.model.request.CredentialRequest)2 Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)1