diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-09-02 14:45:37 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-09-02 14:45:37 +0200 |
commit | 479d5e2e377e9c5daaea3359f84b563ac3ca5825 (patch) | |
tree | 99400a75af7d41bdba180c112e6505e713502eff /tests/unit/external | |
parent | e3512c977a7c4f05207bb312f97dafd1e50f62ed (diff) |
fix cors and cors unittests, fix #324
Diffstat (limited to 'tests/unit/external')
-rw-r--r-- | tests/unit/external/NewsAPITest.php | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/unit/external/NewsAPITest.php b/tests/unit/external/NewsAPITest.php index 2bc649c1c..9a319a378 100644 --- a/tests/unit/external/NewsAPITest.php +++ b/tests/unit/external/NewsAPITest.php @@ -25,6 +25,7 @@ namespace OCA\News\External; +use \OCA\AppFramework\Http\Request; use \OCA\AppFramework\Http\JSONResponse; use \OCA\AppFramework\Utility\ControllerTestUtility; @@ -99,6 +100,8 @@ class NewsAPITest extends ControllerTestUtility { public function testCors() { + $this->request = new Request(array('server' => array())); + $this->newsAPI = new NewsAPI($this->api, $this->request, $this->updater); $response = $this->newsAPI->cors(); $headers = $response->getHeaders(); @@ -106,9 +109,20 @@ class NewsAPITest extends ControllerTestUtility { $this->assertEquals('*', $headers['Access-Control-Allow-Origin']); $this->assertEquals('PUT, POST, GET, DELETE', $headers['Access-Control-Allow-Methods']); $this->assertEquals('true', $headers['Access-Control-Allow-Credentials']); - $this->assertEquals('Authorization', $headers['Access-Control-Allow-Headers']); + $this->assertEquals('Authorization, Content-Type', $headers['Access-Control-Allow-Headers']); $this->assertEquals('1728000', $headers['Access-Control-Max-Age']); } + public function testCorsUsesOriginIfGiven() { + $this->request = new Request(array('server' => array('Origin' => 'test'))); + $this->newsAPI = new NewsAPI($this->api, $this->request, $this->updater); + $response = $this->newsAPI->cors(); + + $headers = $response->getHeaders(); + + $this->assertEquals('test', $headers['Access-Control-Allow-Origin']); + } + + } |