diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-02-26 17:50:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-26 17:50:21 +0100 |
commit | a60d7a8563f6f9e8047ac187e8f96f09f6dfa844 (patch) | |
tree | ed188b5a10bd2006b3ca97bea0e6e5502eb49192 /tests | |
parent | 67a76b00e8e05dbed5acaa8f9dc6a7d28065e6aa (diff) | |
parent | cf35c4b03ab7bd73cc5e9a26d88a0c61731d4b6e (diff) | |
download | nextcloud-server-a60d7a8563f6f9e8047ac187e8f96f09f6dfa844.tar.gz nextcloud-server-a60d7a8563f6f9e8047ac187e8f96f09f6dfa844.zip |
Merge pull request #8541 from nextcloud/translate-permission-error-page
Provide translated error message for permission error
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Settings/Middleware/SubadminMiddlewareTest.php | 10 | ||||
-rw-r--r-- | tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php | 14 |
2 files changed, 14 insertions, 10 deletions
diff --git a/tests/Settings/Middleware/SubadminMiddlewareTest.php b/tests/Settings/Middleware/SubadminMiddlewareTest.php index 834a3fedf23..b464b595ab7 100644 --- a/tests/Settings/Middleware/SubadminMiddlewareTest.php +++ b/tests/Settings/Middleware/SubadminMiddlewareTest.php @@ -15,6 +15,7 @@ use OC\AppFramework\Utility\ControllerMethodReflector; use OC\Settings\Middleware\SubadminMiddleware; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\TemplateResponse; +use OCP\IL10N; /** * Verifies whether an user has at least subadmin rights. @@ -31,6 +32,8 @@ class SubadminMiddlewareTest extends \Test\TestCase { private $reflector; /** @var Controller */ private $controller; + /** @var IL10N */ + private $l10n; protected function setUp() { parent::setUp(); @@ -38,9 +41,10 @@ class SubadminMiddlewareTest extends \Test\TestCase { ->disableOriginalConstructor()->getMock(); $this->controller = $this->getMockBuilder(Controller::class) ->disableOriginalConstructor()->getMock(); + $this->l10n = $this->createMock(IL10N::class); - $this->subadminMiddlewareAsSubAdmin = new SubadminMiddleware($this->reflector, true); - $this->subadminMiddleware = new SubadminMiddleware($this->reflector, false); + $this->subadminMiddlewareAsSubAdmin = new SubadminMiddleware($this->reflector, true, $this->l10n); + $this->subadminMiddleware = new SubadminMiddleware($this->reflector, false, $this->l10n); } /** @@ -86,7 +90,7 @@ class SubadminMiddlewareTest extends \Test\TestCase { public function testAfterNotAdminException() { $expectedResponse = new TemplateResponse('core', '403', array(), 'guest'); $expectedResponse->setStatus(403); - $this->assertEquals($expectedResponse, $this->subadminMiddleware->afterException($this->controller, 'foo', new NotAdminException())); + $this->assertEquals($expectedResponse, $this->subadminMiddleware->afterException($this->controller, 'foo', new NotAdminException(''))); } /** diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php index e36bd727bea..a631fe59a60 100644 --- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php @@ -45,13 +45,11 @@ use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\Response; use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; +use OCP\IL10N; use OCP\ILogger; use OCP\INavigationManager; use OCP\IRequest; -use OCP\ISession; use OCP\IURLGenerator; -use OCP\IUser; -use OCP\IUserSession; use OCP\Security\ISecureRandom; class SecurityMiddlewareTest extends \Test\TestCase { @@ -82,8 +80,8 @@ class SecurityMiddlewareTest extends \Test\TestCase { private $cspNonceManager; /** @var IAppManager|\PHPUnit_Framework_MockObject_MockObject */ private $appManager; - /** @var IUserSession|\PHPUnit_Framework_MockObject_MockObject */ - private $userSession; + /** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */ + private $l10n; protected function setUp() { parent::setUp(); @@ -98,6 +96,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->csrfTokenManager = $this->createMock(CsrfTokenManager::class); $this->cspNonceManager = $this->createMock(ContentSecurityPolicyNonceManager::class); $this->appManager = $this->createMock(IAppManager::class); + $this->l10n = $this->createMock(IL10N::class); $this->appManager->expects($this->any()) ->method('isEnabledForUser') ->willReturn(true); @@ -124,7 +123,8 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->contentSecurityPolicyManager, $this->csrfTokenManager, $this->cspNonceManager, - $this->appManager + $this->appManager, + $this->l10n ); } @@ -541,7 +541,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { new CrossSiteRequestForgeryException(), ], [ - new NotAdminException(), + new NotAdminException(''), ], ]; } |