diff options
author | Andrew Manning <tamanning@zoho.com> | 2016-05-11 05:54:20 -0400 |
---|---|---|
committer | Andrew Manning <tamanning@zoho.com> | 2016-05-11 05:54:20 -0400 |
commit | d968fc51eab8b0fb259ecbeae517056b99554017 (patch) | |
tree | 10e551cff9fefbefbfd7e5031b57320116bb7fce /vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php | |
parent | c7698e4dc388b7d9a9db368672cb057c1d4d3a01 (diff) | |
parent | 4dd3839c41e18d9724855e7955d8737b6f52dcd6 (diff) | |
download | volse-hubzilla-d968fc51eab8b0fb259ecbeae517056b99554017.tar.gz volse-hubzilla-d968fc51eab8b0fb259ecbeae517056b99554017.tar.bz2 volse-hubzilla-d968fc51eab8b0fb259ecbeae517056b99554017.zip |
Merge remote-tracking branch 'upstream/dev' into plugin-repo
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php')
-rw-r--r-- | vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php | 94 |
1 files changed, 70 insertions, 24 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php index 2096a04d7..0ac9e0613 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php @@ -12,10 +12,11 @@ class PluginTest extends \PHPUnit_Framework_TestCase { function testInit() { $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); - $plugin = new Plugin(new Backend\Mock(),'realm'); + $plugin = new Plugin(new Backend\Mock()); $this->assertTrue($plugin instanceof Plugin); $fakeServer->addPlugin($plugin); $this->assertEquals($plugin, $fakeServer->getPlugin('auth')); + $this->assertInternalType('array', $plugin->getPluginInfo()); } @@ -25,14 +26,14 @@ class PluginTest extends \PHPUnit_Framework_TestCase { function testAuthenticate() { $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); - $plugin = new Plugin(new Backend\Mock(),'realm'); + $plugin = new Plugin(new Backend\Mock()); $fakeServer->addPlugin($plugin); - $fakeServer->broadCastEvent('beforeMethod',array('GET','/')); + $this->assertTrue( + $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]) + ); } - - /** * @depends testInit * @expectedException Sabre\DAV\Exception\NotAuthenticated @@ -40,42 +41,87 @@ class PluginTest extends \PHPUnit_Framework_TestCase { function testAuthenticateFail() { $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); - $plugin = new Plugin(new Backend\Mock(),'failme'); + $backend = new Backend\Mock(); + $backend->fail = true; + + $plugin = new Plugin($backend); $fakeServer->addPlugin($plugin); - $fakeServer->broadCastEvent('beforeMethod',array('GET','/')); + $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); } - function testReportPassThrough() { + /** + * @depends testAuthenticate + */ + function testMultipleBackend() { - $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); - $plugin = new Plugin(new Backend\Mock(),'realm'); - $fakeServer->addPlugin($plugin); + $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); + $backend1 = new Backend\Mock(); + $backend2 = new Backend\Mock(); + $backend2->fail = true; - $request = new HTTP\Request(array( - 'REQUEST_METHOD' => 'REPORT', - 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/', - )); - $request->setBody('<?xml version="1.0"?><s:somereport xmlns:s="http://www.rooftopsolutions.nl/NS/example" />'); + $plugin = new Plugin(); + $plugin->addBackend($backend1); + $plugin->addBackend($backend2); - $fakeServer->httpRequest = $request; - $fakeServer->httpResponse = new HTTP\ResponseMock(); - $fakeServer->exec(); + $fakeServer->addPlugin($plugin); + $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); - $this->assertEquals('HTTP/1.1 403 Forbidden', $fakeServer->httpResponse->status); + $this->assertEquals('principals/admin', $plugin->getCurrentPrincipal()); } /** * @depends testInit + * @expectedException Sabre\DAV\Exception + */ + function testNoAuthBackend() { + + $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); + + $plugin = new Plugin(); + $fakeServer->addPlugin($plugin); + $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); + + } + /** + * @depends testInit + * @expectedException Sabre\DAV\Exception + */ + function testInvalidCheckResponse() { + + $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); + $backend = new Backend\Mock(); + $backend->invalidCheckResponse = true; + + $plugin = new Plugin($backend); + $fakeServer->addPlugin($plugin); + $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); + + } + + /** + * @depends testAuthenticate + */ + function testGetCurrentPrincipal() { + + $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('principals/admin', $plugin->getCurrentPrincipal()); + + } + + /** + * @depends testAuthenticate */ - function testGetCurrentUserPrincipal() { + function testGetCurrentUser() { $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); - $plugin = new Plugin(new Backend\Mock(),'realm'); + $plugin = new Plugin(new Backend\Mock()); $fakeServer->addPlugin($plugin); - $fakeServer->broadCastEvent('beforeMethod',array('GET','/')); + $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); $this->assertEquals('admin', $plugin->getCurrentUser()); } |