@@ -0,0 +1,2886 @@
+import pytest%0Afrom http import client%0Afrom unittest import mock%0Aimport functools%0A%0Aimport aiohttp%0A%0Afrom tornado import gen%0Afrom tornado import testing%0Afrom tornado import httpclient%0A%0Afrom tests import utils%0Afrom tests.server.api.v1.utils import ServerTestCase%0A%0Afrom waterbutler.server.utils import CORsMixin%0A%0Aclass MockHandler(CORsMixin):%0A%0A    request = None%0A    headers = %7B%7D%0A%0A    def set_header(self, key, value):%0A        self.headers%5Bkey%5D = value%0A%0Aclass MockRequest(object):%0A%0A    def __init__(%0A            self,%0A            origin=None,%0A            method='GET',%0A            cookies=None,%0A            headers=None%0A    ):%0A        self.origin = origin or ''%0A        self.method = method%0A        self.cookies = cookies or True%0A        self.headers = headers or %7B%0A            'Origin': origin%0A        %7D%0A%0Aclass TestCORsMixin(ServerTestCase):%0A%0A    def setUp(self, *args, **kwargs):%0A        super(TestCORsMixin, self).setUp(*args, **kwargs)%0A        self.handler = MockHandler()%0A%0A    @testing.gen_test%0A    def test_set_default_headers_options(self):%0A        origin = 'http://foo.com'%0A%0A        self.handler.request = MockRequest(%0A            origin=origin,%0A            method='OPTIONS'%0A        )%0A        self.handler.set_default_headers()%0A        assert origin == self.handler.headers%5B'Access-Control-Allow-Origin'%5D%0A%0A    @testing.gen_test%0A    def test_set_default_headers_cross_origin_with_cookie(self):%0A        origin = 'http://foo.com'%0A%0A        for method in ('GET', 'POST', 'PUT', 'PATCH', 'DELETE'):%0A            self.handler.request = MockRequest(%0A                origin=origin,%0A                method='GET',%0A                cookies=True%0A            )%0A            self.handler.set_default_headers()%0A            assert origin not in self.handler.headers%5B'Access-Control-Allow-Origin'%5D%0A%0A    @testing.gen_test%0A    def test_set_default_headers_cross_origin_no_cookie_no_auth_header(self):%0A        origin = 'http://foo.com'%0A%0A        for method in ('GET', 'POST', 'PUT', 'PATCH', 'DELETE'):%0A            self.handler.request = MockRequest(%0A                origin=origin,%0A                method='GET',%0A                cookies=False,%0A                headers=None%0A            )%0A            self.handler.set_default_headers()%0A            assert origin not in self.handler.headers%5B'Access-Control-Allow-Origin'%5D%0A%0A    @testing.gen_test%0A    def test_set_default_headers_cross_origin_no_cookie_but_auth_header(self):%0A        origin = 'http://foo.com'%0A%0A        for method in ('GET', 'POST', 'PUT', 'PATCH', 'DELETE'):%0A            self.handler.request = MockRequest(%0A                origin=origin,%0A                method='GET',%0A                cookies=False,%0A                headers=%7B%0A                    'Authorization': 'asdlisdfgluiwgqruf'%0A                %7D%0A            )%0A            self.handler.set_default_headers()%0A            assert origin not in self.handler.headers%5B'Access-Control-Allow-Origin'%5D%0A

Add CORsMixin tests