From b35122f7a6ad42756c35bb60ba1f06c3dcd45c77 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 21 Oct 2013 15:46:31 -0700 Subject: add sabre (1.8.x) via composer in the !@#$ place it wants to be --- .../dav/tests/Sabre/DAVACL/Property/ACLTest.php | 335 +++++++++++++++++++++ 1 file changed, 335 insertions(+) create mode 100644 vendor/sabre/dav/tests/Sabre/DAVACL/Property/ACLTest.php (limited to 'vendor/sabre/dav/tests/Sabre/DAVACL/Property/ACLTest.php') diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Property/ACLTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Property/ACLTest.php new file mode 100644 index 000000000..7f2014df3 --- /dev/null +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Property/ACLTest.php @@ -0,0 +1,335 @@ +createElementNS('DAV:','d:root'); + + $dom->appendChild($root); + + $acl = new Acl(array()); + $acl->serialize(new DAV\Server(), $root); + + $xml = $dom->saveXML(); + $expected = ' + +'; + $this->assertEquals($expected, $xml); + + } + + function testSerialize() { + + $dom = new \DOMDocument('1.0'); + $root = $dom->createElementNS('DAV:','d:root'); + + $dom->appendChild($root); + + $privileges = array( + array( + 'principal' => 'principals/evert', + 'privilege' => '{DAV:}write', + 'uri' => 'articles', + ), + array( + 'principal' => 'principals/foo', + 'privilege' => '{DAV:}read', + 'uri' => 'articles', + 'protected' => true, + ), + ); + + $acl = new Acl($privileges); + $acl->serialize(new DAV\Server(), $root); + + $dom->formatOutput = true; + + $xml = $dom->saveXML(); + $expected = ' + + + + /principals/evert/ + + + + + + + + + + /principals/foo/ + + + + + + + + + +'; + $this->assertEquals($expected, $xml); + + } + + function testSerializeSpecialPrincipals() { + + $dom = new \DOMDocument('1.0'); + $root = $dom->createElementNS('DAV:','d:root'); + + $dom->appendChild($root); + + $privileges = array( + array( + 'principal' => '{DAV:}authenticated', + 'privilege' => '{DAV:}write', + 'uri' => 'articles', + ), + array( + 'principal' => '{DAV:}unauthenticated', + 'privilege' => '{DAV:}write', + 'uri' => 'articles', + ), + array( + 'principal' => '{DAV:}all', + 'privilege' => '{DAV:}write', + 'uri' => 'articles', + ), + + ); + + $acl = new Acl($privileges); + $acl->serialize(new DAV\Server(), $root); + + $dom->formatOutput = true; + + $xml = $dom->saveXML(); + $expected = ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +'; + $this->assertEquals($expected, $xml); + + } + + function testUnserialize() { + + $source = ' + + + + /principals/evert/ + + + + + + + + + + /principals/foo/ + + + + + + + + + +'; + + $dom = DAV\XMLUtil::loadDOMDocument($source); + $result = Acl::unserialize($dom->firstChild); + + $this->assertInstanceOf('Sabre\\DAVACL\\Property\\ACL', $result); + + $expected = array( + array( + 'principal' => '/principals/evert/', + 'protected' => false, + 'privilege' => '{DAV:}write', + ), + array( + 'principal' => '/principals/foo/', + 'protected' => true, + 'privilege' => '{DAV:}read', + ), + ); + + $this->assertEquals($expected, $result->getPrivileges()); + + + } + + /** + * @expectedException Sabre\DAV\Exception\BadRequest + */ + function testUnserializeNoPrincipal() { + + $source = ' + + + + + + + + + +'; + + $dom = DAV\XMLUtil::loadDOMDocument($source); + Acl::unserialize($dom->firstChild); + + } + + function testUnserializeOtherPrincipal() { + + $source = ' + + + + + + + + + + + + + + + + + + + + + + + + + + +'; + + $dom = DAV\XMLUtil::loadDOMDocument($source); + $result = Acl::unserialize($dom->firstChild); + + $this->assertInstanceOf('Sabre\\DAVACL\\Property\\Acl', $result); + + $expected = array( + array( + 'principal' => '{DAV:}authenticated', + 'protected' => false, + 'privilege' => '{DAV:}write', + ), + array( + 'principal' => '{DAV:}unauthenticated', + 'protected' => false, + 'privilege' => '{DAV:}write', + ), + array( + 'principal' => '{DAV:}all', + 'protected' => false, + 'privilege' => '{DAV:}write', + ), + ); + + $this->assertEquals($expected, $result->getPrivileges()); + + + } + + /** + * @expectedException Sabre\DAV\Exception\NotImplemented + */ + function testUnserializeDeny() { + + $source = ' + + + + + + + + /principals/evert + + +'; + + $dom = DAV\XMLUtil::loadDOMDocument($source); + Acl::unserialize($dom->firstChild); + } + + /** + * @expectedException Sabre\DAV\Exception\BadRequest + */ + function testUnserializeMissingPriv() { + + $source = ' + + + + + + /principals/evert + + +'; + + $dom = DAV\XMLUtil::loadDOMDocument($source); + Acl::unserialize($dom->firstChild); + + } +} -- cgit v1.2.3