use of org.apache.jackrabbit.api.security.principal.GroupPrincipal in project jackrabbit-oak by apache.
the class ExternalGroupPrincipalTest method testIsMemberLocalUser.
@Test
public void testIsMemberLocalUser() throws Exception {
GroupPrincipal principal = getGroupPrincipal();
assertFalse(principal.isMember(getTestUser().getPrincipal()));
assertFalse(principal.isMember(new PrincipalImpl(getTestUser().getPrincipal().getName())));
}
use of org.apache.jackrabbit.api.security.principal.GroupPrincipal in project jackrabbit-oak by apache.
the class L3_EveryoneTest method testEveryoneAsAuthorizableGroup.
public void testEveryoneAsAuthorizableGroup() throws RepositoryException {
// EXERCISE: create an authorizable that corresponds to the everyone principal.
org.apache.jackrabbit.api.security.user.Group everyoneAuthorizable = null;
superuser.save();
try {
GroupPrincipal everyone = (GroupPrincipal) principalManager.getEveryone();
assertEquals(everyone, everyoneAuthorizable.getPrincipal());
// EXERCISE: verify that the everyone principal is still a dynamic group
// EXERCISE: test if the dyanmic nature also applies to the authorizable
} finally {
if (everyoneAuthorizable != null) {
everyoneAuthorizable.remove();
superuser.save();
}
}
}
use of org.apache.jackrabbit.api.security.principal.GroupPrincipal in project jackrabbit-oak by apache.
the class L3_EveryoneTest method testEveryoneIsMemberofEveryone.
public void testEveryoneIsMemberofEveryone() throws RepositoryException {
GroupPrincipal everyone = (GroupPrincipal) principalManager.getEveryone();
PrincipalIterator it = principalManager.getPrincipals(PrincipalManager.SEARCH_TYPE_ALL);
// EXERCISE: discuss the dynamic nature of the everyone group principal
while (it.hasNext()) {
Principal principal = it.nextPrincipal();
if (everyone.equals(principal)) {
assertFalse(everyone.isMember(principal));
} else {
assertTrue(everyone.isMember(principal));
}
}
}
use of org.apache.jackrabbit.api.security.principal.GroupPrincipal in project jackrabbit-oak by apache.
the class PrincipalManagerImplTest method testAllMembersKnown.
@Test
public void testAllMembersKnown() {
for (Principal p : testPrincipals) {
if (isGroup(p)) {
Enumeration<? extends Principal> en = ((GroupPrincipal) p).members();
while (en.hasMoreElements()) {
Principal memb = en.nextElement();
assertTrue(principalMgr.hasPrincipal(memb.getName()));
}
}
}
}
use of org.apache.jackrabbit.api.security.principal.GroupPrincipal in project jackrabbit-oak by apache.
the class PrincipalManagerImplTest method testGetMembersConsistentWithMembership.
@Test
public void testGetMembersConsistentWithMembership() {
Principal everyone = principalMgr.getEveryone();
PrincipalIterator it = principalMgr.getPrincipals(PrincipalManager.SEARCH_TYPE_GROUP);
while (it.hasNext()) {
Principal p = it.nextPrincipal();
if (p.equals(everyone)) {
continue;
}
assertTrue(isGroup(p));
Enumeration<? extends Principal> members = ((GroupPrincipal) p).members();
while (members.hasMoreElements()) {
Principal memb = members.nextElement();
Principal group = null;
PrincipalIterator mship = principalMgr.getGroupMembership(memb);
while (mship.hasNext() && group == null) {
Principal gr = mship.nextPrincipal();
if (p.equals(gr)) {
group = gr;
}
}
assertNotNull("Group member " + memb.getName() + "does not reveal group upon getGroupMembership", p.getName());
}
}
}
Aggregations