Jelmer Vernooij has proposed merging ~jelmer/launchpad:public-https into 
launchpad:master.

Commit message:
Add https as a supported scheme for public branches

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

Add https as a supported scheme for public branches
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~jelmer/launchpad:public-https into launchpad:master.
diff --git a/lib/lp/code/interfaces/branch.py b/lib/lp/code/interfaces/branch.py
index d579132..657ed5d 100644
--- a/lib/lp/code/interfaces/branch.py
+++ b/lib/lp/code/interfaces/branch.py
@@ -277,11 +277,11 @@ class IBranchView(
     id = Int(title=_("ID"), readonly=True, required=True)
 
     @operation_parameters(
-        scheme=TextLine(title=_("URL scheme"), default="http")
+        scheme=TextLine(title=_("URL scheme"), default="https")
     )
     @export_read_operation()
     @operation_for_version("beta")
-    def composePublicURL(scheme="http"):
+    def composePublicURL(scheme="https"):
         """Return a public URL for the branch using the given protocol.
 
         :param scheme: a protocol name accepted by the public
diff --git a/lib/lp/code/interfaces/codehosting.py b/lib/lp/code/interfaces/codehosting.py
index 6c3be3a..86c1fa1 100644
--- a/lib/lp/code/interfaces/codehosting.py
+++ b/lib/lp/code/interfaces/codehosting.py
@@ -68,7 +68,7 @@ def branch_id_alias(branch):
 
 
 # The scheme types that are supported for codehosting.
-SUPPORTED_SCHEMES = "bzr+ssh", "http"
+SUPPORTED_SCHEMES = "bzr+ssh", "http", "https"
 
 
 class IBazaarApplication(ILaunchpadApplication):
diff --git a/lib/lp/code/model/branch.py b/lib/lp/code/model/branch.py
index 71c7fc9..0dcc350 100644
--- a/lib/lp/code/model/branch.py
+++ b/lib/lp/code/model/branch.py
@@ -810,10 +810,10 @@ class Branch(SQLBase, WebhookTargetMixin, BzrIdentityMixin):
     def browse_source_url(self):
         return self.getCodebrowseUrl("files")
 
-    def composePublicURL(self, scheme="http"):
+    def composePublicURL(self, scheme="https"):
         """See `IBranch`."""
         # Not all protocols work for private branches.
-        public_schemes = ["http"]
+        public_schemes = ["https", "http"]
         assert not (self.private and scheme in public_schemes), (
             "Private branch %s has no public URL." % self.unique_name
         )
diff --git a/lib/lp/code/tests/test_branch.py b/lib/lp/code/tests/test_branch.py
index 065f8cd..6c7f1be 100644
--- a/lib/lp/code/tests/test_branch.py
+++ b/lib/lp/code/tests/test_branch.py
@@ -379,10 +379,10 @@ class TestComposePublicURL(TestCaseWithFactory):
         sftp_url = branch.composePublicURL("sftp")
         self.assertEqual(url_pattern % "sftp", sftp_url)
 
-    def test_composePublicURL_default_http(self):
+    def test_composePublicURL_default_https(self):
         # The default scheme for composePublicURL is http.
         branch = self.factory.makeAnyBranch()
-        prefix = "http://";
+        prefix = "https://";
         public_url = branch.composePublicURL()
         self.assertEqual(prefix, public_url[: len(prefix)])
 
@@ -398,8 +398,7 @@ class TestComposePublicURL(TestCaseWithFactory):
         )
         self.assertRaises(AssertionError, branch.composePublicURL, "http")
 
-    def test_composePublicURL_no_https(self):
-        # There's no https support.  If there were, it should probably
-        # not work for private branches.
+    def test_composePublicURL_https_private(self):
+        # Private branches don't have public https URLs.
         branch = self.factory.makeAnyBranch()
         self.assertRaises(AssertionError, branch.composePublicURL, "https")
_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to