}
public function testGenerateToken() {
- $token = 'token';
+ $token = 'tokentokentokentokentoken';
$uid = 'user';
$user = 'User';
$password = 'passme';
}
public function testGenerateTokenNoPassword(): void {
- $token = 'token';
+ $token = 'tokentokentokentokentoken';
$uid = 'user';
$user = 'User';
$password = 'passme';
}
public function testGenerateTokenLongPassword() {
- $token = 'token';
+ $token = 'tokentokentokentokentoken';
$uid = 'user';
$user = 'User';
$password = '';
}
public function testGenerateTokenInvalidName() {
- $token = 'token';
+ $token = 'tokentokentokentokentoken';
$uid = 'user';
$user = 'User';
$password = 'passme';
}
public function testGetPassword() {
- $token = 'token';
+ $token = 'tokentokentokentokentoken';
$uid = 'user';
$user = 'User';
$password = 'passme';
public function testGetPasswordInvalidToken() {
$this->expectException(\OC\Authentication\Exceptions\InvalidTokenException::class);
- $token = 'token';
+ $token = 'tokentokentokentokentoken';
$uid = 'user';
$user = 'User';
$password = 'passme';
}
public function testSetPassword() {
- $token = 'token';
+ $token = 'tokentokentokentokentoken';
$uid = 'user';
$user = 'User';
$password = 'passme';
$this->mapper->expects($this->once())
->method('update')
->with($this->callback(function ($token) use ($newpass) {
- return $newpass === $this->tokenProvider->getPassword($token, 'token');
+ return $newpass === $this->tokenProvider->getPassword($token, 'tokentokentokentokentoken');
}));
$this->tokenProvider->setPassword($actual, $token, $newpass);
- $this->assertSame($newpass, $this->tokenProvider->getPassword($actual, 'token'));
+ $this->assertSame($newpass, $this->tokenProvider->getPassword($actual, 'tokentokentokentokentoken'));
}
}
public function testInvalidateToken() {
- $this->mapper->expects($this->at(0))
- ->method('invalidate')
- ->with(hash('sha512', 'token7'.'1f4h9s'));
- $this->mapper->expects($this->at(1))
+ $this->mapper->expects($this->exactly(2))
->method('invalidate')
- ->with(hash('sha512', 'token7'));
+ ->withConsecutive(
+ [hash('sha512', 'token7'.'1f4h9s')],
+ [hash('sha512', 'token7')]
+ );
$this->tokenProvider->invalidateToken('token7');
}
}
public function testRenewSessionTokenWithoutPassword() {
- $token = 'oldId';
+ $token = 'oldIdtokentokentokentoken';
$uid = 'user';
$user = 'User';
$password = null;
$this->mapper
->expects($this->once())
->method('getToken')
- ->with(hash('sha512', 'oldId' . '1f4h9s'))
+ ->with(hash('sha512', 'oldIdtokentokentokentoken' . '1f4h9s'))
->willReturn($oldToken);
$this->mapper
->expects($this->once())
return $token === $oldToken;
}));
- $this->tokenProvider->renewSessionToken('oldId', 'newId');
+ $this->tokenProvider->renewSessionToken('oldIdtokentokentokentoken', 'newIdtokentokentokentoken');
}
public function testRenewSessionTokenWithPassword(): void {
- $token = 'oldId';
+ $token = 'oldIdtokentokentokentoken';
$uid = 'user';
$user = 'User';
$password = 'password';
$this->mapper
->expects($this->once())
->method('getToken')
- ->with(hash('sha512', 'oldId' . '1f4h9s'))
+ ->with(hash('sha512', 'oldIdtokentokentokentoken' . '1f4h9s'))
->willReturn($oldToken);
$this->mapper
->expects($this->once())
$token->getType() === IToken::DO_NOT_REMEMBER &&
$token->getLastActivity() === $this->time &&
$token->getPassword() !== null &&
- $this->tokenProvider->getPassword($token, 'newId') === 'password';
+ $this->tokenProvider->getPassword($token, 'newIdtokentokentokentoken') === 'password';
}));
$this->mapper
->expects($this->once())
return $token === $oldToken;
}));
- $this->tokenProvider->renewSessionToken('oldId', 'newId');
+ $this->tokenProvider->renewSessionToken('oldIdtokentokentokentoken', 'newIdtokentokentokentoken');
}
public function testGetToken(): void {
$this->mapper->method('getToken')
->with(
$this->callback(function (string $token) {
- return hash('sha512', 'unhashedToken'.'1f4h9s') === $token;
+ return hash('sha512', 'unhashedTokentokentokentokentoken'.'1f4h9s') === $token;
})
)->willReturn($token);
- $this->assertSame($token, $this->tokenProvider->getToken('unhashedToken'));
+ $this->assertSame($token, $this->tokenProvider->getToken('unhashedTokentokentokentokentoken'));
}
public function testGetInvalidToken() {
$this->expectException(InvalidTokenException::class);
- $this->mapper->expects($this->at(0))
- ->method('getToken')
- ->with(
- $this->callback(function (string $token): bool {
- return hash('sha512', 'unhashedToken'.'1f4h9s') === $token;
- })
- )->willThrowException(new DoesNotExistException('nope'));
-
- $this->mapper->expects($this->at(1))
+ $this->mapper->expects($this->exactly(2))
->method('getToken')
- ->with(
- $this->callback(function (string $token): bool {
- return hash('sha512', 'unhashedToken') === $token;
- })
+ ->withConsecutive(
+ [$this->callback(function (string $token): bool {
+ return hash('sha512', 'unhashedTokentokentokentokentoken'.'1f4h9s') === $token;
+ })],
+ [$this->callback(function (string $token): bool {
+ return hash('sha512', 'unhashedTokentokentokentokentoken') === $token;
+ })]
)->willThrowException(new DoesNotExistException('nope'));
- $this->tokenProvider->getToken('unhashedToken');
+ $this->tokenProvider->getToken('unhashedTokentokentokentokentoken');
}
public function testGetExpiredToken() {
- $token = 'token';
+ $token = 'tokentokentokentokentoken';
$uid = 'user';
$user = 'User';
$password = 'passme';
$this->mapper->method('getToken')
->with(
$this->callback(function (string $token) {
- return hash('sha512', 'token'.'1f4h9s') === $token;
+ return hash('sha512', 'tokentokentokentokentoken'.'1f4h9s') === $token;
})
)->willReturn($actual);
try {
- $this->tokenProvider->getToken('token');
+ $this->tokenProvider->getToken('tokentokentokentokentoken');
$this->fail();
} catch (ExpiredTokenException $e) {
$this->assertSame($actual, $e->getToken());
}
public function testRotate() {
- $token = 'oldtoken';
+ $token = 'oldtokentokentokentokentoken';
$uid = 'user';
$user = 'User';
$password = 'password';
]);
$actual = $this->tokenProvider->generateToken($token, $uid, $user, $password, $name, $type, IToken::DO_NOT_REMEMBER);
- $new = $this->tokenProvider->rotate($actual, 'oldtoken', 'newtoken');
+ $new = $this->tokenProvider->rotate($actual, 'oldtokentokentokentokentoken', 'newtokentokentokentokentoken');
- $this->assertSame('password', $this->tokenProvider->getPassword($new, 'newtoken'));
+ $this->assertSame('password', $this->tokenProvider->getPassword($new, 'newtokentokentokentokentoken'));
}
public function testRotateNoPassword() {
- $token = 'oldtoken';
+ $token = 'oldtokentokentokentokentoken';
$uid = 'user';
$user = 'User';
$password = null;
$oldPrivate = $actual->getPrivateKey();
- $new = $this->tokenProvider->rotate($actual, 'oldtoken', 'newtoken');
+ $new = $this->tokenProvider->rotate($actual, 'oldtokentokentokentokentoken', 'newtokentokentokentokentoken');
$newPrivate = $new->getPrivateKey();
public function testUpdatePasswords() {
$uid = 'myUID';
$token1 = $this->tokenProvider->generateToken(
- 'foo',
+ 'foobetokentokentokentoken',
$uid,
$uid,
'bar',
IToken::PERMANENT_TOKEN,
IToken::REMEMBER);
$token2 = $this->tokenProvider->generateToken(
- 'foobar',
+ 'foobartokentokentokentoken',
$uid,
$uid,
'bar',