diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-08-29 00:20:12 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-08-29 00:20:12 +0200 |
commit | 3d46b715e93ed3d350bca2022967c8f5b609e834 (patch) | |
tree | a9df4fd7f2085394056b6a0dc6f432669be77f76 /tests/unit/middleware | |
parent | dec43f5e77dc34f71879a40839ac6f7ffe369c13 (diff) |
add unittest for cors middleware
Diffstat (limited to 'tests/unit/middleware')
-rw-r--r-- | tests/unit/middleware/CORSMiddlewareTest.php | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/unit/middleware/CORSMiddlewareTest.php b/tests/unit/middleware/CORSMiddlewareTest.php new file mode 100644 index 000000000..bccd79f1d --- /dev/null +++ b/tests/unit/middleware/CORSMiddlewareTest.php @@ -0,0 +1,59 @@ +<?php + +/** + * ownCloud - App Framework + * + * @author Bernhard Posselt + * @copyright 2012 Bernhard Posselt dev@bernhard-posselt.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ + + +namespace OCA\News\Middleware; + +use OCA\AppFramework\Http\Response; + + +require_once(__DIR__ . "/../../classloader.php"); + + +class CORSMiddlewareTest extends \PHPUnit_Framework_TestCase { + + + /** + * @API + */ + public function testSetCORSAPIHeader() { + $middleware = new CORSMiddleware(); + $response = $middleware->afterController('\OCA\News\Middleware\CORSMiddlewareTest', + 'testSetCORSAPIHeader', + new Response()); + $headers = $response->getHeaders(); + + $this->assertEquals('*', $headers['Access-Control-Allow-Origin']); + } + + + public function testNoAPINoCORSHEADER() { + $middleware = new CORSMiddleware(); + $response = $middleware->afterController('\OCA\News\Middleware\CORSMiddlewareTest', + 'testNoAPINoCORSHEADER', + new Response()); + $headers = $response->getHeaders(); + $this->assertFalse(array_key_exists('Access-Control-Allow-Origin', $headers)); + } + +} |