aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php90
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php134
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php42
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php72
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php38
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php81
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php10
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php10
8 files changed, 0 insertions, 477 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php
deleted file mode 100644
index ebc1e3f7b..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAV\Auth\Backend;
-
-use Sabre\HTTP;
-
-class AbstractBasicTest extends \PHPUnit\Framework\TestCase
-{
- public function testCheckNoHeaders()
- {
- $request = new HTTP\Request('GET', '/');
- $response = new HTTP\Response();
-
- $backend = new AbstractBasicMock();
-
- $this->assertFalse(
- $backend->check($request, $response)[0]
- );
- }
-
- public function testCheckUnknownUser()
- {
- $request = HTTP\Sapi::createFromServerArray([
- 'REQUEST_METHOD' => 'GET',
- 'REQUEST_URI' => '/',
- 'PHP_AUTH_USER' => 'username',
- 'PHP_AUTH_PW' => 'wrongpassword',
- ]);
- $response = new HTTP\Response();
-
- $backend = new AbstractBasicMock();
-
- $this->assertFalse(
- $backend->check($request, $response)[0]
- );
- }
-
- public function testCheckSuccess()
- {
- $request = HTTP\Sapi::createFromServerArray([
- 'REQUEST_METHOD' => 'GET',
- 'REQUEST_URI' => '/',
- 'PHP_AUTH_USER' => 'username',
- 'PHP_AUTH_PW' => 'password',
- ]);
- $response = new HTTP\Response();
-
- $backend = new AbstractBasicMock();
- $this->assertEquals(
- [true, 'principals/username'],
- $backend->check($request, $response)
- );
- }
-
- public function testRequireAuth()
- {
- $request = new HTTP\Request('GET', '/');
- $response = new HTTP\Response();
-
- $backend = new AbstractBasicMock();
- $backend->setRealm('writing unittests on a saturday night');
- $backend->challenge($request, $response);
-
- $this->assertEquals(
- 'Basic realm="writing unittests on a saturday night", charset="UTF-8"',
- $response->getHeader('WWW-Authenticate')
- );
- }
-}
-
-class AbstractBasicMock extends AbstractBasic
-{
- /**
- * Validates a username and password.
- *
- * This method should return true or false depending on if login
- * succeeded.
- *
- * @param string $username
- * @param string $password
- *
- * @return bool
- */
- public function validateUserPass($username, $password)
- {
- return 'username' == $username && 'password' == $password;
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php
deleted file mode 100644
index a751efdc2..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php
+++ /dev/null
@@ -1,134 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAV\Auth\Backend;
-
-use Sabre\HTTP;
-
-class AbstractDigestTest extends \PHPUnit\Framework\TestCase
-{
- public function testCheckNoHeaders()
- {
- $request = new HTTP\Request('GET', '/');
- $response = new HTTP\Response();
-
- $backend = new AbstractDigestMock();
- $this->assertFalse(
- $backend->check($request, $response)[0]
- );
- }
-
- public function testCheckBadGetUserInfoResponse()
- {
- $header = 'username=null, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1';
- $request = HTTP\Sapi::createFromServerArray([
- 'REQUEST_METHOD' => 'GET',
- 'REQUEST_URI' => '/',
- 'PHP_AUTH_DIGEST' => $header,
- ]);
- $response = new HTTP\Response();
-
- $backend = new AbstractDigestMock();
- $this->assertFalse(
- $backend->check($request, $response)[0]
- );
- }
-
- public function testCheckBadGetUserInfoResponse2()
- {
- $this->expectException('Sabre\DAV\Exception');
- $header = 'username=array, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1';
- $request = HTTP\Sapi::createFromServerArray([
- 'REQUEST_METHOD' => 'GET',
- 'REQUEST_URI' => '/',
- 'PHP_AUTH_DIGEST' => $header,
- ]);
-
- $response = new HTTP\Response();
-
- $backend = new AbstractDigestMock();
- $backend->check($request, $response);
- }
-
- public function testCheckUnknownUser()
- {
- $header = 'username=false, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1';
- $request = HTTP\Sapi::createFromServerArray([
- 'REQUEST_METHOD' => 'GET',
- 'REQUEST_URI' => '/',
- 'PHP_AUTH_DIGEST' => $header,
- ]);
-
- $response = new HTTP\Response();
-
- $backend = new AbstractDigestMock();
- $this->assertFalse(
- $backend->check($request, $response)[0]
- );
- }
-
- public function testCheckBadPassword()
- {
- $header = 'username=user, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1';
- $request = HTTP\Sapi::createFromServerArray([
- 'REQUEST_METHOD' => 'PUT',
- 'REQUEST_URI' => '/',
- 'PHP_AUTH_DIGEST' => $header,
- ]);
-
- $response = new HTTP\Response();
-
- $backend = new AbstractDigestMock();
- $this->assertFalse(
- $backend->check($request, $response)[0]
- );
- }
-
- public function testCheck()
- {
- $digestHash = md5('HELLO:12345:1:1:auth:'.md5('GET:/'));
- $header = 'username=user, realm=myRealm, nonce=12345, uri=/, response='.$digestHash.', opaque=1, qop=auth, nc=1, cnonce=1';
- $request = HTTP\Sapi::createFromServerArray([
- 'REQUEST_METHOD' => 'GET',
- 'REQUEST_URI' => '/',
- 'PHP_AUTH_DIGEST' => $header,
- ]);
-
- $response = new HTTP\Response();
-
- $backend = new AbstractDigestMock();
- $this->assertEquals(
- [true, 'principals/user'],
- $backend->check($request, $response)
- );
- }
-
- public function testRequireAuth()
- {
- $request = new HTTP\Request('GET', '/');
- $response = new HTTP\Response();
-
- $backend = new AbstractDigestMock();
- $backend->setRealm('writing unittests on a saturday night');
- $backend->challenge($request, $response);
-
- $this->assertStringStartsWith(
- 'Digest realm="writing unittests on a saturday night"',
- $response->getHeader('WWW-Authenticate')
- );
- }
-}
-
-class AbstractDigestMock extends AbstractDigest
-{
- public function getDigestHash($realm, $userName)
- {
- switch ($userName) {
- case 'null': return null;
- case 'false': return false;
- case 'array': return [];
- case 'user': return 'HELLO';
- }
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php
deleted file mode 100644
index 8b874f884..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAV\Auth\Backend;
-
-abstract class AbstractPDOTest extends \PHPUnit\Framework\TestCase
-{
- use \Sabre\DAV\DbTestHelperTrait;
-
- public function setup(): void
- {
- $this->dropTables('users');
- $this->createSchema('users');
-
- $this->getPDO()->query(
- "INSERT INTO users (username,digesta1) VALUES ('user','hash')"
- );
- }
-
- public function testConstruct()
- {
- $pdo = $this->getPDO();
- $backend = new PDO($pdo);
- $this->assertTrue($backend instanceof PDO);
- }
-
- /**
- * @depends testConstruct
- */
- public function testUserInfo()
- {
- $pdo = $this->getPDO();
- $backend = new PDO($pdo);
-
- $this->assertNull($backend->getDigestHash('realm', 'blabla'));
-
- $expected = 'hash';
-
- $this->assertEquals($expected, $backend->getDigestHash('realm', 'user'));
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php
deleted file mode 100644
index a0086518f..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAV\Auth\Backend;
-
-use Sabre\HTTP;
-
-class ApacheTest extends \PHPUnit\Framework\TestCase
-{
- public function testConstruct()
- {
- $backend = new Apache();
- $this->assertInstanceOf('Sabre\DAV\Auth\Backend\Apache', $backend);
- }
-
- public function testNoHeader()
- {
- $request = new HTTP\Request('GET', '/');
- $response = new HTTP\Response();
- $backend = new Apache();
-
- $this->assertFalse(
- $backend->check($request, $response)[0]
- );
- }
-
- public function testRemoteUser()
- {
- $request = HTTP\Sapi::createFromServerArray([
- 'REQUEST_METHOD' => 'GET',
- 'REQUEST_URI' => '/',
- 'REMOTE_USER' => 'username',
- ]);
- $response = new HTTP\Response();
- $backend = new Apache();
-
- $this->assertEquals(
- [true, 'principals/username'],
- $backend->check($request, $response)
- );
- }
-
- public function testRedirectRemoteUser()
- {
- $request = HTTP\Sapi::createFromServerArray([
- 'REQUEST_METHOD' => 'GET',
- 'REQUEST_URI' => '/',
- 'REDIRECT_REMOTE_USER' => 'username',
- ]);
- $response = new HTTP\Response();
- $backend = new Apache();
-
- $this->assertEquals(
- [true, 'principals/username'],
- $backend->check($request, $response)
- );
- }
-
- public function testRequireAuth()
- {
- $request = new HTTP\Request('GET', '/');
- $response = new HTTP\Response();
-
- $backend = new Apache();
- $backend->challenge($request, $response);
-
- $this->assertNull(
- $response->getHeader('WWW-Authenticate')
- );
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php
deleted file mode 100644
index 31a86f9ed..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAV\Auth\Backend;
-
-class FileTest extends \PHPUnit\Framework\TestCase
-{
- public function teardown(): void
- {
- if (file_exists(SABRE_TEMPDIR.'/filebackend')) {
- unlink(SABRE_TEMPDIR.'/filebackend');
- }
- }
-
- public function testConstruct()
- {
- $file = new File();
- $this->assertTrue($file instanceof File);
- }
-
- public function testLoadFileBroken()
- {
- $this->expectException('Sabre\DAV\Exception');
- file_put_contents(SABRE_TEMPDIR.'/backend', 'user:realm:hash');
- $file = new File(SABRE_TEMPDIR.'/backend');
- }
-
- public function testLoadFile()
- {
- file_put_contents(SABRE_TEMPDIR.'/backend', 'user:realm:'.md5('user:realm:password'));
- $file = new File();
- $file->loadFile(SABRE_TEMPDIR.'/backend');
-
- $this->assertFalse($file->getDigestHash('realm', 'blabla'));
- $this->assertEquals(md5('user:realm:password'), $file->getDigestHash('realm', 'user'));
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php
deleted file mode 100644
index fca7f722f..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAV\Auth\Backend;
-
-use Sabre\HTTP\RequestInterface;
-use Sabre\HTTP\ResponseInterface;
-
-class Mock implements BackendInterface
-{
- public $fail = false;
-
- public $invalidCheckResponse = false;
-
- public $principal = 'principals/admin';
-
- public function setPrincipal($principal)
- {
- $this->principal = $principal;
- }
-
- /**
- * When this method is called, the backend must check if authentication was
- * successful.
- *
- * The returned value must be one of the following
- *
- * [true, "principals/username"]
- * [false, "reason for failure"]
- *
- * If authentication was successful, it's expected that the authentication
- * backend returns a so-called principal url.
- *
- * Examples of a principal url:
- *
- * principals/admin
- * principals/user1
- * principals/users/joe
- * principals/uid/123457
- *
- * If you don't use WebDAV ACL (RFC3744) we recommend that you simply
- * return a string such as:
- *
- * principals/users/[username]
- *
- * @return array
- */
- public function check(RequestInterface $request, ResponseInterface $response)
- {
- if ($this->invalidCheckResponse) {
- return 'incorrect!';
- }
- if ($this->fail) {
- return [false, 'fail!'];
- }
-
- return [true, $this->principal];
- }
-
- /**
- * This method is called when a user could not be authenticated, and
- * authentication was required for the current request.
- *
- * This gives you the oppurtunity to set authentication headers. The 401
- * status code will already be set.
- *
- * In this case of Basic Auth, this would for example mean that the
- * following header needs to be set:
- *
- * $response->addHeader('WWW-Authenticate', 'Basic realm=SabreDAV');
- *
- * Keep in mind that in the case of multiple authentication backends, other
- * WWW-Authenticate headers may already have been set, and you'll want to
- * append your own WWW-Authenticate header instead of overwriting the
- * existing one.
- */
- public function challenge(RequestInterface $request, ResponseInterface $response)
- {
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php
deleted file mode 100644
index 6ad7906c4..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAV\Auth\Backend;
-
-class PDOMySQLTest extends AbstractPDOTest
-{
- public $driver = 'mysql';
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php
deleted file mode 100644
index b42b40eff..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAV\Auth\Backend;
-
-class PDOSqliteTest extends AbstractPDOTest
-{
- public $driver = 'sqlite';
-}