use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class AuthorizableImplTest method testHashCode.
/**
* @since OAK 1.0
*/
@Test
public void testHashCode() throws Exception {
Authorizable user = userMgr.getAuthorizable(testUser.getID());
Authorizable group = userMgr.getAuthorizable(testGroup.getID());
Map<Authorizable, Authorizable> sameHashCode = new HashMap();
sameHashCode.put(testUser, testUser);
sameHashCode.put(testGroup, testGroup);
sameHashCode.put(user, user);
sameHashCode.put(group, group);
sameHashCode.put(testUser, user);
sameHashCode.put(testGroup, group);
for (Map.Entry entry : sameHashCode.entrySet()) {
assertEquals(entry.getKey().hashCode(), entry.getValue().hashCode());
}
UserManager otherUserManager = getUserConfiguration().getUserManager(root, getNamePathMapper());
user = otherUserManager.getAuthorizable(testUser.getID());
group = otherUserManager.getAuthorizable(testGroup.getID());
Map<Authorizable, Authorizable> notSameHashCode = new HashMap();
notSameHashCode.put(testUser, testGroup);
notSameHashCode.put(user, group);
notSameHashCode.put(testUser, user);
notSameHashCode.put(testGroup, group);
for (Map.Entry entry : notSameHashCode.entrySet()) {
assertFalse(entry.getKey().hashCode() == entry.getValue().hashCode());
}
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class AuthorizablePropertyTest method testSingleToMultiValued.
@Test
public void testSingleToMultiValued() throws Exception {
UserManager uMgr = getUserManager(superuser);
try {
Value v = superuser.getValueFactory().createValue("anyValue");
user.setProperty("someProp", v);
if (!uMgr.isAutoSave()) {
superuser.save();
}
Value[] vs = new Value[] { v, v };
user.setProperty("someProp", vs);
if (!uMgr.isAutoSave()) {
superuser.save();
}
} finally {
if (user.removeProperty("someProp") && !uMgr.isAutoSave()) {
superuser.save();
}
}
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class AbstractRemoveMembersByIdTest method before.
@Override
public void before() throws Exception {
super.before();
UserManager uMgr = getUserManager(root);
for (String id : NON_EXISTING_IDS) {
assertNull(uMgr.getAuthorizable(id));
}
testGroup = uMgr.createGroup("testGroup" + UUID.randomUUID().toString());
memberGroup = uMgr.createGroup("memberGroup" + UUID.randomUUID().toString());
testGroup.addMember(memberGroup);
testGroup.addMember(getTestUser());
root.commit();
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class AuthorizableImplTest method testNotEqualAuthorizables.
/**
* @since OAK 1.0
*/
@Test
public void testNotEqualAuthorizables() throws Exception {
UserManager otherUserManager = getUserConfiguration().getUserManager(root, getNamePathMapper());
Authorizable user = otherUserManager.getAuthorizable(testUser.getID());
Authorizable group = otherUserManager.getAuthorizable(testGroup.getID());
Map<Authorizable, Authorizable> notEqual = new HashMap();
notEqual.put(testUser, testGroup);
notEqual.put(user, group);
notEqual.put(testUser, user);
notEqual.put(testGroup, group);
for (Map.Entry entry : notEqual.entrySet()) {
assertFalse(entry.getKey().equals(entry.getValue()));
assertFalse(entry.getValue().equals(entry.getKey()));
}
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class L3_PrecedenceRulesTest method tearDown.
@Override
protected void tearDown() throws Exception {
try {
if (testSession != null && testSession.isLive()) {
testSession.logout();
}
UserManager uMgr = ((JackrabbitSession) superuser).getUserManager();
Authorizable testUser = uMgr.getAuthorizable(testPrincipal);
if (testUser != null) {
testUser.remove();
}
Authorizable testGroup = uMgr.getAuthorizable(testGroupPrincipal);
if (testGroup != null) {
testGroup.remove();
}
superuser.save();
} finally {
super.tearDown();
}
}
Aggregations