diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2020-04-14 11:37:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-14 11:37:44 +0200 |
commit | 34fc46251fe6a16d36040aed05833a8fb4d80520 (patch) | |
tree | 1e1ec5f75aeba9434c1d593ee85bd23545c2457c /apps/dav/tests/unit | |
parent | 734c1a4649862290868dd5a60b759086006450cc (diff) | |
parent | ce8f194a2a77a5f5cad62d9de4da033a67b4c927 (diff) | |
download | nextcloud-server-34fc46251fe6a16d36040aed05833a8fb4d80520.tar.gz nextcloud-server-34fc46251fe6a16d36040aed05833a8fb4d80520.zip |
Merge pull request #20282 from nextcloud/backport/19180/stable18
[stable18] Check for empty authorization headers for office requests
Diffstat (limited to 'apps/dav/tests/unit')
-rw-r--r-- | apps/dav/tests/unit/DAV/AnonymousOptionsTest.php | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/apps/dav/tests/unit/DAV/AnonymousOptionsTest.php b/apps/dav/tests/unit/DAV/AnonymousOptionsTest.php index a0abac0712a..a61c8e1e550 100644 --- a/apps/dav/tests/unit/DAV/AnonymousOptionsTest.php +++ b/apps/dav/tests/unit/DAV/AnonymousOptionsTest.php @@ -33,7 +33,7 @@ use Sabre\HTTP\Sapi; use Test\TestCase; class AnonymousOptionsTest extends TestCase { - private function sendRequest($method, $path) { + private function sendRequest($method, $path, $userAgent = '') { $server = new Server(); $server->addPlugin(new AnonymousOptionsPlugin()); $server->addPlugin(new Plugin(new BasicCallBack(function() { @@ -42,6 +42,7 @@ class AnonymousOptionsTest extends TestCase { $server->httpRequest->setMethod($method); $server->httpRequest->setUrl($path); + $server->httpRequest->setHeader('User-Agent', $userAgent); $server->sapi = new SapiMock(); $server->exec(); @@ -63,7 +64,19 @@ class AnonymousOptionsTest extends TestCase { public function testAnonymousOptionsNonRootSubDir() { $response = $this->sendRequest('OPTIONS', 'foo/bar'); - $this->assertEquals(401, $response->getStatus()); + $this->assertEquals(200, $response->getStatus()); + } + + public function testAnonymousHead() { + $response = $this->sendRequest('HEAD', '', 'Microsoft Office does strange things'); + + $this->assertEquals(200, $response->getStatus()); + } + + public function testAnonymousHeadNoOffice() { + $response = $this->sendRequest('HEAD', ''); + + $this->assertEquals(401, $response->getStatus(), 'curl'); } } |