def test_set_upstream_as_argument(self): url = 'http://example.com/' view = ProxyView.as_view(upstream=url) request = self.factory.get('') response = view(request, path='') headers = {u'Cookie': u''} self.urlopen.assert_called_with('GET', url, body=b'', redirect=False, retries=None, preload_content=False, decode_content=False, headers=headers)
def test_url_injection(self): path = 'http://example.org' request = self.factory.get(path) view = ProxyView.as_view(upstream='http://example.com/') view(request, path=path) headers = {u'Cookie': u''} url = 'http://example.com/http://example.org' self.urlopen.assert_called_with('GET', url, body=b'', redirect=False, retries=None, preload_content=False, decode_content=False, headers=headers)
def test_upstream_not_implemented(self): with self.assertRaises(NotImplementedError): proxy_view = ProxyView()
def test_connection_pool_singleton(self): view1 = ProxyView(upstream='http://example.com/') view2 = ProxyView(upstream='http://example.com/') self.assertIs(view1.http, view2.http)
def test_default_add_remote_user_attr(self): proxy_view = ProxyView(upstream='http://www.example.com') self.assertFalse(proxy_view.add_remote_user)