コード例 #1
0
 def test_preprintproviders_added_to_cors_whitelist(self):
     url = api_v2_url('users/me/')
     domain = urlparse("https://dinoprints.sexy")
     preprintprovider = factories.PreprintProviderFactory(
         domain=domain.geturl().lower(), _id="DinoXiv")
     settings.load_origins_whitelist()
     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())
コード例 #2
0
 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_origins_whitelist()
     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())
コード例 #3
0
ファイル: test_middleware.py プロジェクト: erinspace/osf.io
 def test_preprintproviders_added_to_cors_whitelist(self):
     url = api_v2_url('users/me/')
     domain = urlparse('https://dinoprints.sexy')
     preprintprovider = factories.PreprintProviderFactory(
         domain=domain.geturl().lower(),
         _id='DinoXiv'
     )
     settings.load_origins_whitelist()
     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())
コード例 #4
0
ファイル: test_middleware.py プロジェクト: erinspace/osf.io
 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_origins_whitelist()
     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())
コード例 #5
0
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_origins_whitelist()

application = get_wsgi_application()
コード例 #6
0
ファイル: wsgi.py プロジェクト: CenterForOpenScience/osf.io
#### 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_origins_whitelist()

application = get_wsgi_application()