def test_build_url_other(self): self.assertEqual( build_url("Test", "https://camptocamp.com/toto?titi#tutu", self._create_dummy_request()), ("https://camptocamp.com/toto?titi#tutu", { "Cache-Control": "no-cache", }))
def test_build_url_forward_headers(self): request = DummyRequest() request.environ = { "SERVER_NAME": "example.com" } request.registry.settings = { "checker": { "forward_headers": ["Cookie"] } } request.headers["Cookie"] = "test" self.assertEqual( build_url( "Test", "https://camptocamp.com/toto?titi#tutu", request ), ( "https://camptocamp.com/toto?titi#tutu", { "Cache-Control": "no-cache", "Cookie": "test", } ) )
def test_build_url_https(self): self.assertEqual( build_url("Test", "https://example.com/toto?titi#tutu", self._create_dummy_request()), ("http://localhost/toto?titi#tutu", { "Cache-Control": "no-cache", "Host": "example.com" }))
def _testurl(self, url): url, headers = build_url("Collect", url, self.request) h = Http() resp, content = h.request(url, headers=headers) if resp.status != httplib.OK: self.status_int = max(self.status_int, resp.status) return '<span style="color: red;">%i - %s</span>' % (resp.status, resp.reason), content return '<span style="color: green;">%s</span>' % content, None
def test_build_url_other(self): self.assertEqual( build_url( "Test", "https://camptocamp.com/toto?titi#tutu", self._create_dummy_request() ), ( "https://camptocamp.com/toto?titi#tutu", { "Cache-Control": "no-cache", } ) )
def test_build_url_https(self): self.assertEqual( build_url( "Test", "https://example.com/toto?titi#tutu", self._create_dummy_request() ), ( "http://localhost/toto?titi#tutu", { "Cache-Control": "no-cache", "Host": "example.com" } ) )
def test_build_url_forward_headers(self): request = DummyRequest() request.environ = {"SERVER_NAME": "example.com"} request.registry.settings = { "checker": { "forward_headers": ["Cookie"] } } request.headers["Cookie"] = "test" self.assertEqual( build_url("Test", "https://camptocamp.com/toto?titi#tutu", request), ("https://camptocamp.com/toto?titi#tutu", { "Cache-Control": "no-cache", "Cookie": "test", }))