use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class WriteTest method testInvalidPrincipal.
public void testInvalidPrincipal() throws Exception {
PrincipalManager pMgr = ((JackrabbitSession) superuser).getPrincipalManager();
String unknown = "unknown";
while (pMgr.hasPrincipal(unknown)) {
unknown = unknown + "_";
}
Principal principal = new PrincipalImpl(unknown);
if (acMgr instanceof JackrabbitAccessControlManager) {
// first try applicable policies
try {
AccessControlPolicy[] policies = ((JackrabbitAccessControlManager) acMgr).getApplicablePolicies(principal);
assertNotNull(policies);
assertEquals(0, policies.length);
} catch (AccessControlException e) {
// success
}
// second existing policies
try {
AccessControlPolicy[] policies = ((JackrabbitAccessControlManager) acMgr).getPolicies(principal);
assertNotNull(policies);
assertEquals(0, policies.length);
} catch (AccessControlException e) {
// success
}
} else {
throw new NotExecutableException();
}
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class AdministratorTest method testAdminNodeCollidingWithAuthorizableFolder.
/**
* Test for collisions that would prevent from recreate the admin user.
* - an intermediate rep:AuthorizableFolder node with the same name
*/
public void testAdminNodeCollidingWithAuthorizableFolder() throws RepositoryException, NotExecutableException {
Authorizable admin = userMgr.getAuthorizable(adminId);
if (admin == null || !(admin instanceof AuthorizableImpl)) {
throw new NotExecutableException();
}
// access the node corresponding to the admin user and remove it
NodeImpl adminNode = ((AuthorizableImpl) admin).getNode();
String adminPath = adminNode.getPath();
String adminNodeName = adminNode.getName();
Node parentNode = adminNode.getParent();
Session s = adminNode.getSession();
adminNode.remove();
// use session obtained from the node as usermgr may point to a dedicated
// system workspace different from the superusers workspace.
s.save();
Session s2 = null;
String collidingPath = null;
try {
// now create a colliding node:
Node n = parentNode.addNode(adminNodeName, "rep:AuthorizableFolder");
collidingPath = n.getPath();
s.save();
// force recreation of admin user.
s2 = getHelper().getSuperuserSession();
admin = userMgr.getAuthorizable(adminId);
assertNotNull(admin);
assertEquals(adminNodeName, ((AuthorizableImpl) admin).getNode().getName());
assertFalse(adminPath.equals(((AuthorizableImpl) admin).getNode().getPath()));
} finally {
if (s2 != null) {
s2.logout();
}
// remove the extra folder and the admin user (created underneath) again.
if (collidingPath != null) {
s.getNode(collidingPath).remove();
s.save();
}
}
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class AuthorizableActionTest method assertAcAction.
private static void assertAcAction(Authorizable a, UserManagerImpl umgr) throws RepositoryException, NotExecutableException {
Session s = umgr.getSession();
AccessControlManager acMgr = s.getAccessControlManager();
boolean hasACL = false;
AccessControlPolicyIterator it = acMgr.getApplicablePolicies("/");
while (it.hasNext()) {
if (it.nextAccessControlPolicy() instanceof AccessControlList) {
hasACL = true;
break;
}
}
if (!hasACL) {
for (AccessControlPolicy p : acMgr.getPolicies("/")) {
if (p instanceof AccessControlList) {
hasACL = true;
break;
}
}
}
if (!hasACL) {
throw new NotExecutableException("No ACLs in workspace containing users.");
}
String path = a.getPath();
assertEquals(1, acMgr.getPolicies(path).length);
assertTrue(acMgr.getPolicies(path)[0] instanceof AccessControlList);
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class AuthorizableImplTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
if (superuser instanceof SessionImpl) {
NameResolver resolver = (SessionImpl) superuser;
protectedUserProps.add(resolver.getJCRName(UserConstants.P_PASSWORD));
protectedUserProps.add(resolver.getJCRName(UserConstants.P_IMPERSONATORS));
protectedUserProps.add(resolver.getJCRName(UserConstants.P_PRINCIPAL_NAME));
protectedUserProps.add(resolver.getJCRName(UserConstants.P_DISABLED));
protectedGroupProps.add(resolver.getJCRName(UserConstants.P_MEMBERS));
protectedGroupProps.add(resolver.getJCRName(UserConstants.P_PRINCIPAL_NAME));
} else {
throw new NotExecutableException();
}
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class PropertyReadMethodsTest method testGetValues.
/**
* Tests failure of Property.getValues() method for a single value
* property.
*/
public void testGetValues() throws RepositoryException, NotExecutableException {
Property singleProp = PropertyUtil.searchSingleValuedProperty(testRootNode);
if (singleProp == null) {
throw new NotExecutableException("No single valued property found.");
}
try {
singleProp.getValues();
fail("Property.getValues() called on a single property " + "should throw a ValueFormatException.");
} catch (ValueFormatException vfe) {
// ok
}
}
Aggregations