* @throws Exception
*/
public void testPropfindPropOwnerAndAclOnNode() throws Exception
{
NodeImpl testNode = (NodeImpl)root.addNode("test_acl_property", "nt:folder");
testNode.addMixin("exo:owneable");
testNode.addMixin("exo:privilegeable");
session.save();
Map<String, String[]> permissions = new HashMap<String, String[]>();
String userName = USER_JOHN;
permissions.put(userName, PermissionType.ALL);
testNode.setPermissions(permissions);
testNode.getSession().save();
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
headers.putSingle("Depth", "1");
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:propfind xmlns:D=\"DAV:\">" + "<D:prop>" + "<D:owner/>"
+ "<D:acl/>" + "</D:prop>" + "</D:propfind>";
ContainerResponse cres =
launcher.service(WebDAVMethods.PROPFIND, getPathWS() + testNode.getPath(), BASE_URI, headers,
request.getBytes(), null, ctx);
assertEquals(HTTPStatus.MULTISTATUS, cres.getStatus());
HierarchicalPropertyEntityProvider provider = new HierarchicalPropertyEntityProvider();
InputStream inputStream = TestUtils.getResponseAsStream(cres);
HierarchicalProperty multistatus = provider.readFrom(null, null, null, null, null, inputStream);
assertEquals(new QName("DAV:", "multistatus"), multistatus.getName());
assertEquals(1, multistatus.getChildren().size());
HierarchicalProperty resourceProp = multistatus.getChildren().get(0);
HierarchicalProperty resourceHref = resourceProp.getChild(new QName("DAV:", "href"));
assertNotNull(resourceHref);
assertEquals(BASE_URI + getPathWS() + testNode.getPath() + "/", resourceHref.getValue());
HierarchicalProperty propstatProp = resourceProp.getChild(new QName("DAV:", "propstat"));
HierarchicalProperty propProp = propstatProp.getChild(new QName("DAV:", "prop"));
HierarchicalProperty aclProp = propProp.getChild(ACLProperties.ACL);