]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use 403 instead of 200 response
authorLukas Reschke <lukas@owncloud.com>
Thu, 29 Jan 2015 11:04:54 +0000 (12:04 +0100)
committerLukas Reschke <lukas@owncloud.com>
Thu, 29 Jan 2015 11:04:54 +0000 (12:04 +0100)
A forbidden should throw a 403 and this makes it easier for me to do some automated testing.

settings/middleware/subadminmiddleware.php
tests/settings/middleware/subadminmiddlewaretest.php

index a5c005e3148d40b0a25ec694dca352d063859ff6..52b77cd7e4fc3a0f0803b448e2393121ec9bfe4e 100644 (file)
@@ -59,7 +59,9 @@ class SubadminMiddleware extends Middleware {
         * @return TemplateResponse
         */
        public function afterException($controller, $methodName, \Exception $exception) {
-               return new TemplateResponse('core', '403', array(), 'guest');
+               $response = new TemplateResponse('core', '403', array(), 'guest');
+               $response->setStatus(Http::STATUS_FORBIDDEN);
+               return $response;
        }
 
 }
index e5572cfba525e1874d143871d856bd33aa3107d8..d0da19f60e11500bd47a1bf94b44504415c57b09 100644 (file)
@@ -81,11 +81,9 @@ class SubadminMiddlewareTest extends \Test\TestCase {
                $this->subadminMiddlewareAsSubAdmin->beforeController($this->controller, 'foo');
        }
 
-
-
-
        public function testAfterException() {
                $expectedResponse = new TemplateResponse('core', '403', array(), 'guest');
+               $expectedResponse->setStatus(403);
                $this->assertEquals($expectedResponse, $this->subadminMiddleware->afterException($this->controller, 'foo', new \Exception()));
        }
-}
\ No newline at end of file
+}