aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-08-28 15:50:45 +0200
committerJoas Schilling <coding@schilljs.com>2023-08-28 15:50:45 +0200
commit25309bcb45232bf30fe719bac1776f0136f7cd7a (patch)
tree7cfa6dacd42f22a854b895c2ae5853ff1725d96b /tests
parentac3d7e3a7e9848c5e134b79f481d73416cc810f4 (diff)
downloadnextcloud-server-25309bcb45232bf30fe719bac1776f0136f7cd7a.tar.gz
nextcloud-server-25309bcb45232bf30fe719bac1776f0136f7cd7a.zip
techdebt(DI): Use public IThrottler interface which exists since Nextcloud 25
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Core/Controller/LoginControllerTest.php6
-rw-r--r--tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php6
-rw-r--r--tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php6
-rw-r--r--tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php9
-rw-r--r--tests/lib/User/SessionTest.php6
5 files changed, 17 insertions, 16 deletions
diff --git a/tests/Core/Controller/LoginControllerTest.php b/tests/Core/Controller/LoginControllerTest.php
index 6044440bdaf..333baf0aa86 100644
--- a/tests/Core/Controller/LoginControllerTest.php
+++ b/tests/Core/Controller/LoginControllerTest.php
@@ -29,7 +29,6 @@ use OC\Authentication\Login\LoginData;
use OC\Authentication\Login\LoginResult;
use OC\Authentication\TwoFactorAuth\Manager;
use OC\Core\Controller\LoginController;
-use OC\Security\Bruteforce\Throttler;
use OC\User\Session;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse;
@@ -43,6 +42,7 @@ use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Notification\IManager;
+use OCP\Security\Bruteforce\IThrottler;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
@@ -74,7 +74,7 @@ class LoginControllerTest extends TestCase {
/** @var Defaults|MockObject */
private $defaults;
- /** @var Throttler|MockObject */
+ /** @var IThrottler|MockObject */
private $throttler;
/** @var IInitialStateService|MockObject */
@@ -99,7 +99,7 @@ class LoginControllerTest extends TestCase {
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->twoFactorManager = $this->createMock(Manager::class);
$this->defaults = $this->createMock(Defaults::class);
- $this->throttler = $this->createMock(Throttler::class);
+ $this->throttler = $this->createMock(IThrottler::class);
$this->initialStateService = $this->createMock(IInitialStateService::class);
$this->webAuthnManager = $this->createMock(\OC\Authentication\WebAuthn\Manager::class);
$this->notificationManager = $this->createMock(IManager::class);
diff --git a/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php b/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php
index 3e48078cbad..a025f39419a 100644
--- a/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php
@@ -25,7 +25,6 @@ namespace Test\AppFramework\Middleware\PublicShare;
use OC\AppFramework\Middleware\PublicShare\Exceptions\NeedAuthenticationException;
use OC\AppFramework\Middleware\PublicShare\PublicShareMiddleware;
-use OC\Security\Bruteforce\Throttler;
use OCP\AppFramework\AuthPublicShareController;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\NotFoundResponse;
@@ -36,6 +35,7 @@ use OCP\IConfig;
use OCP\IRequest;
use OCP\ISession;
use OCP\IURLGenerator;
+use OCP\Security\Bruteforce\IThrottler;
class PublicShareMiddlewareTest extends \Test\TestCase {
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
@@ -44,7 +44,7 @@ class PublicShareMiddlewareTest extends \Test\TestCase {
private $session;
/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
private $config;
- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IThrottler|\PHPUnit\Framework\MockObject\MockObject */
private $throttler;
/** @var PublicShareMiddleware */
@@ -57,7 +57,7 @@ class PublicShareMiddlewareTest extends \Test\TestCase {
$this->request = $this->createMock(IRequest::class);
$this->session = $this->createMock(ISession::class);
$this->config = $this->createMock(IConfig::class);
- $this->throttler = $this->createMock(Throttler::class);
+ $this->throttler = $this->createMock(IThrottler::class);
$this->middleware = new PublicShareMiddleware(
$this->request,
diff --git a/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php
index faf2d24d172..0492d5f7fcf 100644
--- a/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php
@@ -24,11 +24,11 @@ namespace Test\AppFramework\Middleware\Security;
use OC\AppFramework\Middleware\Security\BruteForceMiddleware;
use OC\AppFramework\Utility\ControllerMethodReflector;
-use OC\Security\Bruteforce\Throttler;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Attribute\BruteForceProtection;
use OCP\AppFramework\Http\Response;
use OCP\IRequest;
+use OCP\Security\Bruteforce\IThrottler;
use Psr\Log\LoggerInterface;
use Test\TestCase;
@@ -55,7 +55,7 @@ class TestController extends Controller {
class BruteForceMiddlewareTest extends TestCase {
/** @var ControllerMethodReflector */
private $reflector;
- /** @var Throttler|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IThrottler|\PHPUnit\Framework\MockObject\MockObject */
private $throttler;
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
private $request;
@@ -67,7 +67,7 @@ class BruteForceMiddlewareTest extends TestCase {
parent::setUp();
$this->reflector = new ControllerMethodReflector();
- $this->throttler = $this->createMock(Throttler::class);
+ $this->throttler = $this->createMock(IThrottler::class);
$this->request = $this->createMock(IRequest::class);
$this->logger = $this->createMock(LoggerInterface::class);
diff --git a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php
index 7c48f7e2712..80c2ed84451 100644
--- a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php
@@ -15,21 +15,22 @@ use OC\AppFramework\Http\Request;
use OC\AppFramework\Middleware\Security\CORSMiddleware;
use OC\AppFramework\Middleware\Security\Exceptions\SecurityException;
use OC\AppFramework\Utility\ControllerMethodReflector;
-use OC\Security\Bruteforce\Throttler;
use OC\User\Session;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\Response;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IRequestId;
+use OCP\Security\Bruteforce\IThrottler;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\AppFramework\Middleware\Security\Mock\CORSMiddlewareController;
class CORSMiddlewareTest extends \Test\TestCase {
/** @var ControllerMethodReflector */
private $reflector;
- /** @var Session|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var Session|MockObject */
private $session;
- /** @var Throttler */
+ /** @var IThrottler|MockObject */
private $throttler;
/** @var CORSMiddlewareController */
private $controller;
@@ -38,7 +39,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
parent::setUp();
$this->reflector = new ControllerMethodReflector();
$this->session = $this->createMock(Session::class);
- $this->throttler = $this->createMock(Throttler::class);
+ $this->throttler = $this->createMock(IThrottler::class);
$this->controller = new CORSMiddlewareController(
'test',
$this->createMock(IRequest::class)
diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php
index 598a8b6e061..b6ac7a69fed 100644
--- a/tests/lib/User/SessionTest.php
+++ b/tests/lib/User/SessionTest.php
@@ -14,7 +14,6 @@ use OC\Authentication\Exceptions\InvalidTokenException;
use OC\Authentication\Exceptions\PasswordLoginForbiddenException;
use OC\Authentication\Token\IProvider;
use OC\Authentication\Token\IToken;
-use OC\Security\Bruteforce\Throttler;
use OC\Session\Memory;
use OC\User\LoginException;
use OC\User\Manager;
@@ -30,6 +29,7 @@ use OCP\IRequestId;
use OCP\ISession;
use OCP\IUser;
use OCP\Lockdown\ILockdownManager;
+use OCP\Security\Bruteforce\IThrottler;
use OCP\Security\ISecureRandom;
use OCP\User\Events\PostLoginEvent;
use PHPUnit\Framework\MockObject\MockObject;
@@ -47,7 +47,7 @@ class SessionTest extends \Test\TestCase {
private $tokenProvider;
/** @var IConfig|MockObject */
private $config;
- /** @var Throttler|MockObject */
+ /** @var IThrottler|MockObject */
private $throttler;
/** @var ISecureRandom|MockObject */
private $random;
@@ -73,7 +73,7 @@ class SessionTest extends \Test\TestCase {
->willReturn(10000);
$this->tokenProvider = $this->createMock(IProvider::class);
$this->config = $this->createMock(IConfig::class);
- $this->throttler = $this->createMock(Throttler::class);
+ $this->throttler = $this->createMock(IThrottler::class);
$this->random = $this->createMock(ISecureRandom::class);
$this->manager = $this->createMock(Manager::class);
$this->session = $this->createMock(ISession::class);