aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristoph Wurst <ChristophWurst@users.noreply.github.com>2022-10-18 11:19:33 +0200
committerGitHub <noreply@github.com>2022-10-18 11:19:33 +0200
commitc67146642261084ad8584207441408e78d84af35 (patch)
tree6c08ad7a98a2efac54216c974f0d6cec5f03921d /tests
parentb01de1c5b6d3d2ea66f445086ba1f081c287dfbf (diff)
parentc5922e67d37f3bcf7748a36b4c7ab10d1d10f2b8 (diff)
downloadnextcloud-server-c67146642261084ad8584207441408e78d84af35.tar.gz
nextcloud-server-c67146642261084ad8584207441408e78d84af35.zip
Merge pull request #34379 from nextcloud/fix/transactional-session-token-renewal
Run session token renewals in a database transaction
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php20
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
index ad0a13937ae..ce739a74bb8 100644
--- a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
+++ b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
@@ -1,4 +1,7 @@
<?php
+
+declare(strict_types=1);
+
/**
* @copyright Copyright (c) 2018 Roeland Jago Douma <roeland@famdouma.nl>
*
@@ -34,6 +37,7 @@ use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig;
use OCP\Security\ICrypto;
+use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\TestCase;
@@ -46,6 +50,8 @@ class PublicKeyTokenProviderTest extends TestCase {
private $crypto;
/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
private $config;
+ /** @var IDBConnection|IDBConnection|MockObject */
+ private IDBConnection $db;
/** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
private $logger;
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
@@ -66,14 +72,24 @@ class PublicKeyTokenProviderTest extends TestCase {
['secret', '', '1f4h9s'],
['openssl', [], []],
]);
+ $this->db = $this->createMock(IDBConnection::class);
+ $this->db->method('atomic')->willReturnCallback(function ($cb) {
+ return $cb();
+ });
$this->logger = $this->createMock(LoggerInterface::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->time = 1313131;
$this->timeFactory->method('getTime')
->willReturn($this->time);
- $this->tokenProvider = new PublicKeyTokenProvider($this->mapper, $this->crypto, $this->config, $this->logger,
- $this->timeFactory);
+ $this->tokenProvider = new PublicKeyTokenProvider(
+ $this->mapper,
+ $this->crypto,
+ $this->config,
+ $this->db,
+ $this->logger,
+ $this->timeFactory,
+ );
}
public function testGenerateToken() {