def test_prepare_request_with_overridden_host(self): factory = RequestFactory() request = factory.post("/sso/saml/classProvider/acs/", **dict(HTTP_HOST="garbage.com", )) req = prepare_django_request(request) self.assertEqual(req["script_name"], "/sso/saml/classProvider/acs/") self.assertEqual(req["http_host"], "abc.example.org")
def test_prepare_https_request_with_POST_no_proxy(self): factory = RequestFactory() request = factory.post("/sso/saml/?provider=classProvider", secure=True, **dict(HTTP_HOST="example.com")) req = prepare_django_request(request) self.assertEqual(req["get_data"]["provider"], "classProvider") self.assertEqual(req["https"], "on") self.assertEqual(req["script_name"], "/sso/saml/") self.assertEqual(req["http_host"], "example.com")
def test_prepare_https_request_with_GET_plus_proxy(self): factory = RequestFactory() request = factory.get( "/sso/saml/?provider=classProvider", **dict( HTTP_X_FORWARDED_FOR="10.10.10.10", HTTP_X_FORWARDED_PROTO="https", HTTP_HOST="example.com", )) req = prepare_django_request(request) self.assertEqual(req["get_data"]["provider"], "classProvider") self.assertEqual(req["https"], "on") self.assertEqual(req["script_name"], "/sso/saml/") self.assertEqual(req["http_host"], "example.com")