* in ACL request body.
* @throws Exception
*/
public void testWrongPrincipalElementInAclBody() throws Exception
{
NodeImpl testNode = (NodeImpl)root.addNode(TEST_NODE_NAME, "nt:folder");
session.save();
testNode.addMixin("exo:owneable");
testNode.addMixin("exo:privilegeable");
session.save();
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
headers.putSingle("Depth", "0");
headers.putSingle(HttpHeaders.CONTENT_TYPE, "text/xml; charset=\"utf-8\"");
EnvironmentContext ctx = new EnvironmentContext();
Set<String> adminRoles = new HashSet<String>();
adminRoles.add("administrators");
DummySecurityContext adminSecurityContext = new DummySecurityContext(new Principal()
{
public String getName()
{
return USER_ROOT;
}
}, adminRoles);
ctx.put(SecurityContext.class, adminSecurityContext);
RequestHandlerImpl handler = (RequestHandlerImpl)container.getComponentInstanceOfType(RequestHandlerImpl.class);
ResourceLauncher launcher = new ResourceLauncher(handler);
String request =
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<D:acl xmlns:D=\"DAV:\">" + "<D:ace>" + "<D:principal>"
+ "</D:principal>" + "<D:grant>" + "<D:privilege><D:read /><D:write /></D:privilege>" + "</D:grant>"
+ "</D:ace>" + "</D:acl>";
ContainerResponse response =
launcher.service(WebDavConstants.WebDAVMethods.ACL, getPathWS() + testNode.getPath(), BASE_URI, headers,
request.getBytes(), null, ctx);
assertEquals(HTTPStatus.BAD_REQUEST, response.getStatus());
request =
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<D:acl xmlns:D=\"DAV:\">" + "<D:ace>" + "<D:principal>"
+ "<D:all />" + "</D:principal>" + "<D:grant>" + "<D:privilege><D:read /><D:write /></D:privilege>"
+ "</D:grant>" + "</D:ace>" + "</D:acl>";
response =
launcher.service(WebDavConstants.WebDAVMethods.ACL, getPathWS() + testNode.getPath(), BASE_URI, headers,
request.getBytes(), null, ctx);
assertEquals(HTTPStatus.BAD_REQUEST, response.getStatus());
request =
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<D:acl xmlns:D=\"DAV:\">" + "<D:ace>" + "<D:principal>"
+ "<D:href>" + "</D:href>" + "</D:principal>" + "<D:grant>"
+ "<D:privilege><D:read /><D:write /></D:privilege>" + "</D:grant>" + "</D:ace>" + "</D:acl>";
response =
launcher.service(WebDavConstants.WebDAVMethods.ACL, getPathWS() + testNode.getPath(), BASE_URI, headers,
request.getBytes(), null, ctx);
assertEquals(HTTPStatus.BAD_REQUEST, response.getStatus());
request =
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<D:acl xmlns:D=\"DAV:\">" + "<D:ace>" + "<D:principal>"
+ "<D:href>" + USER_ONE + "</D:href>" + "<href>" + USER_TWO + "</href>" + "</D:principal>" + "<D:grant>"
+ "<D:privilege><D:read /><D:write /></D:privilege>" + "</D:grant>" + "</D:ace>" + "</D:acl>";
response =
launcher.service(WebDavConstants.WebDAVMethods.ACL, getPathWS() + testNode.getPath(), BASE_URI, headers,
request.getBytes(), null, ctx);
assertEquals(HTTPStatus.BAD_REQUEST, response.getStatus());
testNode.remove();
session.save();
}