aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Security/VerificationToken/VerificationTokenTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Security/VerificationToken/VerificationTokenTest.php')
-rw-r--r--tests/lib/Security/VerificationToken/VerificationTokenTest.php55
1 files changed, 19 insertions, 36 deletions
diff --git a/tests/lib/Security/VerificationToken/VerificationTokenTest.php b/tests/lib/Security/VerificationToken/VerificationTokenTest.php
index 481646f26ab..7123cc8b013 100644
--- a/tests/lib/Security/VerificationToken/VerificationTokenTest.php
+++ b/tests/lib/Security/VerificationToken/VerificationTokenTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2021 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security\VerificationToken;
@@ -34,8 +17,8 @@ use OCP\IUser;
use OCP\Security\ICrypto;
use OCP\Security\ISecureRandom;
use OCP\Security\VerificationToken\InvalidTokenException;
-use Test\TestCase;
use PHPUnit\Framework\MockObject\MockObject;
+use Test\TestCase;
class VerificationTokenTest extends TestCase {
/** @var VerificationToken */
@@ -69,13 +52,13 @@ class VerificationTokenTest extends TestCase {
);
}
- public function testTokenUserUnknown() {
+ public function testTokenUserUnknown(): void {
$this->expectException(InvalidTokenException::class);
$this->expectExceptionCode(InvalidTokenException::USER_UNKNOWN);
$this->token->check('encryptedToken', null, 'fingerprintToken', 'foobar');
}
- public function testTokenUserUnknown2() {
+ public function testTokenUserUnknown2(): void {
$user = $this->createMock(IUser::class);
$user->expects($this->atLeastOnce())
->method('isEnabled')
@@ -86,7 +69,7 @@ class VerificationTokenTest extends TestCase {
$this->token->check('encryptedToken', $user, 'fingerprintToken', 'foobar');
}
- public function testTokenNotFound() {
+ public function testTokenNotFound(): void {
$user = $this->createMock(IUser::class);
$user->expects($this->atLeastOnce())
->method('isEnabled')
@@ -102,7 +85,7 @@ class VerificationTokenTest extends TestCase {
$this->token->check('encryptedToken', $user, 'fingerprintToken', 'foobar');
}
- public function testTokenDecryptionError() {
+ public function testTokenDecryptionError(): void {
$user = $this->createMock(IUser::class);
$user->expects($this->atLeastOnce())
->method('isEnabled')
@@ -116,7 +99,7 @@ class VerificationTokenTest extends TestCase {
->with('alice', 'core', 'fingerprintToken', null)
->willReturn('encryptedToken');
$this->config->expects($this->any())
- ->method('getSystemValue')
+ ->method('getSystemValueString')
->with('secret')
->willReturn('357111317');
@@ -129,7 +112,7 @@ class VerificationTokenTest extends TestCase {
$this->token->check('encryptedToken', $user, 'fingerprintToken', 'foobar');
}
- public function testTokenInvalidFormat() {
+ public function testTokenInvalidFormat(): void {
$user = $this->createMock(IUser::class);
$user->expects($this->atLeastOnce())
->method('isEnabled')
@@ -143,7 +126,7 @@ class VerificationTokenTest extends TestCase {
->with('alice', 'core', 'fingerprintToken', null)
->willReturn('encryptedToken');
$this->config->expects($this->any())
- ->method('getSystemValue')
+ ->method('getSystemValueString')
->with('secret')
->willReturn('357111317');
@@ -156,7 +139,7 @@ class VerificationTokenTest extends TestCase {
$this->token->check('encryptedToken', $user, 'fingerprintToken', 'foobar');
}
- public function testTokenExpired() {
+ public function testTokenExpired(): void {
$user = $this->createMock(IUser::class);
$user->expects($this->atLeastOnce())
->method('isEnabled')
@@ -173,7 +156,7 @@ class VerificationTokenTest extends TestCase {
->with('alice', 'core', 'fingerprintToken', null)
->willReturn('encryptedToken');
$this->config->expects($this->any())
- ->method('getSystemValue')
+ ->method('getSystemValueString')
->with('secret')
->willReturn('357111317');
@@ -190,7 +173,7 @@ class VerificationTokenTest extends TestCase {
$this->token->check('encryptedToken', $user, 'fingerprintToken', 'foobar');
}
- public function testTokenExpiredByLogin() {
+ public function testTokenExpiredByLogin(): void {
$user = $this->createMock(IUser::class);
$user->expects($this->atLeastOnce())
->method('isEnabled')
@@ -207,7 +190,7 @@ class VerificationTokenTest extends TestCase {
->with('alice', 'core', 'fingerprintToken', null)
->willReturn('encryptedToken');
$this->config->expects($this->any())
- ->method('getSystemValue')
+ ->method('getSystemValueString')
->with('secret')
->willReturn('357111317');
@@ -224,7 +207,7 @@ class VerificationTokenTest extends TestCase {
$this->token->check('encryptedToken', $user, 'fingerprintToken', 'foobar', true);
}
- public function testTokenMismatch() {
+ public function testTokenMismatch(): void {
$user = $this->createMock(IUser::class);
$user->expects($this->atLeastOnce())
->method('isEnabled')
@@ -241,7 +224,7 @@ class VerificationTokenTest extends TestCase {
->with('alice', 'core', 'fingerprintToken', null)
->willReturn('encryptedToken');
$this->config->expects($this->any())
- ->method('getSystemValue')
+ ->method('getSystemValueString')
->with('secret')
->willReturn('357111317');
@@ -258,7 +241,7 @@ class VerificationTokenTest extends TestCase {
$this->token->check('encryptedToken', $user, 'fingerprintToken', 'foobar');
}
- public function testTokenSuccess() {
+ public function testTokenSuccess(): void {
$user = $this->createMock(IUser::class);
$user->expects($this->atLeastOnce())
->method('isEnabled')
@@ -275,7 +258,7 @@ class VerificationTokenTest extends TestCase {
->with('alice', 'core', 'fingerprintToken', null)
->willReturn('encryptedToken');
$this->config->expects($this->any())
- ->method('getSystemValue')
+ ->method('getSystemValueString')
->with('secret')
->willReturn('357111317');
@@ -290,7 +273,7 @@ class VerificationTokenTest extends TestCase {
$this->token->check('barfoo', $user, 'fingerprintToken', 'foobar');
}
- public function testCreate() {
+ public function testCreate(): void {
$user = $this->createMock(IUser::class);
$user->expects($this->any())
->method('getUID')