def test_websocket_good_origin(config): config.registry.settings.update({'origins': 'http://good'}) config.include('h.streamer') req = DummyRequest(headers={'Origin': 'http://good'}) req.get_response = MagicMock() res = websocket(req) assert res.code != 403
def test_websocket_same_origin(config): config.include('h.streamer') # example.com is the dummy request default host URL req = DummyRequest(headers={'Origin': 'http://example.com'}) req.get_response = MagicMock() res = websocket(req) assert res.code != 403
def test_websocket_good_origin(config): config.registry.settings.update({"origins": "http://good"}) config.include("h.streamer") req = DummyRequest(headers={"Origin": "http://good"}) req.get_response = MagicMock() res = websocket(req) assert res.code != 403
def test_websocket_bad_origin(): settings = {'origins': 'http://good'} with testConfig(settings=settings) as config: config.include('h.streamer') req = DummyRequest(headers={'Origin': 'http://bad'}) res = websocket(req) assert res.code == 403
def test_websocket_good_origin(): settings = {'origins': 'http://good'} with testConfig(settings=settings) as config: config.include('h.streamer') req = DummyRequest(headers={'Origin': 'http://good'}) req.get_response = MagicMock() res = websocket(req) assert res.code != 403