tests: Add test to rotate without stored password

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2024-02-13 11:06:15 +01:00
parent ee8a015a53
commit 734f6e4da8
No known key found for this signature in database
GPG key ID: 4C614C6ED2CDE6DF

View file

@ -564,6 +564,26 @@ class PublicKeyTokenProviderTest extends TestCase {
$this->assertSame('password', $this->tokenProvider->getPassword($new, 'newtokentokentokentokentoken'));
}
public function testRotateNoStoreCrypt() {
$token = 'oldtokentokentokentokentoken';
$uid = 'user';
$user = 'User';
$password = 'password';
$name = 'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12';
$type = IToken::PERMANENT_TOKEN;
$this->config->method('getSystemValueBool')
->willReturnMap([
['auth.storeCryptedPassword', true, false],
]);
$actual = $this->tokenProvider->generateToken($token, $uid, $user, $password, $name, $type, IToken::DO_NOT_REMEMBER);
$new = $this->tokenProvider->rotate($actual, 'oldtokentokentokentokentoken', 'newtokentokentokentokentoken');
$this->expectException(PasswordlessTokenException::class);
$this->tokenProvider->getPassword($new, 'newtokentokentokentokentoken');
}
public function testRotateNoPassword() {
$token = 'oldtokentokentokentokentoken';
$uid = 'user';
@ -580,7 +600,8 @@ class PublicKeyTokenProviderTest extends TestCase {
$newPrivate = $new->getPrivateKey();
$this->assertNotSame($newPrivate, $oldPrivate);
$this->assertNull($oldPrivate);
$this->assertNull($newPrivate);
$this->assertNull($new->getPassword());
}
@ -606,6 +627,11 @@ class PublicKeyTokenProviderTest extends TestCase {
}
public function testUpdatePasswords() {
$this->config->method('getSystemValueBool')
->willReturnMap([
['auth.storeCryptedPassword', true, true],
]);
$uid = 'myUID';
$token1 = $this->tokenProvider->generateToken(
'foobetokentokentokentoken',