diff options
author | Christoph Wurst <christoph@owncloud.com> | 2016-05-31 10:48:14 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@owncloud.com> | 2016-05-31 17:07:49 +0200 |
commit | c58d8159d7bdee93a67a917e16b750fe99df9f99 (patch) | |
tree | 568acfd8c2f26bd675a151bb42130a626468633b /tests | |
parent | 9a9c1b9439055fc6ad9f8372b354e4fc7ce3bc02 (diff) | |
download | nextcloud-server-c58d8159d7bdee93a67a917e16b750fe99df9f99.tar.gz nextcloud-server-c58d8159d7bdee93a67a917e16b750fe99df9f99.zip |
Create session tokens for apache auth users
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Authentication/Token/DefaultTokenProviderTest.php | 11 | ||||
-rw-r--r-- | tests/lib/User/SessionTest.php | 38 |
2 files changed, 49 insertions, 0 deletions
diff --git a/tests/lib/Authentication/Token/DefaultTokenProviderTest.php b/tests/lib/Authentication/Token/DefaultTokenProviderTest.php index e04424e4628..98cee208065 100644 --- a/tests/lib/Authentication/Token/DefaultTokenProviderTest.php +++ b/tests/lib/Authentication/Token/DefaultTokenProviderTest.php @@ -135,6 +135,17 @@ class DefaultTokenProviderTest extends TestCase { } /** + * @expectedException \OC\Authentication\Exceptions\PasswordlessTokenException + */ + public function testGetPasswordPasswordLessToken() { + $token = 'token1234'; + $tk = new DefaultToken(); + $tk->setPassword(null); + + $this->tokenProvider->getPassword($tk, $token); + } + + /** * @expectedException \OC\Authentication\Exceptions\InvalidTokenException */ public function testGetPasswordDeletesInvalidToken() { diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php index 5ff2a16acb9..36f14e85492 100644 --- a/tests/lib/User/SessionTest.php +++ b/tests/lib/User/SessionTest.php @@ -621,4 +621,42 @@ class SessionTest extends \Test\TestCase { $this->invokePrivate($userSession, 'validateSession', [$user]); } + public function testValidateSessionNoPassword() { + $userManager = $this->getMock('\OCP\IUserManager'); + $session = $this->getMock('\OCP\ISession'); + $timeFactory = $this->getMock('\OCP\AppFramework\Utility\ITimeFactory'); + $tokenProvider = $this->getMock('\OC\Authentication\Token\IProvider'); + $userSession = $this->getMockBuilder('\OC\User\Session') + ->setConstructorArgs([$userManager, $session, $timeFactory, $tokenProvider, $this->config]) + ->setMethods(['logout']) + ->getMock(); + + $user = $this->getMock('\OCP\IUser'); + $token = $this->getMock('\OC\Authentication\Token\IToken'); + + $session->expects($this->once()) + ->method('getId') + ->will($this->returnValue('sessionid')); + $tokenProvider->expects($this->once()) + ->method('getToken') + ->with('sessionid') + ->will($this->returnValue($token)); + $session->expects($this->once()) + ->method('get') + ->with('last_login_check') + ->will($this->returnValue(1000)); + $timeFactory->expects($this->once()) + ->method('getTime') + ->will($this->returnValue(5000)); + $tokenProvider->expects($this->once()) + ->method('getPassword') + ->with($token, 'sessionid') + ->will($this->throwException(new \OC\Authentication\Exceptions\PasswordlessTokenException())); + $session->expects($this->once()) + ->method('set') + ->with('last_login_check', 5000); + + $this->invokePrivate($userSession, 'validateSession', [$user]); + } + } |