aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php94
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());
}