예제 #1
0
    def test_cors_headers_extension(self):
        # definining headers in the service and in the view
        service = Service('coconuts',
                          '/migrate',
                          cors_headers=('X-Header-Foobar'))
        service.add_view('POST', _stub, cors_headers=('X-Header-Barbaz'))
        self.assertIn('X-Header-Foobar', service.cors_supported_headers_for())
        self.assertIn('X-Header-Barbaz', service.cors_supported_headers_for())

        # check that adding the same header twice doesn't make bad things
        # happen
        service.add_view(
            'POST',
            _stub,
            cors_headers=('X-Header-Foobar'),
        )
        self.assertEqual(len(service.cors_supported_headers_for()), 2)

        # check that adding a header on a cors disabled method doesn't
        # change anything
        service.add_view('put',
                         _stub,
                         cors_headers=('X-Another-Header', ),
                         cors_enabled=False)

        self.assertNotIn('X-Another-Header',
                         service.cors_supported_headers_for())
예제 #2
0
    def test_cors_headers_for_service_instanciation(self):
        # When definining services, it's possible to add headers. This tests
        # it is possible to list all the headers supported by a service.
        service = Service("coconuts", "/migrate", cors_headers=("X-Header-Coconut"))
        self.assertNotIn("X-Header-Coconut", service.cors_supported_headers_for())

        service.add_view("POST", _stub)
        self.assertIn("X-Header-Coconut", service.cors_supported_headers_for())
예제 #3
0
    def test_cors_headers_for_service_instanciation(self):
        # When definining services, it's possible to add headers. This tests
        # it is possible to list all the headers supported by a service.
        service = Service('coconuts', '/migrate',
                          cors_headers=('X-Header-Coconut'))
        self.assertNotIn('X-Header-Coconut',
                         service.cors_supported_headers_for())

        service.add_view('POST', _stub)
        self.assertIn('X-Header-Coconut', service.cors_supported_headers_for())
예제 #4
0
    def test_cors_headers_for_service_instanciation(self):
        # When definining services, it's possible to add headers. This tests
        # it is possible to list all the headers supported by a service.
        service = Service('coconuts', '/migrate',
                          cors_headers=('X-Header-Coconut'))
        self.assertNotIn('X-Header-Coconut',
                         service.cors_supported_headers_for())

        service.add_view('POST', _stub)
        self.assertIn('X-Header-Coconut', service.cors_supported_headers_for())
예제 #5
0
 def test_cors_headers_for_method(self):
     # defining headers in the view should work.
     service = Service("coconuts", "/migrate")
     service.add_view("GET", _stub, cors_headers=("X-Header-Foobar"))
     service.add_view("POST", _stub, cors_headers=("X-Header-Barbaz"))
     get_headers = service.cors_supported_headers_for(method="GET")
     self.assertNotIn("X-Header-Barbaz", get_headers)
예제 #6
0
 def test_cors_headers_for_method(self):
     # defining headers in the view should work.
     service = Service('coconuts', '/migrate')
     service.add_view('GET', _stub, cors_headers=('X-Header-Foobar'))
     service.add_view('POST', _stub, cors_headers=('X-Header-Barbaz'))
     get_headers = service.cors_supported_headers_for(method='GET')
     self.assertNotIn('X-Header-Barbaz', get_headers)
예제 #7
0
 def test_cors_headers_for_method(self):
     # defining headers in the view should work.
     service = Service('coconuts', '/migrate')
     service.add_view('GET', _stub, cors_headers=('X-Header-Foobar'))
     service.add_view('POST', _stub, cors_headers=('X-Header-Barbaz'))
     get_headers = service.cors_supported_headers_for(method='GET')
     self.assertNotIn('X-Header-Barbaz', get_headers)
예제 #8
0
 def test_cors_headers_for_method_are_deduplicated(self):
     # defining headers in the view should work.
     service = Service("coconuts", "/migrate")
     service.cors_headers = ("X-Header-Foobar",)
     service.add_view("GET", _stub, cors_headers=("X-Header-Foobar", "X-Header-Barbaz"))
     get_headers = service.cors_supported_headers_for(method="GET")
     expected = set(["X-Header-Foobar", "X-Header-Barbaz"])
     self.assertEqual(expected, get_headers)
예제 #9
0
    def test_cors_headers_extension(self):
        # definining headers in the service and in the view
        service = Service("coconuts", "/migrate", cors_headers=("X-Header-Foobar"))
        service.add_view("POST", _stub, cors_headers=("X-Header-Barbaz"))
        self.assertIn("X-Header-Foobar", service.cors_supported_headers_for())
        self.assertIn("X-Header-Barbaz", service.cors_supported_headers_for())

        # check that adding the same header twice doesn't make bad things
        # happen
        service.add_view("POST", _stub, cors_headers=("X-Header-Foobar"))
        self.assertEqual(len(service.cors_supported_headers_for()), 2)

        # check that adding a header on a cors disabled method doesn't
        # change anything
        service.add_view("put", _stub, cors_headers=("X-Another-Header",), cors_enabled=False)

        self.assertNotIn("X-Another-Header", service.cors_supported_headers_for())
예제 #10
0
 def test_cors_headers_for_method_are_deduplicated(self):
     # defining headers in the view should work.
     service = Service('coconuts', '/migrate')
     service.cors_headers = ('X-Header-Foobar',)
     service.add_view('GET', _stub,
                      cors_headers=('X-Header-Foobar', 'X-Header-Barbaz'))
     get_headers = service.cors_supported_headers_for(method='GET')
     expected = set(['X-Header-Foobar', 'X-Header-Barbaz'])
     self.assertEqual(expected, get_headers)
예제 #11
0
 def test_cors_headers_for_method_are_deduplicated(self):
     # defining headers in the view should work.
     service = Service('coconuts', '/migrate')
     service.cors_headers = ('X-Header-Foobar',)
     service.add_view('GET', _stub,
                      cors_headers=('X-Header-Foobar', 'X-Header-Barbaz'))
     get_headers = service.cors_supported_headers_for(method='GET')
     expected = set(['X-Header-Foobar', 'X-Header-Barbaz'])
     self.assertEqual(expected, get_headers)
예제 #12
0
    def test_cors_headers_extension(self):
        # definining headers in the service and in the view
        service = Service('coconuts', '/migrate',
                          cors_headers=('X-Header-Foobar'))
        service.add_view('POST', _stub, cors_headers=('X-Header-Barbaz'))
        self.assertIn('X-Header-Foobar', service.cors_supported_headers_for())
        self.assertIn('X-Header-Barbaz', service.cors_supported_headers_for())

        # check that adding the same header twice doesn't make bad things
        # happen
        service.add_view('POST', _stub, cors_headers=('X-Header-Foobar'),)
        self.assertEqual(len(service.cors_supported_headers_for()), 2)

        # check that adding a header on a cors disabled method doesn't
        # change anything
        service.add_view('put', _stub,
                         cors_headers=('X-Another-Header',),
                         cors_enabled=False)

        self.assertNotIn('X-Another-Header',
                         service.cors_supported_headers_for())
예제 #13
0
 def test_cors_headers_for_view_definition(self):
     # defining headers in the view should work.
     service = Service("coconuts", "/migrate")
     service.add_view("POST", _stub, cors_headers=("X-Header-Foobar"))
     self.assertIn("X-Header-Foobar", service.cors_supported_headers_for())
예제 #14
0
 def test_cors_headers_for_view_definition(self):
     # defining headers in the view should work.
     service = Service('coconuts', '/migrate')
     service.add_view('POST', _stub, cors_headers=('X-Header-Foobar'))
     self.assertIn('X-Header-Foobar', service.cors_supported_headers_for())
예제 #15
0
 def test_cors_headers_for_view_definition(self):
     # defining headers in the view should work.
     service = Service('coconuts', '/migrate')
     service.add_view('POST', _stub, cors_headers=('X-Header-Foobar'))
     self.assertIn('X-Header-Foobar', service.cors_supported_headers_for())