aboutsummaryrefslogtreecommitdiffstats
path: root/tests/settings
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2016-02-22 09:41:56 +0100
committerLukas Reschke <lukas@owncloud.com>2016-02-22 09:41:56 +0100
commit6c96b3d07f7248d1ab4066dbf71025753de1a0a9 (patch)
tree71fa05b693ea0064c7fd2b191059c31ae44ab800 /tests/settings
parent8a8209796d4577644228121edc2231ae027217c7 (diff)
downloadnextcloud-server-6c96b3d07f7248d1ab4066dbf71025753de1a0a9.tar.gz
nextcloud-server-6c96b3d07f7248d1ab4066dbf71025753de1a0a9.zip
Throw normal exceptions instead of eating them
Partially addresses https://github.com/owncloud/core/issues/22550 Replaces https://github.com/owncloud/core/pull/20185
Diffstat (limited to 'tests/settings')
-rw-r--r--tests/settings/middleware/subadminmiddlewaretest.php17
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/settings/middleware/subadminmiddlewaretest.php b/tests/settings/middleware/subadminmiddlewaretest.php
index d0da19f60e1..2b76e4beaa9 100644
--- a/tests/settings/middleware/subadminmiddlewaretest.php
+++ b/tests/settings/middleware/subadminmiddlewaretest.php
@@ -10,6 +10,7 @@
namespace OC\Settings\Middleware;
+use OC\Appframework\Middleware\Security\Exceptions\NotAdminException;
use OC\AppFramework\Utility\ControllerMethodReflector;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\TemplateResponse;
@@ -41,8 +42,7 @@ class SubadminMiddlewareTest extends \Test\TestCase {
}
/**
- * @expectedException \Exception
- * @expectedExceptionMessage Logged in user must be a subadmin
+ * @expectedException \OC\Appframework\Middleware\Security\Exceptions\NotAdminException
*/
public function testBeforeControllerAsUserWithExemption() {
$this->reflector
@@ -81,9 +81,18 @@ class SubadminMiddlewareTest extends \Test\TestCase {
$this->subadminMiddlewareAsSubAdmin->beforeController($this->controller, 'foo');
}
- public function testAfterException() {
+ public function testAfterNotAdminException() {
+ $expectedResponse = new TemplateResponse('core', '403', array(), 'guest');
+ $expectedResponse->setStatus(403);
+ $this->assertEquals($expectedResponse, $this->subadminMiddleware->afterException($this->controller, 'foo', new NotAdminException()));
+ }
+
+ /**
+ * @expectedException \Exception
+ */
+ public function testAfterRegularException() {
$expectedResponse = new TemplateResponse('core', '403', array(), 'guest');
$expectedResponse->setStatus(403);
- $this->assertEquals($expectedResponse, $this->subadminMiddleware->afterException($this->controller, 'foo', new \Exception()));
+ $this->subadminMiddleware->afterException($this->controller, 'foo', new \Exception());
}
}