@Test public void testInvalidGetAssumeRolePolicyDocument() { assertThat(awsIamService.getAssumeRolePolicy(new Role())).isNull(); Role role = new Role().withAssumeRolePolicyDocument("}garbage"); assertThat(awsIamService.getAssumeRolePolicy(role)).isNull(); }
public Policy getAssumeRolePolicy(Role role) { Policy policy = null; String assumeRolePolicyDocument = role.getAssumeRolePolicyDocument(); if (assumeRolePolicyDocument != null) { try { String decodedAssumeRolePolicyDocument = URLDecoder.decode(assumeRolePolicyDocument, StandardCharsets.UTF_8); policy = Policy.fromJson(decodedAssumeRolePolicyDocument); } catch (IllegalArgumentException e) { LOGGER.error(String.format("Unable to get policy from role (%s)", role.getArn()), e); } } return policy; }
AwsIamService { public Policy getAssumeRolePolicy(Role role) { Policy policy = null; String assumeRolePolicyDocument = role.getAssumeRolePolicyDocument(); if (assumeRolePolicyDocument != null) { try { String decodedAssumeRolePolicyDocument = URLDecoder.decode(assumeRolePolicyDocument, StandardCharsets.UTF_8); policy = Policy.fromJson(decodedAssumeRolePolicyDocument); } catch (IllegalArgumentException e) { LOGGER.error(String.format("Unable to get policy from role (%s)", role.getArn()), e); } } return policy; } }
AwsIamService { public Policy getAssumeRolePolicy(Role role) { Policy policy = null; String assumeRolePolicyDocument = role.getAssumeRolePolicyDocument(); if (assumeRolePolicyDocument != null) { try { String decodedAssumeRolePolicyDocument = URLDecoder.decode(assumeRolePolicyDocument, StandardCharsets.UTF_8); policy = Policy.fromJson(decodedAssumeRolePolicyDocument); } catch (IllegalArgumentException e) { LOGGER.error(String.format("Unable to get policy from role (%s)", role.getArn()), e); } } return policy; }  }
AwsIamService { public Policy getAssumeRolePolicy(Role role) { Policy policy = null; String assumeRolePolicyDocument = role.getAssumeRolePolicyDocument(); if (assumeRolePolicyDocument != null) { try { String decodedAssumeRolePolicyDocument = URLDecoder.decode(assumeRolePolicyDocument, StandardCharsets.UTF_8); policy = Policy.fromJson(decodedAssumeRolePolicyDocument); } catch (IllegalArgumentException e) { LOGGER.error(String.format("Unable to get policy from role (%s)", role.getArn()), e); } } return policy; }  InstanceProfile getInstanceProfile(AmazonIdentityManagement iam, String instanceProfileArn,
            ValidationResultBuilder validationResultBuilder); Set<Role> getValidRoles(AmazonIdentityManagement iam, Set<String> roleArns,
            ValidationResultBuilder validationResultBuilder); Role getRole(AmazonIdentityManagement iam, String roleArn,
            ValidationResultBuilder validationResultBuilder); Policy getAssumeRolePolicy(Role role); Policy getPolicy(String policyFileName, Map<String, String> replacements); SortedSet<String> getStatementActions(Statement statement); SortedSet<String> getStatementResources(Statement statement); List<EvaluationResult> simulatePrincipalPolicy(AmazonIdentityManagement iam,
            String policySourceArn, Collection<String> actionNames, Collection<String> resourceArns); List<EvaluationResult> validateRolePolicies(AmazonIdentityManagement iam, Role role,
            Collection<Policy> policies); }
AwsIamService { public Policy getAssumeRolePolicy(Role role) { Policy policy = null; String assumeRolePolicyDocument = role.getAssumeRolePolicyDocument(); if (assumeRolePolicyDocument != null) { try { String decodedAssumeRolePolicyDocument = URLDecoder.decode(assumeRolePolicyDocument, StandardCharsets.UTF_8); policy = Policy.fromJson(decodedAssumeRolePolicyDocument); } catch (IllegalArgumentException e) { LOGGER.error(String.format("Unable to get policy from role (%s)", role.getArn()), e); } } return policy; }  InstanceProfile getInstanceProfile(AmazonIdentityManagement iam, String instanceProfileArn,
            ValidationResultBuilder validationResultBuilder); Set<Role> getValidRoles(AmazonIdentityManagement iam, Set<String> roleArns,
            ValidationResultBuilder validationResultBuilder); Role getRole(AmazonIdentityManagement iam, String roleArn,
            ValidationResultBuilder validationResultBuilder); Policy getAssumeRolePolicy(Role role); Policy getPolicy(String policyFileName, Map<String, String> replacements); SortedSet<String> getStatementActions(Statement statement); SortedSet<String> getStatementResources(Statement statement); List<EvaluationResult> simulatePrincipalPolicy(AmazonIdentityManagement iam,
            String policySourceArn, Collection<String> actionNames, Collection<String> resourceArns); List<EvaluationResult> validateRolePolicies(AmazonIdentityManagement iam, Role role,
            Collection<Policy> policies);  }