aboutsummaryrefslogtreecommitdiff
path: root/ihatemoney/tests
diff options
context:
space:
mode:
authorAlexis Metaireau <alexis@notmyidea.org>2018-12-25 18:13:58 +0100
committerGitHub <noreply@github.com>2018-12-25 18:13:58 +0100
commit620596e32cbacac62d79d1a9f82cd57136b95b52 (patch)
tree503cce7c21b85f7bc3dd79eac69f22d7c1b4a8b6 /ihatemoney/tests
parentc317bfa576b472aed2e4ec5725bcd33b1dd1b9d8 (diff)
downloadihatemoney-mirror-620596e32cbacac62d79d1a9f82cd57136b95b52.zip
ihatemoney-mirror-620596e32cbacac62d79d1a9f82cd57136b95b52.tar.gz
ihatemoney-mirror-620596e32cbacac62d79d1a9f82cd57136b95b52.tar.bz2
Add CORS to the API. Fix #404 (#407)
Diffstat (limited to 'ihatemoney/tests')
-rw-r--r--ihatemoney/tests/tests.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/ihatemoney/tests/tests.py b/ihatemoney/tests/tests.py
index f368780..17b3a8d 100644
--- a/ihatemoney/tests/tests.py
+++ b/ihatemoney/tests/tests.py
@@ -1020,6 +1020,16 @@ class APITestCase(IhatemoneyTestCase):
('%s:%s' % (username, password)).encode('utf-8')).decode('utf-8').replace('\n', '')
return {"Authorization": "Basic %s" % base64string}
+ def test_cors_requests(self):
+ # Create a project and test that CORS headers are present if requested.
+ resp = self.api_create("raclette")
+ self.assertStatus(201, resp)
+
+ # Try to do an OPTIONS requests and see if the headers are correct.
+ resp = self.client.options("/api/projects/raclette",
+ headers=self.get_auth("raclette"))
+ self.assertEqual(resp.headers['Access-Control-Allow-Origin'], '*')
+
def test_basic_auth(self):
# create a project
resp = self.api_create("raclette")