forked from brutasse/graphite-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_http.py
33 lines (26 loc) · 1.15 KB
/
test_http.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from . import TestCase
class HttpTestCase(TestCase):
def test_cors(self):
response = self.app.options('/render')
self.assertFalse(
'Access-Control-Allow-Origin' in response.headers.keys())
response = self.app.options('/render', headers=(
('Origin', 'https://example.com'),
))
self.assertEqual(response.headers['Access-Control-Allow-Origin'],
'https://example.com')
response = self.app.options('/render', headers=(
('Origin', 'http://foo.example.com:8888'),
))
self.assertEqual(response.headers['Access-Control-Allow-Origin'],
'http://foo.example.com:8888')
response = self.app.options('/', headers=(
('Origin', 'http://foo.example.com'),
))
self.assertFalse(
'Access-Control-Allow-Origin' in response.headers.keys())
def test_trailing_slash(self):
response = self.app.get('/render?target=foo')
self.assertEqual(response.status_code, 200)
response = self.app.get('/render/?target=foo')
self.assertEqual(response.status_code, 200)