use of org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal in project jackrabbit-oak by apache.
the class CugExcludeDefaultTest method testAdminPrincipal.
@Test
public void testAdminPrincipal() {
Set<Principal> principals = ImmutableSet.<Principal>of(new AdminPrincipal() {
@Override
public String getName() {
return "admin";
}
});
assertTrue(exclude.isExcluded(principals));
}
use of org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal in project jackrabbit-oak by apache.
the class AdminPrincipalsBaseTest method testAdminAuthInfoPrincipals.
@Test
public void testAdminAuthInfoPrincipals() throws Exception {
try {
for (Principal p : adminSession.getAuthInfo().getPrincipals()) {
if (p instanceof AdminPrincipal) {
boolean success = acl.addAccessControlEntry(p, privilegesFromNames(PrivilegeConstants.JCR_READ));
assertResult(success);
}
}
} catch (AccessControlException e) {
assertException();
}
}
use of org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal in project jackrabbit-oak by apache.
the class AbstractPrincipalProviderTest method testAdminPrincipal.
@Test
public void testAdminPrincipal() throws Exception {
String userId = adminSession.getAuthInfo().getUserID();
Authorizable admin = getUserManager(root).getAuthorizable(userId);
if (admin != null && admin.getPrincipal() instanceof AdminPrincipal) {
Principal principal = principalProvider.getPrincipal(admin.getPrincipal().getName());
assertTrue(principal instanceof AdminPrincipal);
Set<? extends Principal> principals = principalProvider.getPrincipals(userId);
boolean containsAdminPrincipal = false;
for (Principal p : principals) {
if (p instanceof AdminPrincipal) {
containsAdminPrincipal = true;
break;
}
}
assertTrue(containsAdminPrincipal);
}
}
use of org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal in project jackrabbit-oak by apache.
the class ImpersonationImplEmptyTest method testAllowsAdminPrincipal2.
@Test
public void testAllowsAdminPrincipal2() throws Exception {
Subject subject = new Subject(true, ImmutableSet.of(new AdminPrincipal() {
@Override
public String getName() {
return "principalName";
}
}), ImmutableSet.of(), ImmutableSet.of());
assertTrue(impersonation.allows(subject));
}
use of org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal in project jackrabbit-oak by apache.
the class UserInitializerTest method testAnonymous.
@Test
public void testAnonymous() throws Exception {
Authorizable a = userMgr.getAuthorizable(UserUtil.getAnonymousId(config));
assertFalse(a.isGroup());
User anonymous = (User) a;
assertFalse(anonymous.isAdmin());
assertFalse(anonymous.getPrincipal() instanceof AdminPrincipal);
assertTrue(anonymous.getPrincipal() instanceof TreeBasedPrincipal);
assertEquals(anonymous.getID(), anonymous.getPrincipal().getName());
}
Aggregations