diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-11-20 13:35:23 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-11-24 15:11:54 +0100 |
commit | ae36c01b959d1cbdaeabb46d30cb416aae428a88 (patch) | |
tree | 8a7e577b3565d20ab1a14896e6cf0bd05054e119 /apps/dav/tests/unit/connector/sabre/auth.php | |
parent | eacb24c1518ca80871447fbb500f093a0c280ee6 (diff) | |
download | nextcloud-server-ae36c01b959d1cbdaeabb46d30cb416aae428a88.tar.gz nextcloud-server-ae36c01b959d1cbdaeabb46d30cb416aae428a88.zip |
Adjust sabre changes in core
Diffstat (limited to 'apps/dav/tests/unit/connector/sabre/auth.php')
-rw-r--r-- | apps/dav/tests/unit/connector/sabre/auth.php | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/apps/dav/tests/unit/connector/sabre/auth.php b/apps/dav/tests/unit/connector/sabre/auth.php index 4c060ff04bb..595bd441617 100644 --- a/apps/dav/tests/unit/connector/sabre/auth.php +++ b/apps/dav/tests/unit/connector/sabre/auth.php @@ -249,9 +249,12 @@ class Auth extends TestCase { } public function testAuthenticateAlreadyLoggedIn() { - $server = $this->getMockBuilder('\Sabre\DAV\Server') - ->disableOriginalConstructor() - ->getMock(); + $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + ->disableOriginalConstructor() + ->getMock(); + $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + ->disableOriginalConstructor() + ->getMock(); $this->userSession ->expects($this->once()) ->method('isLoggedIn') @@ -275,13 +278,10 @@ class Auth extends TestCase { ->expects($this->once()) ->method('close'); - $this->assertTrue($this->auth->authenticate($server, 'TestRealm')); + $response = $this->auth->check($request, $response); + $this->assertEquals([true, 'principals/MyWrongDavUser'], $response); } - /** - * @expectedException \Sabre\DAV\Exception\NotAuthenticated - * @expectedExceptionMessage No basic authentication headers were found - */ public function testAuthenticateNoBasicAuthenticateHeadersProvided() { $server = $this->getMockBuilder('\Sabre\DAV\Server') ->disableOriginalConstructor() @@ -292,7 +292,8 @@ class Auth extends TestCase { $server->httpResponse = $this->getMockBuilder('\Sabre\HTTP\ResponseInterface') ->disableOriginalConstructor() ->getMock(); - $this->auth->authenticate($server, 'TestRealm'); + $response = $this->auth->check($server->httpRequest, $server->httpResponse); + $this->assertEquals([false, 'No \'Authorization: Basic\' header found. Either the client didn\'t send one, or the server is mis-configured'], $response); } /** @@ -300,21 +301,20 @@ class Auth extends TestCase { * @expectedExceptionMessage Cannot authenticate over ajax calls */ public function testAuthenticateNoBasicAuthenticateHeadersProvidedWithAjax() { - $server = $this->getMockBuilder('\Sabre\DAV\Server') + /** @var \Sabre\HTTP\RequestInterface $httpRequest */ + $httpRequest = $this->getMockBuilder('\Sabre\HTTP\RequestInterface') ->disableOriginalConstructor() ->getMock(); - $server->httpRequest = $this->getMockBuilder('\Sabre\HTTP\RequestInterface') + /** @var \Sabre\HTTP\ResponseInterface $httpResponse */ + $httpResponse = $this->getMockBuilder('\Sabre\HTTP\ResponseInterface') ->disableOriginalConstructor() ->getMock(); - $server->httpResponse = $this->getMockBuilder('\Sabre\HTTP\ResponseInterface') - ->disableOriginalConstructor() - ->getMock(); - $server->httpRequest + $httpRequest ->expects($this->once()) ->method('getHeader') ->with('X-Requested-With') ->will($this->returnValue('XMLHttpRequest')); - $this->auth->authenticate($server, 'TestRealm'); + $this->auth->check($httpRequest, $httpResponse); } public function testAuthenticateValidCredentials() { @@ -352,13 +352,10 @@ class Auth extends TestCase { ->expects($this->exactly(2)) ->method('getUser') ->will($this->returnValue($user)); - $this->assertTrue($this->auth->authenticate($server, 'TestRealm')); + $response = $this->auth->check($server->httpRequest, $server->httpResponse); + $this->assertEquals([true, 'principals/username'], $response); } - /** - * @expectedException \Sabre\DAV\Exception\NotAuthenticated - * @expectedExceptionMessage Username or password does not match - */ public function testAuthenticateInvalidCredentials() { $server = $this->getMockBuilder('\Sabre\DAV\Server') ->disableOriginalConstructor() @@ -384,6 +381,7 @@ class Auth extends TestCase { ->method('login') ->with('username', 'password') ->will($this->returnValue(false)); - $this->auth->authenticate($server, 'TestRealm'); + $response = $this->auth->check($server->httpRequest, $server->httpResponse); + $this->assertEquals([false, 'Username or password was incorrect'], $response); } } |