From ed32170a0487cdf045b565cc971067504b79aaf0 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Fri, 8 Oct 2010 14:14:05 +0000 Subject: Fixed #13218 -- Ensure that syndicated content served over HTTPS uses https:// links by default. Thanks to schaefer for the report, and Ben Firshman for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14007 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/syndication/tests.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/regressiontests/syndication/tests.py b/tests/regressiontests/syndication/tests.py index 7911657079..76a6c88bc1 100644 --- a/tests/regressiontests/syndication/tests.py +++ b/tests/regressiontests/syndication/tests.py @@ -236,6 +236,25 @@ class SyndicationFeedTest(FeedTestCase): if link.getAttribute('rel') == 'self': self.assertEqual(link.getAttribute('href'), 'http://example.com/customfeedurl/') + def test_secure_urls(self): + """ + Test URLs are prefixed with https:// when feed is requested over HTTPS. + """ + response = self.client.get('/syndication/rss2/', **{ + 'wsgi.url_scheme': 'https', + }) + doc = minidom.parseString(response.content) + chan = doc.getElementsByTagName('channel')[0] + self.assertEqual( + chan.getElementsByTagName('link')[0].firstChild.wholeText[0:5], + 'https' + ) + atom_link = chan.getElementsByTagName('atom:link')[0] + self.assertEqual(atom_link.getAttribute('href')[0:5], 'https') + for link in doc.getElementsByTagName('link'): + if link.getAttribute('rel') == 'self': + self.assertEqual(link.getAttribute('href')[0:5], 'https') + def test_item_link_error(self): """ Test that a ImproperlyConfigured is raised if no link could be found @@ -270,6 +289,10 @@ class SyndicationFeedTest(FeedTestCase): views.add_domain('example.com', '/foo/?arg=value'), 'http://example.com/foo/?arg=value' ) + self.assertEqual( + views.add_domain('example.com', '/foo/?arg=value', True), + 'https://example.com/foo/?arg=value' + ) self.assertEqual( views.add_domain('example.com', 'http://djangoproject.com/doc/'), 'http://djangoproject.com/doc/' -- cgit v1.3