diff options
author | Christoph Wurst <christoph@owncloud.com> | 2016-06-21 10:23:50 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@owncloud.com> | 2016-06-21 10:24:25 +0200 |
commit | b805908dca5cd4daf9f56bc140bbed48e067d573 (patch) | |
tree | 9c9bee8639d269b80985621c873163b5803a6a8b /tests/lib/Authentication | |
parent | 0e575c7eeadc6c8eb11b0be2ed1d39cdcf6cfcb8 (diff) | |
download | nextcloud-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.php | 33 |
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') |