summaryrefslogtreecommitdiffstats
path: root/tests/lib/User
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@owncloud.com>2016-06-21 10:23:50 +0200
committerChristoph Wurst <christoph@owncloud.com>2016-06-21 10:24:25 +0200
commitb805908dca5cd4daf9f56bc140bbed48e067d573 (patch)
tree9c9bee8639d269b80985621c873163b5803a6a8b /tests/lib/User
parent0e575c7eeadc6c8eb11b0be2ed1d39cdcf6cfcb8 (diff)
downloadnextcloud-server-b805908dca5cd4daf9f56bc140bbed48e067d573.tar.gz
nextcloud-server-b805908dca5cd4daf9f56bc140bbed48e067d573.zip
update session token password on user password change
Diffstat (limited to 'tests/lib/User')
-rw-r--r--tests/lib/User/SessionTest.php65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php
index 7a34d42a2bc..4dcdc7c1348 100644
--- a/tests/lib/User/SessionTest.php
+++ b/tests/lib/User/SessionTest.php
@@ -818,4 +818,69 @@ class SessionTest extends \Test\TestCase {
$this->invokePrivate($userSession, 'validateSession', [$user]);
}
+ public function testUpdateSessionTokenPassword() {
+ $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 = new \OC\User\Session($userManager, $session, $timeFactory, $tokenProvider, $this->config);
+
+ $password = '123456';
+ $sessionId ='session1234';
+ $token = new \OC\Authentication\Token\DefaultToken();
+
+ $session->expects($this->once())
+ ->method('getId')
+ ->will($this->returnValue($sessionId));
+ $tokenProvider->expects($this->once())
+ ->method('getToken')
+ ->with($sessionId)
+ ->will($this->returnValue($token));
+ $tokenProvider->expects($this->once())
+ ->method('setPassword')
+ ->with($token, $sessionId, $password);
+
+ $userSession->updateSessionTokenPassword($password);
+ }
+
+ public function testUpdateSessionTokenPasswordNoSessionAvailable() {
+ $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 = new \OC\User\Session($userManager, $session, $timeFactory, $tokenProvider, $this->config);
+
+ $session->expects($this->once())
+ ->method('getId')
+ ->will($this->throwException(new \OCP\Session\Exceptions\SessionNotAvailableException()));
+
+ $userSession->updateSessionTokenPassword('1234');
+ }
+
+ public function testUpdateSessionTokenPasswordInvalidTokenException() {
+ $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 = new \OC\User\Session($userManager, $session, $timeFactory, $tokenProvider, $this->config);
+
+ $password = '123456';
+ $sessionId ='session1234';
+ $token = new \OC\Authentication\Token\DefaultToken();
+
+ $session->expects($this->once())
+ ->method('getId')
+ ->will($this->returnValue($sessionId));
+ $tokenProvider->expects($this->once())
+ ->method('getToken')
+ ->with($sessionId)
+ ->will($this->returnValue($token));
+ $tokenProvider->expects($this->once())
+ ->method('setPassword')
+ ->with($token, $sessionId, $password)
+ ->will($this->throwException(new \OC\Authentication\Exceptions\InvalidTokenException()));
+
+ $userSession->updateSessionTokenPassword($password);
+ }
+
}