mirror of
https://github.com/django/django.git
synced 2025-01-12 03:15:47 +00:00
Fixed get_port test cases.
This commit is contained in:
parent
f7c66b8bc6
commit
4946f0ea9e
@ -1240,10 +1240,11 @@ class HostValidationTests(SimpleTestCase):
|
|||||||
}
|
}
|
||||||
request.get_host()
|
request.get_host()
|
||||||
|
|
||||||
@override_settings(USE_X_FORWARDED_PORT=False)
|
@override_settings(USE_X_FORWARDED_PORT=False, ALLOWED_HOSTS=["internal.com"])
|
||||||
def test_get_port(self):
|
def test_get_port(self):
|
||||||
request = HttpRequest()
|
request = HttpRequest()
|
||||||
request.META = {
|
request.META = {
|
||||||
|
"SERVER_NAME": "internal.com",
|
||||||
"SERVER_PORT": "8080",
|
"SERVER_PORT": "8080",
|
||||||
"HTTP_X_FORWARDED_PORT": "80",
|
"HTTP_X_FORWARDED_PORT": "80",
|
||||||
}
|
}
|
||||||
@ -1252,14 +1253,16 @@ class HostValidationTests(SimpleTestCase):
|
|||||||
|
|
||||||
request = HttpRequest()
|
request = HttpRequest()
|
||||||
request.META = {
|
request.META = {
|
||||||
|
"SERVER_NAME": "internal.com",
|
||||||
"SERVER_PORT": "8080",
|
"SERVER_PORT": "8080",
|
||||||
}
|
}
|
||||||
self.assertEqual(request.get_port(), "8080")
|
self.assertEqual(request.get_port(), "8080")
|
||||||
|
|
||||||
@override_settings(USE_X_FORWARDED_PORT=True)
|
@override_settings(USE_X_FORWARDED_PORT=True, ALLOWED_HOSTS=["internal.com"])
|
||||||
def test_get_port_with_x_forwarded_port(self):
|
def test_get_port_with_x_forwarded_port(self):
|
||||||
request = HttpRequest()
|
request = HttpRequest()
|
||||||
request.META = {
|
request.META = {
|
||||||
|
"SERVER_NAME": "internal.com",
|
||||||
"SERVER_PORT": "8080",
|
"SERVER_PORT": "8080",
|
||||||
"HTTP_X_FORWARDED_PORT": "80",
|
"HTTP_X_FORWARDED_PORT": "80",
|
||||||
}
|
}
|
||||||
@ -1268,6 +1271,7 @@ class HostValidationTests(SimpleTestCase):
|
|||||||
|
|
||||||
request = HttpRequest()
|
request = HttpRequest()
|
||||||
request.META = {
|
request.META = {
|
||||||
|
"SERVER_NAME": "internal.com",
|
||||||
"SERVER_PORT": "8080",
|
"SERVER_PORT": "8080",
|
||||||
}
|
}
|
||||||
self.assertEqual(request.get_port(), "8080")
|
self.assertEqual(request.get_port(), "8080")
|
||||||
|
Loading…
Reference in New Issue
Block a user