use of org.apache.shiro.authz.Permission in project ddf by codice.
the class WorkspacePolicyExtensionTest method testShouldRemoveRolesAndEmailsWhenEmailImplied.
@Test
public void testShouldRemoveRolesAndEmailsWhenEmailImplied() {
List<Permission> before = ImmutableList.of(RANDOM, ROLES, EMAILS);
doReturn(before).when(match).getPermissionList();
CollectionPermission subject = subjectFrom(makePermission(Constants.EMAIL_ADDRESS_CLAIM_URI, VALUES));
List<Permission> after = extension.isPermittedMatchAll(subject, match).getPermissionList();
assertThat(after, is(ImmutableList.of(RANDOM)));
}
use of org.apache.shiro.authz.Permission in project ddf by codice.
the class PolicyManagerTest method testAllPolicies.
private void testAllPolicies() {
//check search policy
ContextPolicy policy = manager.getContextPolicy("/search");
assertThat("/search", is(policy.getContextPath()));
Iterator<String> authIter = policy.getAuthenticationMethods().iterator();
int i = 0;
while (authIter.hasNext()) {
if (i == 0) {
assertThat("SAML", is(authIter.next()));
} else if (i == 1) {
assertThat("BASIC", is(authIter.next()));
} else if (i == 2) {
assertThat("GUEST", is(authIter.next()));
}
i++;
}
List<Permission> permissionList = policy.getAllowedAttributePermissions().getPermissionList();
assertThat("role : user", is(permissionList.get(0).toString()));
assertThat("control : foo", is(permissionList.get(1).toString()));
assertThat("control : bar", is(permissionList.get(2).toString()));
//check admin policy
policy = manager.getContextPolicy("/admin");
assertThat("/admin", is(policy.getContextPath()));
authIter = policy.getAuthenticationMethods().iterator();
i = 0;
while (authIter.hasNext()) {
if (i == 0) {
assertThat("SAML", is(authIter.next()));
} else if (i == 1) {
assertThat("BASIC", is(authIter.next()));
}
i++;
}
//check foo policy
policy = manager.getContextPolicy("/foo");
assertThat("/foo", is(policy.getContextPath()));
authIter = policy.getAuthenticationMethods().iterator();
i = 0;
while (authIter.hasNext()) {
if (i == 0) {
assertThat("BASIC", is(authIter.next()));
}
i++;
}
//make sure some random context points to /
policy = manager.getContextPolicy("/random");
assertThat("/", is(policy.getContextPath()));
authIter = policy.getAuthenticationMethods().iterator();
i = 0;
while (authIter.hasNext()) {
if (i == 0) {
assertThat("SAML", is(authIter.next()));
} else if (i == 1) {
assertThat("BASIC", is(authIter.next()));
}
i++;
}
//check unprotected contexts
policy = manager.getContextPolicy("/unprotected");
assertThat("/unprotected", is(policy.getContextPath()));
authIter = policy.getAuthenticationMethods().iterator();
assertThat(false, is(authIter.hasNext()));
policy = manager.getContextPolicy("/unprotected2");
assertThat("/unprotected2", is(policy.getContextPath()));
authIter = policy.getAuthenticationMethods().iterator();
assertThat(authIter.hasNext(), is(false));
}
Aggregations