use of org.apache.jackrabbit.api.security.principal.GroupPrincipal in project jackrabbit-oak by apache.
the class L3_EveryoneTest method testEveryoneExists.
public void testEveryoneExists() throws RepositoryException {
Principal everyone = principalManager.getEveryone();
assertNotNull(everyone);
assertTrue(everyone instanceof GroupPrincipal);
Authorizable everyoneAuthorizable = ((JackrabbitSession) superuser).getUserManager().getAuthorizable(everyone);
assertNull(everyoneAuthorizable);
}
use of org.apache.jackrabbit.api.security.principal.GroupPrincipal in project jackrabbit by apache.
the class GroupTest method testMembersInPrincipal.
public void testMembersInPrincipal() throws NotExecutableException, RepositoryException {
User auth = getTestUser(superuser);
Group newGroup = null;
Group newGroup2 = null;
try {
newGroup = userMgr.createGroup(getTestPrincipal());
newGroup2 = userMgr.createGroup(getTestPrincipal());
save(superuser);
newGroup.addMember(newGroup2);
save(superuser);
newGroup2.addMember(auth);
save(superuser);
GroupPrincipal ngPrincipal = (GroupPrincipal) newGroup.getPrincipal();
GroupPrincipal ng2Principal = (GroupPrincipal) newGroup2.getPrincipal();
assertFalse(ng2Principal.isMember(ngPrincipal));
// newGroup2 must be member of newGroup's principal
assertTrue(ngPrincipal.isMember(newGroup2.getPrincipal()));
// testuser must be member of newGroup2's and newGroup's principal (indirect)
assertTrue(ng2Principal.isMember(auth.getPrincipal()));
assertTrue(ngPrincipal.isMember(auth.getPrincipal()));
} finally {
if (newGroup != null) {
newGroup.removeMember(newGroup2);
newGroup.remove();
save(superuser);
}
if (newGroup2 != null) {
newGroup2.removeMember(auth);
newGroup2.remove();
save(superuser);
}
}
}
use of org.apache.jackrabbit.api.security.principal.GroupPrincipal in project jackrabbit by apache.
the class DefaultPrincipalProviderTest method testGroupMembership.
/**
* Test for: Principal assiocated with Group does not update members
* @see <a href=https://issues.apache.org/jira/browse/JCR-3552>JCR-3552</a>
*/
public void testGroupMembership() throws Exception {
Group g = null;
User u = null;
Principal up = getTestPrincipal();
try {
// create a group and user, add the user to the group and assert membership
g = userMgr.createGroup(getTestPrincipal());
u = userMgr.createUser(up.getName(), buildPassword(up));
save(superuser);
g.addMember(u);
save(superuser);
Principal groupPrincipal = principalProvider.getPrincipal(g.getPrincipal().getName());
assertTrue(groupPrincipal instanceof GroupPrincipal);
assertTrue(((GroupPrincipal) groupPrincipal).isMember(u.getPrincipal()));
// remove the user from the group and assert the user is no longer a member of the group
g.removeMember(u);
save(superuser);
groupPrincipal = principalProvider.getPrincipal(g.getPrincipal().getName());
assertFalse(((GroupPrincipal) groupPrincipal).isMember(u.getPrincipal()));
} finally {
if (null != g) {
g.remove();
}
if (null != u) {
u.remove();
}
save(superuser);
}
}
Aggregations