diff options
author | Joas Schilling <coding@schilljs.com> | 2022-02-23 10:40:58 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-02-23 11:01:58 +0100 |
commit | d078d536835fc75a79b5381a628cefb92ae74886 (patch) | |
tree | 65dac66485b3562fa04f8fce4fabcac69a36ce74 /tests/lib/AppFramework/Middleware | |
parent | cc6653e45c86e8019846274b04154c96e34632cf (diff) | |
download | nextcloud-server-d078d536835fc75a79b5381a628cefb92ae74886.tar.gz nextcloud-server-d078d536835fc75a79b5381a628cefb92ae74886.zip |
Fix tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib/AppFramework/Middleware')
4 files changed, 28 insertions, 24 deletions
diff --git a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php index 9a5254fb4dd..f408320971d 100644 --- a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php +++ b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php @@ -28,6 +28,7 @@ use OC\AppFramework\Middleware\MiddlewareDispatcher; use OCP\AppFramework\Http\Response; use OCP\AppFramework\Middleware; use OCP\IConfig; +use OCP\IRequestId; // needed to test ordering class TestMiddleware extends Middleware { @@ -129,8 +130,8 @@ class MiddlewareDispatcherTest extends \Test\TestCase { ->setConstructorArgs(['app', new Request( ['method' => 'GET'], - $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), - $this->getMockBuilder(IConfig::class)->getMock() + $this->createMock(IRequestId::class), + $this->createMock(IConfig::class) ) ])->getMock(); } @@ -272,7 +273,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { public function testExceptionShouldRunAfterExceptionOfOnlyPreviouslyExecutedMiddlewares() { $m1 = $this->getMiddleware(); $m2 = $this->getMiddleware(true); - $m3 = $this->getMockBuilder('\OCP\AppFramework\Middleware')->getMock(); + $m3 = $this->createMock(Middleware::class); $m3->expects($this->never()) ->method('afterException'); $m3->expects($this->never()) diff --git a/tests/lib/AppFramework/Middleware/MiddlewareTest.php b/tests/lib/AppFramework/Middleware/MiddlewareTest.php index 42e38bbd999..bd61aab4673 100644 --- a/tests/lib/AppFramework/Middleware/MiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/MiddlewareTest.php @@ -24,9 +24,12 @@ namespace Test\AppFramework\Middleware; use OC\AppFramework\Http\Request; +use OCP\AppFramework\Controller; use OCP\AppFramework\Http\Response; use OCP\AppFramework\Middleware; use OCP\IConfig; +use OCP\IRequestId; +use OC\AppFramework\DependencyInjection\DIContainer; class ChildMiddleware extends Middleware { }; @@ -49,22 +52,22 @@ class MiddlewareTest extends \Test\TestCase { $this->middleware = new ChildMiddleware(); - $this->api = $this->getMockBuilder('OC\AppFramework\DependencyInjection\DIContainer') + $this->api = $this->getMockBuilder(DIContainer::class) ->disableOriginalConstructor() ->getMock(); - $this->controller = $this->getMockBuilder('OCP\AppFramework\Controller') + $this->controller = $this->getMockBuilder(Controller::class) ->setMethods([]) ->setConstructorArgs([ $this->api, new Request( [], - $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), - $this->getMockBuilder(IConfig::class)->getMock() + $this->createMock(IRequestId::class), + $this->createMock(IConfig::class) ) ])->getMock(); $this->exception = new \Exception(); - $this->response = $this->getMockBuilder('OCP\AppFramework\Http\Response')->getMock(); + $this->response = $this->getMockBuilder(Response::class)->getMock(); } diff --git a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php index c89f38b44f5..cc6c74c16c4 100644 --- a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php @@ -21,7 +21,7 @@ use OCP\AppFramework\Controller; use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\Response; use OCP\IConfig; -use OCP\Security\ISecureRandom; +use OCP\IRequestId; class CORSMiddlewareTest extends \Test\TestCase { @@ -52,7 +52,7 @@ class CORSMiddlewareTest extends \Test\TestCase { 'HTTP_ORIGIN' => 'test' ] ], - $this->createMock(ISecureRandom::class), + $this->createMock(IRequestId::class), $this->createMock(IConfig::class) ); $this->reflector->reflect($this, __FUNCTION__); @@ -71,7 +71,7 @@ class CORSMiddlewareTest extends \Test\TestCase { 'HTTP_ORIGIN' => 'test' ] ], - $this->createMock(ISecureRandom::class), + $this->createMock(IRequestId::class), $this->createMock(IConfig::class) ); $middleware = new CORSMiddleware($request, $this->reflector, $this->session, $this->throttler); @@ -88,7 +88,7 @@ class CORSMiddlewareTest extends \Test\TestCase { public function testNoOriginHeaderNoCORSHEADER() { $request = new Request( [], - $this->createMock(ISecureRandom::class), + $this->createMock(IRequestId::class), $this->createMock(IConfig::class) ); $this->reflector->reflect($this, __FUNCTION__); @@ -112,7 +112,7 @@ class CORSMiddlewareTest extends \Test\TestCase { 'HTTP_ORIGIN' => 'test' ] ], - $this->createMock(ISecureRandom::class), + $this->createMock(IRequestId::class), $this->createMock(IConfig::class) ); $this->reflector->reflect($this, __FUNCTION__); @@ -130,7 +130,7 @@ class CORSMiddlewareTest extends \Test\TestCase { public function testNoCORSShouldAllowCookieAuth() { $request = new Request( [], - $this->createMock(ISecureRandom::class), + $this->createMock(IRequestId::class), $this->createMock(IConfig::class) ); $this->reflector->reflect($this, __FUNCTION__); @@ -155,7 +155,7 @@ class CORSMiddlewareTest extends \Test\TestCase { 'PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'pass' ]], - $this->createMock(ISecureRandom::class), + $this->createMock(IRequestId::class), $this->createMock(IConfig::class) ); $this->session->expects($this->once()) @@ -181,7 +181,7 @@ class CORSMiddlewareTest extends \Test\TestCase { 'PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'pass' ]], - $this->createMock(ISecureRandom::class), + $this->createMock(IRequestId::class), $this->createMock(IConfig::class) ); $this->session->expects($this->once()) @@ -207,7 +207,7 @@ class CORSMiddlewareTest extends \Test\TestCase { 'PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'pass' ]], - $this->createMock(ISecureRandom::class), + $this->createMock(IRequestId::class), $this->createMock(IConfig::class) ); $this->session->expects($this->once()) @@ -228,7 +228,7 @@ class CORSMiddlewareTest extends \Test\TestCase { 'PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'pass' ]], - $this->createMock(ISecureRandom::class), + $this->createMock(IRequestId::class), $this->createMock(IConfig::class) ); $middleware = new CORSMiddleware($request, $this->reflector, $this->session, $this->throttler); @@ -244,7 +244,7 @@ class CORSMiddlewareTest extends \Test\TestCase { 'PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'pass' ]], - $this->createMock(ISecureRandom::class), + $this->createMock(IRequestId::class), $this->createMock(IConfig::class) ); $middleware = new CORSMiddleware($request, $this->reflector, $this->session, $this->throttler); @@ -264,7 +264,7 @@ class CORSMiddlewareTest extends \Test\TestCase { 'PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'pass' ]], - $this->createMock(ISecureRandom::class), + $this->createMock(IRequestId::class), $this->createMock(IConfig::class) ); $middleware = new CORSMiddleware($request, $this->reflector, $this->session, $this->throttler); diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php index 1af2b2b9f1c..276ebe8f9ac 100644 --- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php @@ -42,9 +42,9 @@ use OCP\IConfig; use OCP\IL10N; use OCP\INavigationManager; use OCP\IRequest; +use OCP\IRequestId; use OCP\IURLGenerator; use OCP\IUserSession; -use OCP\Security\ISecureRandom; use Psr\Log\LoggerInterface; class SecurityMiddlewareTest extends \Test\TestCase { @@ -500,7 +500,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { 'REQUEST_URI' => 'nextcloud/index.php/apps/specialapp' ] ], - $this->createMock(ISecureRandom::class), + $this->createMock(IRequestId::class), $this->createMock(IConfig::class) ); $this->middleware = $this->getMiddleware(false, false, false); @@ -534,7 +534,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { 'REQUEST_URI' => 'nextcloud/index.php/apps/specialapp', ], ], - $this->createMock(ISecureRandom::class), + $this->createMock(IRequestId::class), $this->createMock(IConfig::class) ); @@ -580,7 +580,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { 'REQUEST_URI' => 'nextcloud/index.php/apps/specialapp' ] ], - $this->createMock(ISecureRandom::class), + $this->createMock(IRequestId::class), $this->createMock(IConfig::class) ); $this->middleware = $this->getMiddleware(false, false, false); |