use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class L3_UserVsPrincipalTest method testLookup.
@Test
public void testLookup() throws RepositoryException {
Map<String, Object[]> resultMap = ImmutableMap.of(testId, new Object[] { null, null, null }, testPrincipal.getName(), new Object[] { null, null, null }, testGroupId, new Object[] { null, null }, testGroupPrincipal.getName(), new Object[] { null, null });
for (String key : resultMap.keySet()) {
Object[] result = resultMap.get(key);
// lookup principal by "ID"
Principal expectedP = (Principal) result[0];
Principal principal = principalManager.getPrincipal(key);
assertEquals(expectedP, principal);
// lookup authorizable by "principal"
Principal p = new PrincipalImpl(key);
Authorizable a = getUserManager(root).getAuthorizable(p);
if (a != null) {
assertEquals(expectedP, a.getPrincipal());
}
// lookup Authorizable by "ID"
Authorizable expectedA = (Authorizable) result[1];
a = getUserManager(root).getAuthorizable(key);
assertEquals(expectedA, a);
}
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class RandomAuthorizableNodeNameTest method testCreateGroupWithPath.
@Test
public void testCreateGroupWithPath() throws Exception {
Group group = getUserManager(root).createGroup(id, new PrincipalImpl(id), "a/b");
root.commit();
assertNodeName(group, "a/b");
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class CugExcludeDefaultTest method testPrincipals.
@Test
public void testPrincipals() {
Set<Principal> principals = new HashSet<Principal>();
principals.add(new PrincipalImpl("test"));
principals.add(new ItemBasedPrincipal() {
@Override
public String getPath() {
return "/path";
}
@Override
public String getName() {
return "test";
}
});
assertFalse(exclude.isExcluded(principals));
for (Principal p : principals) {
assertFalse(exclude.isExcluded(ImmutableSet.of(p)));
}
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class CugExcludeImplTest method testExcludeAnother.
@Test
public void testExcludeAnother() {
Map<String, Object> m = ImmutableMap.<String, Object>of("principalNames", principalNames);
activate(m);
assertFalse(exclude.isExcluded(ImmutableSet.<Principal>of(new PrincipalImpl("another"))));
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class CugExcludeImplTest method testExcludeTest.
@Test
public void testExcludeTest() {
Map<String, Object> m = ImmutableMap.<String, Object>of("principalNames", principalNames);
activate(m);
Set<Principal> all = new HashSet<Principal>();
for (String name : principalNames) {
Principal p = new PrincipalImpl(name);
assertTrue(exclude.isExcluded(ImmutableSet.of(p)));
all.add(p);
assertTrue(exclude.isExcluded(all));
}
}
Aggregations