From eccb87d9a03e8021c0b55620db3cbcc34f4e02bb Mon Sep 17 00:00:00 2001 From: Nick Smith Date: Wed, 25 Jun 2014 11:03:30 +0100 Subject: [PATCH] Add routing test for when two sites have the same hostname but different ports --- wagtail/wagtailcore/tests/test_page_model.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wagtail/wagtailcore/tests/test_page_model.py b/wagtail/wagtailcore/tests/test_page_model.py index 1bae57952..cf9a8b7bc 100644 --- a/wagtail/wagtailcore/tests/test_page_model.py +++ b/wagtail/wagtailcore/tests/test_page_model.py @@ -16,6 +16,7 @@ class TestRouting(TestCase): default_site = Site.objects.get(is_default_site=True) events_page = Page.objects.get(url_path='/home/events/') events_site = Site.objects.create(hostname='events.example.com', root_page=events_page) + alternate_port_events_site = Site.objects.create(hostname='events.example.com', root_page=events_page, port='8765') # requests without a Host: header should be directed to the default site request = HttpRequest() @@ -28,6 +29,12 @@ class TestRouting(TestCase): request.META['HTTP_HOST'] = 'events.example.com' self.assertEqual(Site.find_for_request(request), events_site) + # ports in the Host: header should be respected + request = HttpRequest() + request.path = '/' + request.META['HTTP_HOST'] = 'events.example.com:8765' + self.assertEqual(Site.find_for_request(request), alternate_port_events_site) + # requests with an unrecognised Host: header should be directed to the default site request = HttpRequest() request.path = '/'