Search in sources :

Example 11 with SimulatePrincipalPolicyResult

use of com.amazonaws.services.identitymanagement.model.SimulatePrincipalPolicyResult in project cloudbreak by hortonworks.

the class AwsIDBrokerAssumeRoleValidatorTest method checkCanAssumeRoles.

@Test
public void checkCanAssumeRoles() {
    Role instanceProfileRole = new Role();
    InstanceProfile instanceProfile = new InstanceProfile().withRoles(instanceProfileRole);
    Role role = new Role().withArn("roleArn");
    Collection<Role> roles = Collections.singletonList(role);
    EvaluationResult evalResult = new EvaluationResult().withEvalDecision(PolicyEvaluationDecisionType.Allowed).withEvalResourceName(role.getArn());
    when(iam.simulatePrincipalPolicy(any(SimulatePrincipalPolicyRequest.class))).thenReturn(new SimulatePrincipalPolicyResult().withEvaluationResults(evalResult));
    ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
    assertThat(awsIDBrokerAssumeRoleValidator.canAssumeRoles(iam, instanceProfile, roles, validationResultBuilder)).isTrue();
    assertThat(validationResultBuilder.build().hasError()).isFalse();
}
Also used : Role(com.amazonaws.services.identitymanagement.model.Role) InstanceProfile(com.amazonaws.services.identitymanagement.model.InstanceProfile) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) SimulatePrincipalPolicyRequest(com.amazonaws.services.identitymanagement.model.SimulatePrincipalPolicyRequest) SimulatePrincipalPolicyResult(com.amazonaws.services.identitymanagement.model.SimulatePrincipalPolicyResult) EvaluationResult(com.amazonaws.services.identitymanagement.model.EvaluationResult) Test(org.junit.jupiter.api.Test)

Aggregations

SimulatePrincipalPolicyResult (com.amazonaws.services.identitymanagement.model.SimulatePrincipalPolicyResult)11 EvaluationResult (com.amazonaws.services.identitymanagement.model.EvaluationResult)9 SimulatePrincipalPolicyRequest (com.amazonaws.services.identitymanagement.model.SimulatePrincipalPolicyRequest)9 GetCallerIdentityRequest (com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest)5 GetCallerIdentityResult (com.amazonaws.services.securitytoken.model.GetCallerIdentityResult)5 AmazonIdentityManagementClient (com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonIdentityManagementClient)5 AmazonSecurityTokenServiceClient (com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonSecurityTokenServiceClient)5 AwsCredentialView (com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView)5 ArrayList (java.util.ArrayList)5 Test (org.junit.jupiter.api.Test)5 AwsPermissionMissingException (com.sequenceiq.cloudbreak.cloud.aws.common.exception.AwsPermissionMissingException)4 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)4 URL (java.net.URL)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 Policy (com.amazonaws.auth.policy.Policy)3 InstanceProfile (com.amazonaws.services.identitymanagement.model.InstanceProfile)3 OrganizationsDecisionDetail (com.amazonaws.services.identitymanagement.model.OrganizationsDecisionDetail)3 Role (com.amazonaws.services.identitymanagement.model.Role)3 ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)3