summaryrefslogtreecommitdiffstats
path: root/tests/lib/Authentication
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/Authentication
parent0e575c7eeadc6c8eb11b0be2ed1d39cdcf6cfcb8 (diff)
downloadnextcloud-server-b805908dca5cd4daf9f56bc140bbed48e067d573.tar.gz
nextcloud-server-b805908dca5cd4daf9f56bc140bbed48e067d573.zip
update session token password on user password change
Diffstat (limited to 'tests/lib/Authentication')
-rw-r--r--tests/lib/Authentication/Token/DefaultTokenProviderTest.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/lib/Authentication/Token/DefaultTokenProviderTest.php b/tests/lib/Authentication/Token/DefaultTokenProviderTest.php
index 98cee208065..d4117d877ea 100644
--- a/tests/lib/Authentication/Token/DefaultTokenProviderTest.php
+++ b/tests/lib/Authentication/Token/DefaultTokenProviderTest.php
@@ -175,6 +175,39 @@ class DefaultTokenProviderTest extends TestCase {
$tokenProvider->getPassword($tk, $token);
}
+ public function testSetPassword() {
+ $token = new DefaultToken();
+ $tokenId = 'token123';
+ $password = '123456';
+
+ $this->config->expects($this->once())
+ ->method('getSystemValue')
+ ->with('secret')
+ ->will($this->returnValue('ocsecret'));
+ $this->crypto->expects($this->once())
+ ->method('encrypt')
+ ->with($password, $tokenId . 'ocsecret')
+ ->will($this->returnValue('encryptedpassword'));
+ $this->mapper->expects($this->once())
+ ->method('update')
+ ->with($token);
+
+ $this->tokenProvider->setPassword($token, $tokenId, $password);
+
+ $this->assertEquals('encryptedpassword', $token->getPassword());
+ }
+
+ /**
+ * @expectedException \OC\Authentication\Exceptions\InvalidTokenException
+ */
+ public function testSetPasswordInvalidToken() {
+ $token = $this->getMock('\OC\Authentication\Token\IToken');
+ $tokenId = 'token123';
+ $password = '123456';
+
+ $this->tokenProvider->setPassword($token, $tokenId, $password);
+ }
+
public function testInvalidateToken() {
$this->mapper->expects($this->once())
->method('invalidate')