summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-05-29 12:18:10 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2018-06-18 22:11:55 +0200
commit4bbc21cb216c51ab22f31089c9c09a3dec8980dc (patch)
tree5f2322a324a87bea1f8586e0789d602f99773c94 /tests/lib
parent4c0d7104792cb89b8bc013c08b9c9fcb63dcf0da (diff)
downloadnextcloud-server-4bbc21cb216c51ab22f31089c9c09a3dec8980dc.tar.gz
nextcloud-server-4bbc21cb216c51ab22f31089c9c09a3dec8980dc.zip
SetPassword on PublicKeyTokens
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/Authentication/Token/DefaultTokenProviderTest.php10
-rw-r--r--tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php21
2 files changed, 19 insertions, 12 deletions
diff --git a/tests/lib/Authentication/Token/DefaultTokenProviderTest.php b/tests/lib/Authentication/Token/DefaultTokenProviderTest.php
index 95b5b928559..58e152457fc 100644
--- a/tests/lib/Authentication/Token/DefaultTokenProviderTest.php
+++ b/tests/lib/Authentication/Token/DefaultTokenProviderTest.php
@@ -132,13 +132,12 @@ class DefaultTokenProviderTest extends TestCase {
}
public function testGetTokenByUser() {
- $user = $this->createMock(IUser::class);
$this->mapper->expects($this->once())
->method('getTokenByUser')
- ->with($user)
+ ->with('uid')
->will($this->returnValue(['token']));
- $this->assertEquals(['token'], $this->tokenProvider->getTokenByUser($user));
+ $this->assertEquals(['token'], $this->tokenProvider->getTokenByUser('uid'));
}
public function testGetPassword() {
@@ -243,13 +242,12 @@ class DefaultTokenProviderTest extends TestCase {
public function testInvaildateTokenById() {
$id = 123;
- $user = $this->createMock(IUser::class);
$this->mapper->expects($this->once())
->method('deleteById')
- ->with($user, $id);
+ ->with('uid', $id);
- $this->tokenProvider->invalidateTokenById($user, $id);
+ $this->tokenProvider->invalidateTokenById('uid', $id);
}
public function testInvalidateOldTokens() {
diff --git a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
index 4901001db99..d5cfe5d1ee6 100644
--- a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
+++ b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
@@ -121,13 +121,12 @@ class PublicKeyTokenProviderTest extends TestCase {
}
public function testGetTokenByUser() {
- $user = $this->createMock(IUser::class);
$this->mapper->expects($this->once())
->method('getTokenByUser')
- ->with($user)
+ ->with('uid')
->will($this->returnValue(['token']));
- $this->assertEquals(['token'], $this->tokenProvider->getTokenByUser($user));
+ $this->assertEquals(['token'], $this->tokenProvider->getTokenByUser('uid'));
}
public function testGetPassword() {
@@ -189,7 +188,18 @@ class PublicKeyTokenProviderTest extends TestCase {
$actual = $this->tokenProvider->generateToken($token, $uid, $user, $password, $name, $type, IToken::DO_NOT_REMEMBER);
+ $this->mapper->method('getTokenByUser')
+ ->with('user')
+ ->willReturn([$actual]);
+
$newpass = 'newpass';
+ $this->mapper->expects($this->once())
+ ->method('update')
+ ->with($this->callback(function ($token) use ($newpass) {
+ return $newpass === $this->tokenProvider->getPassword($token, 'token');
+ }));
+
+
$this->tokenProvider->setPassword($actual, $token, $newpass);
$this->assertSame($newpass, $this->tokenProvider->getPassword($actual, 'token'));
@@ -216,13 +226,12 @@ class PublicKeyTokenProviderTest extends TestCase {
public function testInvaildateTokenById() {
$id = 123;
- $user = $this->createMock(IUser::class);
$this->mapper->expects($this->once())
->method('deleteById')
- ->with($user, $id);
+ ->with('uid', $id);
- $this->tokenProvider->invalidateTokenById($user, $id);
+ $this->tokenProvider->invalidateTokenById('uid', $id);
}
public function testInvalidateOldTokens() {