← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:po-export-https into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:po-export-https into launchpad:master.

Commit message:
Send HTTPS URLs in translation export emails

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1441416 in Launchpad itself: "Translation downloads should provide https link"
  https://bugs.launchpad.net/launchpad/+bug/1441416

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/380475

These were originally HTTP due to performance concerns, but those concerns became obsolete quite some time ago.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:po-export-https into launchpad:master.
diff --git a/lib/lp/translations/scripts/po_export_queue.py b/lib/lp/translations/scripts/po_export_queue.py
index c66f93d..f8bcf9b 100644
--- a/lib/lp/translations/scripts/po_export_queue.py
+++ b/lib/lp/translations/scripts/po_export_queue.py
@@ -291,7 +291,7 @@ class ExportResult:
             name=path, size=self.exported_file.size, file=self.exported_file,
             contentType=self.exported_file.content_type)
 
-        self.url = alias.http_url
+        self.url = alias.getURL()
         if logger is not None:
             logger.info("Stored file at %s" % self.url)
 
diff --git a/lib/lp/translations/tests/test_exportresult.py b/lib/lp/translations/tests/test_exportresult.py
index 77d5129..4d26a86 100644
--- a/lib/lp/translations/tests/test_exportresult.py
+++ b/lib/lp/translations/tests/test_exportresult.py
@@ -36,6 +36,13 @@ class TestExportResult(TestCaseWithFactory):
 
     layer = ZopelessDatabaseLayer
 
+    def setUp(self):
+        super(TestExportResult, self).setUp()
+        # In development mode, the librarian is normally configured to
+        # generate HTTP URLs.  Enable HTTPS URLs so that we can test that
+        # ExportResult uses them.
+        self.pushConfig("librarian", use_https=True)
+
     def makeExportResult(self):
         request = [self.factory.makePOFile()]
         requester = self.factory.makePerson()
@@ -55,7 +62,7 @@ class TestExportResult(TestCaseWithFactory):
         export_result.setExportFile(export)
         export_result.upload()
 
-        self.assertIsNot(None, export_result.url)
+        self.assertStartsWith(export_result.url, "https://";)
         sha256 = hashlib.sha256(export.content).hexdigest()
         self.assertEqual(sha256, librarian.aliases.values()[0].content.sha256)
         alias = librarian.findBySHA256(sha256)