From 66effbfe0827fc61fff6d248797a894213ad20d6 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 28 May 2016 17:46:24 +0200 Subject: upgrade to sabre32 --- .../Sabre/DAV/Auth/Backend/AbstractBasicTest.php | 13 +++++----- .../Sabre/DAV/Auth/Backend/AbstractDigestTest.php | 11 ++++---- .../Sabre/DAV/Auth/Backend/AbstractPDOTest.php | 20 +++++++++++---- .../tests/Sabre/DAV/Auth/Backend/ApacheTest.php | 1 - .../dav/tests/Sabre/DAV/Auth/Backend/FileTest.php | 12 ++++----- .../dav/tests/Sabre/DAV/Auth/Backend/Mock.php | 6 ++--- .../tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php | 26 +------------------ .../tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php | 23 ++--------------- .../sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php | 30 +++++----------------- 9 files changed, 44 insertions(+), 98 deletions(-) (limited to 'vendor/sabre/dav/tests/Sabre/DAV/Auth') diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php index 7d7a59898..455403aff 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php @@ -2,7 +2,6 @@ namespace Sabre\DAV\Auth\Backend; -use Sabre\DAV; use Sabre\HTTP; class AbstractBasicTest extends \PHPUnit_Framework_TestCase { @@ -22,10 +21,10 @@ class AbstractBasicTest extends \PHPUnit_Framework_TestCase { function testCheckUnknownUser() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'PHP_AUTH_USER' => 'username', - 'PHP_AUTH_PW' => 'wrongpassword', - )); + 'PHP_AUTH_PW' => 'wrongpassword', + ]); $response = new HTTP\Response(); $backend = new AbstractBasicMock(); @@ -38,10 +37,10 @@ class AbstractBasicTest extends \PHPUnit_Framework_TestCase { function testCheckSuccess() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'PHP_AUTH_USER' => 'username', - 'PHP_AUTH_PW' => 'password', - )); + 'PHP_AUTH_PW' => 'password', + ]); $response = new HTTP\Response(); $backend = new AbstractBasicMock(); diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php index 8ef416c37..14c72aaa0 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php @@ -2,7 +2,6 @@ namespace Sabre\DAV\Auth\Backend; -use Sabre\DAV; use Sabre\HTTP; class AbstractDigestTest extends \PHPUnit_Framework_TestCase { @@ -87,12 +86,12 @@ class AbstractDigestTest extends \PHPUnit_Framework_TestCase { 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(array( + $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', 'PHP_AUTH_DIGEST' => $header, 'REQUEST_URI' => '/', - )); + ]); $response = new HTTP\Response(); @@ -127,10 +126,10 @@ class AbstractDigestMock extends AbstractDigest { function getDigestHash($realm, $userName) { - switch($userName) { + switch ($userName) { case 'null' : return null; case 'false' : return false; - case 'array' : return array(); + 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 index d22923d51..b14e9fa2e 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php @@ -2,11 +2,21 @@ namespace Sabre\DAV\Auth\Backend; -use Sabre\DAV; - abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { - abstract function getPDO(); + use \Sabre\DAV\DbTestHelperTrait; + + function setUp() { + + $this->dropTables('users'); + $this->createSchema('users'); + + $this->getPDO()->query( + "INSERT INTO users (username,digesta1) VALUES ('user','hash')" + + ); + + } function testConstruct() { @@ -24,11 +34,11 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $pdo = $this->getPDO(); $backend = new PDO($pdo); - $this->assertNull($backend->getDigestHash('realm','blabla')); + $this->assertNull($backend->getDigestHash('realm', 'blabla')); $expected = 'hash'; - $this->assertEquals($expected, $backend->getDigestHash('realm','user')); + $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 index 697b593db..29cbc2162 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php @@ -2,7 +2,6 @@ namespace Sabre\DAV\Auth\Backend; -use Sabre\DAV; use Sabre\HTTP; class ApacheTest extends \PHPUnit_Framework_TestCase { diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php index d2e5fe49b..9b66d642f 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php @@ -6,7 +6,7 @@ class FileTest extends \PHPUnit_Framework_TestCase { function tearDown() { - if (file_exists(SABRE_TEMPDIR . '/filebackend')) unlink(SABRE_TEMPDIR .'/filebackend'); + if (file_exists(SABRE_TEMPDIR . '/filebackend')) unlink(SABRE_TEMPDIR . '/filebackend'); } @@ -22,20 +22,20 @@ class FileTest extends \PHPUnit_Framework_TestCase { */ function testLoadFileBroken() { - file_put_contents(SABRE_TEMPDIR . '/backend','user:realm:hash'); + file_put_contents(SABRE_TEMPDIR . '/backend', 'user:realm:hash'); $file = new File(); - $file->loadFile(SABRE_TEMPDIR .'/backend'); + $file->loadFile(SABRE_TEMPDIR . '/backend'); } function testLoadFile() { - file_put_contents(SABRE_TEMPDIR . '/backend','user:realm:' . md5('user:realm:password')); + 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')); + $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 index a782cb74d..b30b3f143 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php @@ -2,10 +2,8 @@ namespace Sabre\DAV\Auth\Backend; -use - Sabre\DAV, - Sabre\HTTP\RequestInterface, - Sabre\HTTP\ResponseInterface; +use Sabre\HTTP\RequestInterface; +use Sabre\HTTP\ResponseInterface; class Mock implements BackendInterface { diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php index 8de2be667..18f59793a 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php @@ -2,32 +2,8 @@ namespace Sabre\DAV\Auth\Backend; -require_once 'Sabre/TestUtil.php'; - class PDOMySQLTest extends AbstractPDOTest { - function getPDO() { - - if (!SABRE_HASMYSQL) $this->markTestSkipped('MySQL driver is not available, or not properly configured'); - $pdo = \Sabre\TestUtil::getMySQLDB(); - if (!$pdo) $this->markTestSkipped('Could not connect to MySQL database'); - $pdo->query("DROP TABLE IF EXISTS users"); - $pdo->query(<<query("INSERT INTO users (username,digesta1,email,displayname) VALUES ('user','hash','user@example.org','User')"); - - return $pdo; - - } + 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 index abfb031bb..b1f382237 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php @@ -2,27 +2,8 @@ namespace Sabre\DAV\Auth\Backend; -require_once 'Sabre/DAV/Auth/Backend/AbstractPDOTest.php'; +class PDOSqliteTest extends AbstractPDOTest { -class PDOSQLiteTest extends AbstractPDOTest { - - function tearDown() { - - if (file_exists(SABRE_TEMPDIR . '/pdobackend')) unlink(SABRE_TEMPDIR . '/pdobackend'); - if (file_exists(SABRE_TEMPDIR . '/pdobackend2')) unlink(SABRE_TEMPDIR . '/pdobackend2'); - - } - - function getPDO() { - - if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available'); - $pdo = new \PDO('sqlite:'.SABRE_TEMPDIR.'/pdobackend'); - $pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION); - $pdo->query('CREATE TABLE users (username TEXT, digesta1 TEXT, email VARCHAR(80), displayname VARCHAR(80))'); - $pdo->query('INSERT INTO users VALUES ("user","hash","user@example.org","User")'); - - return $pdo; - - } + public $driver = 'sqlite'; } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php index 0ac9e0613..3ed79a7da 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php @@ -5,13 +5,11 @@ namespace Sabre\DAV\Auth; use Sabre\HTTP; use Sabre\DAV; -require_once 'Sabre/HTTP/ResponseMock.php'; - class PluginTest extends \PHPUnit_Framework_TestCase { function testInit() { - $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); + $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(new Backend\Mock()); $this->assertTrue($plugin instanceof Plugin); $fakeServer->addPlugin($plugin); @@ -25,7 +23,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase { */ function testAuthenticate() { - $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); + $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(new Backend\Mock()); $fakeServer->addPlugin($plugin); $this->assertTrue( @@ -40,7 +38,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase { */ function testAuthenticateFail() { - $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); + $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $backend = new Backend\Mock(); $backend->fail = true; @@ -55,7 +53,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase { */ function testMultipleBackend() { - $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); + $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $backend1 = new Backend\Mock(); $backend2 = new Backend\Mock(); $backend2->fail = true; @@ -77,7 +75,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase { */ function testNoAuthBackend() { - $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); + $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(); $fakeServer->addPlugin($plugin); @@ -90,7 +88,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase { */ function testInvalidCheckResponse() { - $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); + $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $backend = new Backend\Mock(); $backend->invalidCheckResponse = true; @@ -105,7 +103,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase { */ function testGetCurrentPrincipal() { - $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); + $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(new Backend\Mock()); $fakeServer->addPlugin($plugin); $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); @@ -113,18 +111,4 @@ class PluginTest extends \PHPUnit_Framework_TestCase { } - /** - * @depends testAuthenticate - */ - function testGetCurrentUser() { - - $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); - $plugin = new Plugin(new Backend\Mock()); - $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); - $this->assertEquals('admin', $plugin->getCurrentUser()); - - } - } - -- cgit v1.2.3 From dcc65bbacb81801b5e138795c18ef9e740dbd26c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 28 Jun 2016 21:45:14 +0200 Subject: update to sabre/dav to version 3.2.0 --- .../dav/tests/Sabre/DAV/Auth/Backend/FileTest.php | 3 +-- vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'vendor/sabre/dav/tests/Sabre/DAV/Auth') diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php index 9b66d642f..f694f4806 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php @@ -23,8 +23,7 @@ class FileTest extends \PHPUnit_Framework_TestCase { function testLoadFileBroken() { file_put_contents(SABRE_TEMPDIR . '/backend', 'user:realm:hash'); - $file = new File(); - $file->loadFile(SABRE_TEMPDIR . '/backend'); + $file = new File(SABRE_TEMPDIR . '/backend'); } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php index 3ed79a7da..b566dd757 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php @@ -48,6 +48,25 @@ class PluginTest extends \PHPUnit_Framework_TestCase { } + /** + * @depends testAuthenticateFail + */ + function testAuthenticateFailDontAutoRequire() { + + $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); + $backend = new Backend\Mock(); + $backend->fail = true; + + $plugin = new Plugin($backend); + $plugin->autoRequireLogin = false; + $fakeServer->addPlugin($plugin); + $this->assertTrue( + $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]) + ); + $this->assertEquals(1, count($plugin->getLoginFailedReasons())); + + } + /** * @depends testAuthenticate */ -- cgit v1.2.3