def test_institutions_added_to_cors_whitelist(self): url = api_v2_url('users/me/') domain = urlparse("https://dinosaurs.sexy") institution = factories.InstitutionFactory( domains=[domain.netloc.lower()], name="Institute for Sexy Lizards") settings.load_institutions() request = self.request_factory.get(url, HTTP_ORIGIN=domain.geturl()) response = HttpResponse() self.middleware.process_request(request) processed = self.middleware.process_response(request, response) assert_equal(response['Access-Control-Allow-Origin'], domain.geturl())
def test_institutions_added_to_cors_whitelist(self): url = api_v2_url("users/me/") domain = urlparse("https://dinosaurs.sexy") institution = factories.InstitutionFactory( institution_domains=[domain.netloc.lower()], title="Institute for Sexy Lizards" ) settings.load_institutions() request = self.request_factory.get(url, HTTP_ORIGIN=domain.geturl()) response = HttpResponse() self.middleware.process_request(request) processed = self.middleware.process_response(request, response) assert_equal(response["Access-Control-Allow-Origin"], domain.geturl())
#### WARNING: Here be monkeys ############### import six import sys from rest_framework.fields import Field from rest_framework.request import Request # Cached properties break internal caching # 792005806b50f8aad086a76ff5a742c66a98428e @property def context(self): return getattr(self.root, '_context', {}) # Overriding __getattribute__ is super slow def __getattr__(self, attr): try: return getattr(self._request, attr) except AttributeError: info = sys.exc_info() six.reraise(info[0], info[1], info[2].tb_next) Field.context = context Request.__getattr__ = __getattr__ Request.__getattribute__ = object.__getattribute__ ############# /monkeys #################### init_app(set_backends=True, routes=False, attach_request_handlers=False) api_settings.load_institutions() application = get_wsgi_application()
import six import sys from rest_framework.fields import Field from rest_framework.request import Request # Cached properties break internal caching # 792005806b50f8aad086a76ff5a742c66a98428e @property def context(self): return getattr(self.root, '_context', {}) # Overriding __getattribute__ is super slow def __getattr__(self, attr): try: return getattr(self._request, attr) except AttributeError: info = sys.exc_info() six.reraise(info[0], info[1], info[2].tb_next) Field.context = context Request.__getattr__ = __getattr__ Request.__getattribute__ = object.__getattribute__ ############# /monkeys #################### init_app(set_backends=True, routes=False, attach_request_handlers=False) api_settings.load_institutions() application = get_wsgi_application()