PolicyIdpAccessEnforcer implements JsonMapper { public void actionAllowed(PdpPolicy pdpPolicy, PolicyAccess policyAccess, String serviceProviderId, List<String> identityProviderIds) { doActionAllowed(pdpPolicy, policyAccess, serviceProviderId, identityProviderIds, true); }  void actionAllowed(PdpPolicy pdpPolicy, PolicyAccess policyAccess, String serviceProviderId, List<String> identityProviderIds); boolean actionAllowedIndicator(PdpPolicy pdpPolicy, PolicyAccess policyAccess, String serviceProviderId, List<String> identityProviderIds); Iterable<PdpPolicyViolation> filterViolations(Iterable<PdpPolicyViolation> violations); List<PdpPolicyDefinition> filterPdpPolicies(List<PdpPolicyDefinition> policies); List<EntityMetaData> filterIdentityProviders(List<EntityMetaData> identityProviders); static FederatedUser federatedUser(); String username(); String authenticatingAuthority(); String userDisplayName(); boolean isPolicyIdpAccessEnforcementRequired();  }
@Test public void testActionNotAllowedDifferentAuthenticatingAuthorityButOwnerDifferentIdp() throws Exception { this.pdpPolicy.setAuthenticatingAuthority(notOwnedIdp); setupSecurityContext(false, entityMetadata(identityProviderIds[0]), entityMetadata(notOwnedIdp)); this.subject.actionAllowed(pdpPolicy, PolicyAccess.WRITE, serviceProviderIds[0], singletonList(identityProviderIds[0])); }
@Test public void testActionNotAllowedButNoEnforcementForUser() throws Exception { setupSecurityContext(false, entityMetadata(identityProviderIds), entityMetadata(serviceProviderIds)); this.subject.actionAllowed(pdpPolicy, PolicyAccess.WRITE, null, null); }
@Test public void testActionAllowedViolations() throws Exception { this.subject.actionAllowed(null, PolicyAccess.VIOLATIONS, null, null); }
@Test public void testActionAllowedIdpsAndSpAllowed() throws Exception { manage.allowAll(true); this.subject.actionAllowed(pdpPolicy, PolicyAccess.READ, notOwnedSp, Collections.EMPTY_LIST); }
@Test public void testActionAllowedHappyFlowNoIdps() throws Exception { this.subject.actionAllowed(pdpPolicy, PolicyAccess.WRITE, serviceProviderIds[0], EMPTY_LIST); }
@Test public void testActionAllowedHappyFlowOwnedIdps() throws Exception { this.subject.actionAllowed(pdpPolicy, PolicyAccess.WRITE, serviceProviderIds[0], asList(identityProviderIds)); }
@Test(expected = PolicyIdpAccessMismatchServiceProviderException.class) public void testActionNotAllowedSpDoesNotMatch() throws Exception { setupSecurityContext(true, entityMetadata(identityProviderIds), entityMetadata("http: this.subject.actionAllowed(pdpPolicy, PolicyAccess.WRITE, serviceProviderIds[0], EMPTY_LIST); }
@Test(expected = PolicyIdpAccessMismatchIdentityProvidersException.class) public void testActionNotAllowedIdpsDoNotMatch() throws Exception { this.subject.actionAllowed(pdpPolicy, PolicyAccess.WRITE, serviceProviderIds[0], singletonList(notOwnedIdp)); }
@Test(expected = PolicyIdpAccessOriginatingIdentityProviderException.class) public void testActionNotAllowedWrongAuthenticatingAuthority() throws Exception { this.pdpPolicy.setAuthenticatingAuthority(notOwnedIdp); this.subject.actionAllowed(pdpPolicy, PolicyAccess.WRITE, serviceProviderIds[0], EMPTY_LIST); }