aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAV/Browser
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/Browser')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php10
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php14
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php154
3 files changed, 126 insertions, 52 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php
index 6fc65f9e8..157c2170a 100644
--- a/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php
@@ -10,6 +10,7 @@ class GuessContentTypeTest extends DAV\AbstractServer {
function setUp() {
parent::setUp();
+ \Sabre\TestUtil::clearTempDir();
file_put_contents(SABRE_TEMPDIR . '/somefile.jpg','blabla');
file_put_contents(SABRE_TEMPDIR . '/somefile.hoi','blabla');
@@ -17,7 +18,7 @@ class GuessContentTypeTest extends DAV\AbstractServer {
function tearDown() {
- unlink(SABRE_TEMPDIR . '/somefile.jpg');
+ \Sabre\TestUtil::clearTempDir();
parent::tearDown();
}
@@ -44,7 +45,7 @@ class GuessContentTypeTest extends DAV\AbstractServer {
);
$result = $this->server->getPropertiesForPath('/somefile.jpg',$properties);
$this->assertArrayHasKey(0,$result);
- $this->assertArrayHasKey(200,$result[0]);
+ $this->assertArrayHasKey(200,$result[0], 'We received: ' . print_r($result,true));
$this->assertArrayHasKey('{DAV:}getcontenttype',$result[0][200]);
$this->assertEquals('image/jpeg',$result[0][200]['{DAV:}getcontenttype']);
@@ -61,8 +62,9 @@ class GuessContentTypeTest extends DAV\AbstractServer {
);
$result = $this->server->getPropertiesForPath('/somefile.hoi',$properties);
$this->assertArrayHasKey(0,$result);
- $this->assertArrayHasKey(404,$result[0]);
- $this->assertArrayHasKey('{DAV:}getcontenttype',$result[0][404]);
+ $this->assertArrayHasKey(200,$result[0]);
+ $this->assertArrayHasKey('{DAV:}getcontenttype',$result[0][200]);
+ $this->assertEquals('application/octet-stream',$result[0][200]['{DAV:}getcontenttype']);
}
}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php
index 169675e7e..9d9fbb319 100644
--- a/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php
@@ -23,21 +23,21 @@ class MapGetToPropFindTest extends DAV\AbstractServer {
'REQUEST_METHOD' => 'GET',
);
- $request = new HTTP\Request($serverVars);
+ $request = HTTP\Sapi::createFromServerArray($serverVars);
$request->setBody('');
$this->server->httpRequest = ($request);
$this->server->exec();
+ $this->assertEquals(207, $this->response->status,'Incorrect status response received. Full response body: ' . $this->response->body);
$this->assertEquals(array(
- 'Content-Type' => 'application/xml; charset=utf-8',
- 'DAV' => '1, 3, extended-mkcol',
- 'Vary' => 'Brief,Prefer',
+ 'X-Sabre-Version' => [DAV\Version::VERSION],
+ 'Content-Type' => ['application/xml; charset=utf-8'],
+ 'DAV' => ['1, 3, extended-mkcol'],
+ 'Vary' => ['Brief,Prefer'],
),
- $this->response->headers
+ $this->response->getHeaders()
);
- $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'Incorrect status response received. Full response body: ' . $this->response->body);
-
}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php
index c3c4bdebb..00beea9f2 100644
--- a/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php
@@ -9,80 +9,114 @@ require_once 'Sabre/DAV/AbstractServer.php';
class PluginTest extends DAV\AbstractServer{
+ protected $plugin;
+
function setUp() {
parent::setUp();
- $this->server->addPlugin(new Plugin());
+ $this->server->addPlugin($this->plugin = new Plugin());
+ $this->server->tree->getNodeForPath('')->createDirectory('dir2');
}
function testCollectionGet() {
- $serverVars = array(
- 'REQUEST_URI' => '/dir',
- 'REQUEST_METHOD' => 'GET',
- );
-
- $request = new HTTP\Request($serverVars);
- $this->server->httpRequest = ($request);
+ $request = new HTTP\Request('GET', '/dir');
+ $this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
- $this->assertEquals(array(
- 'Content-Type' => 'text/html; charset=utf-8',
- ),
- $this->response->headers
+ $this->assertEquals(200, $this->response->getStatus(), "Incorrect status received. Full response body: " . $this->response->getBodyAsString());
+ $this->assertEquals(
+ [
+ 'X-Sabre-Version' => [DAV\Version::VERSION],
+ 'Content-Type' => ['text/html; charset=utf-8'],
+ 'Content-Security-Policy' => ["img-src 'self'; style-src 'self';"]
+ ],
+ $this->response->getHeaders()
);
- $this->assertTrue(strpos($this->response->body, 'Index for dir/') !== false);
- $this->assertTrue(strpos($this->response->body, '<a href="/dir/child.txt"><img src="/?sabreAction=asset&assetName=icons%2Ffile.png" alt="" width="24" />')!==false);
+ $body = $this->response->getBodyAsString();
+ $this->assertTrue(strpos($body, '<title>dir') !== false, $body);
+ $this->assertTrue(strpos($body, '<a href="/dir/child.txt">')!==false);
}
- function testNotFound() {
+ /**
+ * Adding the If-None-Match should have 0 effect, but it threw an error.
+ */
+ function testCollectionGetIfNoneMatch() {
- $serverVars = array(
- 'REQUEST_URI' => '/random',
- 'REQUEST_METHOD' => 'GET',
+ $request = new HTTP\Request('GET', '/dir');
+ $request->setHeader('If-None-Match', '"foo-bar"');
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals(200, $this->response->getStatus(), "Incorrect status received. Full response body: " . $this->response->getBodyAsString());
+ $this->assertEquals(
+ [
+ 'X-Sabre-Version' => [DAV\Version::VERSION],
+ 'Content-Type' => ['text/html; charset=utf-8'],
+ 'Content-Security-Policy' => ["img-src 'self'; style-src 'self';"]
+ ],
+ $this->response->getHeaders()
);
- $request = new HTTP\Request($serverVars);
+ $body = $this->response->getBodyAsString();
+ $this->assertTrue(strpos($body, '<title>dir') !== false, $body);
+ $this->assertTrue(strpos($body, '<a href="/dir/child.txt">')!==false);
+
+ }
+ function testCollectionGetRoot() {
+
+ $request = new HTTP\Request('GET', '/');
$this->server->httpRequest = ($request);
$this->server->exec();
- $this->assertEquals('HTTP/1.1 404 Not Found',$this->response->status);
+ $this->assertEquals(200, $this->response->status, "Incorrect status received. Full response body: " . $this->response->getBodyAsString());
+ $this->assertEquals(
+ [
+ 'X-Sabre-Version' => [DAV\Version::VERSION],
+ 'Content-Type' => ['text/html; charset=utf-8'],
+ 'Content-Security-Policy' => ["img-src 'self'; style-src 'self';"]
+ ],
+ $this->response->getHeaders()
+ );
+
+ $body = $this->response->getBodyAsString();
+ $this->assertTrue(strpos($body, '<title>/') !== false, $body);
+ $this->assertTrue(strpos($body, '<a href="/dir/">')!==false);
+ $this->assertTrue(strpos($body, '<span class="btn disabled">')!==false);
}
- function testPostOtherContentType() {
+ function testGETPassthru() {
- $serverVars = array(
- 'REQUEST_URI' => '/',
- 'REQUEST_METHOD' => 'POST',
- 'CONTENT_TYPE' => 'text/xml',
+ $request = new HTTP\Request('GET', '/random');
+ $response = new HTTP\Response();
+ $this->assertNull(
+ $this->plugin->httpGet($request, $response)
);
- $request = new HTTP\Request($serverVars);
+
+ }
+
+ function testPostOtherContentType() {
+
+ $request = new HTTP\Request('POST', '/', ['Content-Type' => 'text/xml']);
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 501 Not Implemented', $this->response->status);
+ $this->assertEquals(501, $this->response->status);
}
function testPostNoSabreAction() {
- $serverVars = array(
- 'REQUEST_URI' => '/',
- 'REQUEST_METHOD' => 'POST',
- 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
- );
- $postVars = array();
-
- $request = new HTTP\Request($serverVars,$postVars);
+ $request = new HTTP\Request('POST', '/', ['Content-Type' => 'application/x-www-form-urlencoded']);
+ $request->setPostData([]);
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 501 Not Implemented', $this->response->status);
+ $this->assertEquals(501, $this->response->status);
}
@@ -98,17 +132,55 @@ class PluginTest extends DAV\AbstractServer{
'name' => 'new_collection',
);
- $request = new HTTP\Request($serverVars,$postVars);
+ $request = HTTP\Sapi::createFromServerArray($serverVars);
+ $request->setPostData($postVars);
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 302 Found', $this->response->status);
+ $this->assertEquals(302, $this->response->status);
$this->assertEquals(array(
- 'Location' => '/',
- ), $this->response->headers);
+ 'X-Sabre-Version' => [DAV\Version::VERSION],
+ 'Location' => ['/'],
+ ), $this->response->getHeaders());
$this->assertTrue(is_dir(SABRE_TEMPDIR . '/new_collection'));
}
+ function testGetAsset() {
+
+ $request = new HTTP\Request('GET', '/?sabreAction=asset&assetName=favicon.ico');
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals(200, $this->response->getStatus(), 'Error: ' . $this->response->body);
+ $this->assertEquals([
+ 'X-Sabre-Version' => [DAV\Version::VERSION],
+ 'Content-Type' => ['image/vnd.microsoft.icon'],
+ 'Content-Length' => ['4286'],
+ 'Cache-Control' => ['public, max-age=1209600'],
+ 'Content-Security-Policy' => ["img-src 'self'; style-src 'self';"]
+ ], $this->response->getHeaders());
+
+ }
+
+ function testGetAsset404() {
+
+ $request = new HTTP\Request('GET', '/?sabreAction=asset&assetName=flavicon.ico');
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals(404, $this->response->getStatus(), 'Error: ' . $this->response->body);
+
+ }
+
+ function testGetAssetEscapeBasePath() {
+
+ $request = new HTTP\Request('GET', '/?sabreAction=asset&assetName=./../assets/favicon.ico');
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals(404, $this->response->getStatus(), 'Error: ' . $this->response->body);
+
+ }
}