[Pkg-owncloud-commits] [php-sabredav] 171/220: Support for principal-match REPORT
David Prévot
taffit at moszumanska.debian.org
Thu May 12 01:21:24 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabredav.
commit 5c61bc487a18d4bccac887bda6ed3f4db3cb4d5b
Author: Evert Pot <me at evertpot.com>
Date: Wed Apr 20 10:03:24 2016 +0800
Support for principal-match REPORT
---
CHANGELOG.md | 1 +
lib/DAVACL/Plugin.php | 16 ++++++++++-
tests/Sabre/DAVACL/PrincipalMatchTest.php | 45 +++++++++++++++++++++++++++++++
tests/Sabre/DAVServerTest.php | 2 +-
4 files changed, 62 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6d28ca8..e935eb5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -47,6 +47,7 @@ ChangeLog
* Renamed `phpunit.xml` to `phpunit.xml.dist` to make local modifications easy.
* Functionality from `IShareableCalendar` is merged into `ISharedCalendar`.
* #751: Fixed XML responses from failing `MKCOL` requests.
+* #600: Support for `principal-match` ACL `REPORT`.
3.1.3 (2016-04-06)
diff --git a/lib/DAVACL/Plugin.php b/lib/DAVACL/Plugin.php
index b7174a2..484021d 100644
--- a/lib/DAVACL/Plugin.php
+++ b/lib/DAVACL/Plugin.php
@@ -1322,10 +1322,24 @@ class Plugin extends DAV\ServerPlugin {
}
- $responses[] = new Response($item, $properties, 'HTTP/1.1 200 OK');
+ $responses[] = new DAV\Xml\Element\Response(
+ $item,
+ $properties,
+ '200'
+ );
}
+ $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
+ $this->server->httpResponse->setStatus(207);
+ $this->server->httpResponse->setBody(
+ $this->server->xml->write(
+ '{DAV:}multistatus',
+ $responses,
+ $this->server->getBaseUri()
+ )
+ );
+
}
diff --git a/tests/Sabre/DAVACL/PrincipalMatchTest.php b/tests/Sabre/DAVACL/PrincipalMatchTest.php
new file mode 100644
index 0000000..012ad3e
--- /dev/null
+++ b/tests/Sabre/DAVACL/PrincipalMatchTest.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Sabre\DAVACL;
+
+use Sabre\HTTP\Request;
+
+class PrincipalMatchTest extends \Sabre\DAVServerTest {
+
+ public $setupACL = true;
+ public $autoLogin = 'user1';
+
+ function testPrincipalMatch() {
+
+ $xml = <<<XML
+<?xml version="1.0"?>
+<principal-match xmlns="DAV:">
+ <self />
+</principal-match>
+XML;
+
+ $request = new Request('REPORT', '/principals', ['Content-Type' => 'application/xml']);
+ $request->setBody($xml);
+
+ $response = $this->request($request, 207);
+
+ $expected = <<<XML
+<?xml version="1.0"?>
+<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
+ <d:status>HTTP/1.1 200 OK</d:status>
+ <d:href>/principals/user1</d:href>
+ <d:propstat>
+ <d:prop/>
+ <d:status>HTTP/1.1 418 I'm a teapot</d:status>
+ </d:propstat>
+</d:multistatus>
+XML;
+
+ $this->assertXmlStringEqualsXmlString(
+ $expected,
+ $response->getBodyAsString()
+ );
+
+ }
+
+}
diff --git a/tests/Sabre/DAVServerTest.php b/tests/Sabre/DAVServerTest.php
index c9039ea..95c3ddf 100644
--- a/tests/Sabre/DAVServerTest.php
+++ b/tests/Sabre/DAVServerTest.php
@@ -279,7 +279,7 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase {
if ($this->setupCardDAV && is_null($this->carddavBackend)) {
$this->carddavBackend = new CardDAV\Backend\Mock($this->carddavAddressBooks, $this->carddavCards);
}
- if ($this->setupCardDAV || $this->setupCalDAV) {
+ if ($this->setupCardDAV || $this->setupCalDAV || $this->setupACL) {
$this->principalBackend = new DAVACL\PrincipalBackend\Mock();
}
if ($this->setupLocks) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-php/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list