def test_proxy_view_authorizes(self): request = DummyRequest(path='/proxy/foo/remote/path/@@view', headers={}) self.mocker.replay() view = ProxyView(request) with self.assertRaises(Forbidden): view.__call__()
def test_proxy_view_authorizes(self): request = DummyRequest( path='/proxy/foo/remote/path/@@view', headers={}) self.mocker.replay() view = ProxyView(request) with self.assertRaises(Forbidden): view.__call__()
def test_proxy_view(self): request = DummyRequest( path='/proxy/foo/remote/path/@@view', params={'foo': 'bar'}, headers={'X-BRIDGE-ORIGIN': 'bar', 'X-BRIDGE-AC': 'john.doe'}, environ={'REMOTE_ADDR': '127.0.0.1'}) self.expect(self.proxy()).result(Response('proxied response')) self.mocker.replay() view = ProxyView(request) response = view.__call__() self.assertTrue(IResponse.providedBy(response)) self.assertEqual(response.body, 'proxied response')
def test_proxy_view(self): request = DummyRequest(path='/proxy/foo/remote/path/@@view', params={'foo': 'bar'}, headers={ 'X-BRIDGE-ORIGIN': 'bar', 'X-BRIDGE-AC': 'john.doe' }, environ={'REMOTE_ADDR': '127.0.0.1'}) self.expect(self.proxy()).result(Response('proxied response')) self.mocker.replay() view = ProxyView(request) response = view.__call__() self.assertTrue(IResponse.providedBy(response)) self.assertEqual(response.body, 'proxied response')
def test_normal_request_logged(self): url = 'http://bridge/proxy/foo/remote/path/@@view' request = DummyRequest(url=url, path='/proxy/foo/remote/path/@@view', headers={ 'X-BRIDGE-ORIGIN': 'bar', 'X-BRIDGE-AC': 'john.doe' }, environ={'REMOTE_ADDR': '127.0.0.1'}) self.expect(self.proxy()).result(Response('proxied response')) self.mocker.replay() view = ProxyView(request) response = view.__call__() self.assertEqual(response.body, 'proxied response') self.assertEqual(self.read_log().strip(), 'INFO GET: "bar" 200 OK (%s)' % url)
def test_normal_request_logged(self): url = 'http://bridge/proxy/foo/remote/path/@@view' request = DummyRequest( url=url, path='/proxy/foo/remote/path/@@view', headers={'X-BRIDGE-ORIGIN': 'bar', 'X-BRIDGE-AC': 'john.doe'}, environ={'REMOTE_ADDR': '127.0.0.1'}) self.expect(self.proxy()).result(Response('proxied response')) self.mocker.replay() view = ProxyView(request) response = view.__call__() self.assertEqual(response.body, 'proxied response') self.assertEqual( self.read_log().strip(), 'INFO GET: "bar" 200 OK (%s)' % url)
def test_forbidden_request_logged(self): url = 'http://bridge/proxy/foo/remote/path/@@view' request = DummyRequest(url=url, headers={ 'X-BRIDGE-ORIGIN': 'wrong-client', 'X-BRIDGE-AC': 'john.doe' }) self.expect(self.proxy()).result(Response('proxied response')) self.mocker.replay() view = ProxyView(request) with self.assertRaises(Forbidden): view() self.assertEqual( self.read_log().strip(), 'ERROR GET: "wrong-client" FAILED (%s): ' % url + \ 'HTTPForbidden: Access was denied to this resource.')