diff options
| author | Anton Samarchyan <desecho@gmail.com> | 2016-11-29 18:17:10 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-11-29 18:17:10 -0500 |
| commit | 05d2c5a66dd72c26e5221855e08834a66c844399 (patch) | |
| tree | 9c75bce12b1d9215c5a8ad23edbf6d092a78edb5 /tests/sites_tests | |
| parent | 95627cb0aae375cb5820f051dee768d764fc2e68 (diff) | |
Fixed #27181 -- Allowed contrib.sites to match domains with trailing ".".
Diffstat (limited to 'tests/sites_tests')
| -rw-r--r-- | tests/sites_tests/tests.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/sites_tests/tests.py b/tests/sites_tests/tests.py index 64fe2215d4..3ea66be9bb 100644 --- a/tests/sites_tests/tests.py +++ b/tests/sites_tests/tests.py @@ -93,6 +93,19 @@ class SitesFrameworkTests(TestCase): site = get_current_site(request) self.assertEqual(site.name, "example.com") + @override_settings(SITE_ID='', ALLOWED_HOSTS=['example.com']) + def test_get_current_site_host_with_trailing_dot(self): + """ + The site is matched if the name in the request has a trailing dot. + """ + request = HttpRequest() + request.META = { + 'SERVER_NAME': 'example.com.', + 'SERVER_PORT': '80', + } + site = get_current_site(request) + self.assertEqual(site.name, 'example.com') + @override_settings(SITE_ID='', ALLOWED_HOSTS=['example.com', 'example.net']) def test_get_current_site_no_site_id_and_handle_port_fallback(self): request = HttpRequest() |
