[Pkg-owncloud-commits] [php-sabredav] 02/07: Test for #700
David Prévot
taffit at moszumanska.debian.org
Tue Aug 11 13:35:33 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to tag 3.0.3
in repository php-sabredav.
commit 68f68b65d1fdfb338cd76840a362e3bda5cc1bba
Author: Evert Pot <me at evertpot.com>
Date: Thu Aug 6 15:55:37 2015 -0400
Test for #700
---
lib/CalDAV/Plugin.php | 2 +-
tests/Sabre/DAV/HttpGetTest.php | 43 +-----------------
tests/Sabre/DAV/HttpHeadTest.php | 97 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 99 insertions(+), 43 deletions(-)
diff --git a/lib/CalDAV/Plugin.php b/lib/CalDAV/Plugin.php
index 4e5f6be..51580e5 100644
--- a/lib/CalDAV/Plugin.php
+++ b/lib/CalDAV/Plugin.php
@@ -578,7 +578,7 @@ class Plugin extends DAV\ServerPlugin {
if ($node instanceof ICalendarObjectContainer && $depth === 0) {
- if(strpos($this->server->httpRequest->getHeader('User-Agent'), 'MSFT-WP/') === 0) {
+ if (strpos($this->server->httpRequest->getHeader('User-Agent'), 'MSFT-WP/') === 0) {
// Windows phone incorrectly supplied depth as 0, when it actually
// should have set depth to 1. We're implementing a workaround here
// to deal with this.
diff --git a/tests/Sabre/DAV/HttpGetTest.php b/tests/Sabre/DAV/HttpGetTest.php
index 71db51a..95e58a3 100644
--- a/tests/Sabre/DAV/HttpGetTest.php
+++ b/tests/Sabre/DAV/HttpGetTest.php
@@ -6,7 +6,7 @@ use Sabre\DAVServerTest;
use Sabre\HTTP;
/**
- * Tests related to the PUT request.
+ * Tests related to the GET request.
*
* @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
* @author Evert Pot (http://evertpot.com/)
@@ -125,33 +125,6 @@ class HttpGetTest extends DAVServerTest {
}
- /**
- * HEAD is identical to GET, but it's missing a body
- */
- function testHEAD() {
-
- $request = new HTTP\Request('HEAD', '//file1');
- $response = $this->request($request);
-
- $this->assertEquals(200, $response->getStatus());
-
- // Removing Last-Modified because it keeps changing.
- $response->removeHeader('Last-Modified');
-
- $this->assertEquals(
- [
- 'X-Sabre-Version' => [Version::VERSION],
- 'Content-Type' => ['application/octet-stream'],
- 'Content-Length' => [3],
- 'ETag' => ['"' . md5('foo') . '"'],
- ],
- $response->getHeaders()
- );
-
- $this->assertEquals('', $response->getBodyAsString());
-
- }
-
function testGetCollection() {
$request = new HTTP\Request('GET', '/dir');
@@ -161,20 +134,6 @@ class HttpGetTest extends DAVServerTest {
}
- /**
- * According to the specs, HEAD should behave identical to GET. But, broken
- * clients needs HEAD requests on collections to respond with a 200, so
- * that's what we do.
- */
- function testHEADCollection() {
-
- $request = new HTTP\Request('HEAD', '/dir');
- $response = $this->request($request);
-
- $this->assertEquals(200, $response->getStatus());
-
- }
-
function testGetStreaming() {
$request = new HTTP\Request('GET', '/streaming');
diff --git a/tests/Sabre/DAV/HttpHeadTest.php b/tests/Sabre/DAV/HttpHeadTest.php
new file mode 100644
index 0000000..cace128
--- /dev/null
+++ b/tests/Sabre/DAV/HttpHeadTest.php
@@ -0,0 +1,97 @@
+<?php
+
+namespace Sabre\DAV;
+
+use Sabre\DAVServerTest;
+use Sabre\HTTP;
+
+/**
+ * Tests related to the HEAD request.
+ *
+ * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class HttpHeadTest extends DAVServerTest {
+
+ /**
+ * Sets up the DAV tree.
+ *
+ * @return void
+ */
+ function setUpTree() {
+
+ $this->tree = new Mock\Collection('root', [
+ 'file1' => 'foo',
+ new Mock\Collection('dir', []),
+ new Mock\StreamingFile('streaming', 'stream')
+ ]);
+
+ }
+
+ function testHEAD() {
+
+ $request = new HTTP\Request('HEAD', '//file1');
+ $response = $this->request($request);
+
+ $this->assertEquals(200, $response->getStatus());
+
+ // Removing Last-Modified because it keeps changing.
+ $response->removeHeader('Last-Modified');
+
+ $this->assertEquals(
+ [
+ 'X-Sabre-Version' => [Version::VERSION],
+ 'Content-Type' => ['application/octet-stream'],
+ 'Content-Length' => [3],
+ 'ETag' => ['"' . md5('foo') . '"'],
+ ],
+ $response->getHeaders()
+ );
+
+ $this->assertEquals('', $response->getBodyAsString());
+
+ }
+
+ /**
+ * According to the specs, HEAD should behave identical to GET. But, broken
+ * clients needs HEAD requests on collections to respond with a 200, so
+ * that's what we do.
+ */
+ function testHEADCollection() {
+
+ $request = new HTTP\Request('HEAD', '/dir');
+ $response = $this->request($request);
+
+ $this->assertEquals(200, $response->getStatus());
+
+ }
+
+ /**
+ * HEAD automatically internally maps to GET via a sub-request.
+ * The Auth plugin must not be triggered twice for these, so we'll
+ * test for that.
+ */
+ function testDoubleAuth() {
+
+ $count = 0;
+
+ $authBackend = new Auth\Backend\BasicCallBack(function($userName,$password) use (&$count) {
+ $count++;
+ return true;
+ });
+ $this->server->addPlugin(
+ new Auth\Plugin(
+ $authBackend
+ )
+ );
+ $request = new HTTP\Request('HEAD', '/file1', ['Authorization' => 'Basic ' . base64_encode('user:pass')]);
+ $response = $this->request($request);
+
+ $this->assertEquals(200, $response->getStatus());
+
+ $this->assertEquals(1, $count, 'Auth was triggered twice :(');
+
+ }
+
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list