diff options
author | Joas Schilling <coding@schilljs.com> | 2022-03-22 10:51:54 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-03-23 21:46:35 +0100 |
commit | 7efa2fa3a02167eea8f9b94d67b86d68e0b6e56a (patch) | |
tree | 3edb85a1475acdb40016aeff8c17d88c41767012 /tests | |
parent | b7245ae3facb0e2cde85087fd91cc985a05b892c (diff) | |
download | nextcloud-server-7efa2fa3a02167eea8f9b94d67b86d68e0b6e56a.tar.gz nextcloud-server-7efa2fa3a02167eea8f9b94d67b86d68e0b6e56a.zip |
Limit the length of app password names
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Authentication/Token/ManagerTest.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/lib/Authentication/Token/ManagerTest.php b/tests/lib/Authentication/Token/ManagerTest.php index fb92b3e5018..ee2b3cdc768 100644 --- a/tests/lib/Authentication/Token/ManagerTest.php +++ b/tests/lib/Authentication/Token/ManagerTest.php @@ -127,6 +127,37 @@ class ManagerTest extends TestCase { $this->assertSame($token, $actual); } + public function testGenerateTokenTooLongName() { + $token = $this->createMock(IToken::class); + $token->method('getName') + ->willReturn(str_repeat('a', 120) . '…'); + + + $this->publicKeyTokenProvider->expects($this->once()) + ->method('generateToken') + ->with( + 'token', + 'uid', + 'loginName', + 'password', + str_repeat('a', 120) . '…', + IToken::TEMPORARY_TOKEN, + IToken::REMEMBER + )->willReturn($token); + + $actual = $this->manager->generateToken( + 'token', + 'uid', + 'loginName', + 'password', + str_repeat('a', 200), + IToken::TEMPORARY_TOKEN, + IToken::REMEMBER + ); + + $this->assertSame(121, mb_strlen($actual->getName())); + } + public function tokenData(): array { return [ [new DefaultToken()], |