← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/always-https-codebrowse into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/always-https-codebrowse into lp:launchpad.

Commit message:
Construct all links to Bazaar codebrowse using HTTPS.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/always-https-codebrowse/+merge/336376

Especially relevant since bazaar.launchpad.net serves JS.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/always-https-codebrowse into lp:launchpad.
=== modified file 'configs/development/launchpad-lazr.conf'
--- configs/development/launchpad-lazr.conf	2017-09-07 13:25:13 +0000
+++ configs/development/launchpad-lazr.conf	2018-01-19 17:32:19 +0000
@@ -36,7 +36,6 @@
 authentication_endpoint: http://xmlrpc-private.launchpad.dev:8087/authserver
 codehosting_endpoint: http://xmlrpc-private.launchpad.dev:8087/codehosting
 supermirror_root: http://bazaar.launchpad.dev/
-codebrowse_root: http://bazaar.launchpad.dev/
 secure_codebrowse_root: https://bazaar.launchpad.dev/
 internal_branch_by_id_root: http://bazaar-internal.launchpad.dev/
 internal_codebrowse_root: http://localhost:8080/

=== modified file 'lib/launchpad_loggerhead/tests.py'
--- lib/launchpad_loggerhead/tests.py	2018-01-02 10:54:31 +0000
+++ lib/launchpad_loggerhead/tests.py	2018-01-19 17:32:19 +0000
@@ -1,15 +1,9 @@
-# Copyright 2010 Canonical Ltd.  This software is licensed under the
+# Copyright 2010-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
-import cStringIO
-import errno
-import logging
-import re
-import socket
 import urllib
 
 import lazr.uri
-from paste import httpserver
 from paste.httpexceptions import HTTPExceptionHandler
 import wsgi_intercept
 from wsgi_intercept.urllib2_intercept import (
@@ -17,7 +11,6 @@
     uninstall_opener,
     )
 import wsgi_intercept.zope_testbrowser
-import zope.event
 
 from launchpad_loggerhead.app import RootApp
 from launchpad_loggerhead.session import SessionHandler
@@ -37,14 +30,14 @@
 def session_scribbler(app, test):
     """Squirrel away the session variable."""
     def scribble(environ, start_response):
-        test.session = environ[SESSION_VAR] # Yay for mutables.
+        test.session = environ[SESSION_VAR]  # Yay for mutables.
         return app(environ, start_response)
     return scribble
 
 
 def dummy_destination(environ, start_response):
     """Return a fake response."""
-    start_response('200 OK', [('Content-type','text/plain')])
+    start_response('200 OK', [('Content-type', 'text/plain')])
     return ['This is a dummy destination.\n']
 
 
@@ -52,7 +45,7 @@
     """A mock root app that doesn't require open id."""
     def _complete_login(self, environ, start_response):
         environ[SESSION_VAR]['user'] = 'bob'
-        start_response('200 OK', [('Content-type','text/plain')])
+        start_response('200 OK', [('Content-type', 'text/plain')])
         return ['\n']
 
 
@@ -85,7 +78,6 @@
         app = HTTPExceptionHandler(app)
         app = SessionHandler(app, SESSION_VAR, SECRET)
         self.cookie_name = app.cookie_handler.cookie_name
-        self.intercept(config.codehosting.codebrowse_root, app)
         self.intercept(config.codehosting.secure_codebrowse_root, app)
         self.intercept(allvhosts.configs['mainsite'].rooturl,
                        dummy_destination)

=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py	2017-11-24 17:22:34 +0000
+++ lib/lp/code/model/branch.py	2018-01-19 17:32:19 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 __metaclass__ = type
@@ -699,10 +699,7 @@
 
     def getCodebrowseUrl(self, *extras):
         """See `IBranch`."""
-        if self.private:
-            root = config.codehosting.secure_codebrowse_root
-        else:
-            root = config.codehosting.codebrowse_root
+        root = config.codehosting.secure_codebrowse_root
         return urlutils.join(root, self.unique_name, *extras)
 
     def getCodebrowseUrlForRevision(self, revision):

=== modified file 'lib/lp/code/model/tests/test_branch.py'
--- lib/lp/code/model/tests/test_branch.py	2018-01-02 16:10:26 +0000
+++ lib/lp/code/model/tests/test_branch.py	2018-01-19 17:32:19 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for Branches."""
@@ -2281,14 +2281,14 @@
     layer = DatabaseFunctionalLayer
 
     def test_simple(self):
-        # The basic codebrowse URL for a public branch is a 'http' url.
+        # The basic codebrowse URL for a public branch is an 'https' URL.
         branch = self.factory.makeAnyBranch()
         self.assertEqual(
-            'http://bazaar.launchpad.dev/' + branch.unique_name,
+            'https://bazaar.launchpad.dev/' + branch.unique_name,
             branch.getCodebrowseUrl())
 
     def test_private(self):
-        # The codebrowse URL for a private branch is a 'https' url.
+        # The codebrowse URL for a private branch is an 'https' URL.
         owner = self.factory.makePerson()
         branch = self.factory.makeAnyBranch(
             owner=owner, information_type=InformationType.USERDATA)
@@ -2301,7 +2301,7 @@
         # Any arguments to getCodebrowseUrl are appended to the URL.
         branch = self.factory.makeAnyBranch()
         self.assertEqual(
-            'http://bazaar.launchpad.dev/' + branch.unique_name + '/a/b',
+            'https://bazaar.launchpad.dev/' + branch.unique_name + '/a/b',
             branch.getCodebrowseUrl('a', 'b'))
 
     def test_source_code_url(self):

=== modified file 'lib/lp/code/stories/branches/xx-branch-index.txt'
--- lib/lp/code/stories/branches/xx-branch-index.txt	2015-06-27 04:10:49 +0000
+++ lib/lp/code/stories/branches/xx-branch-index.txt	2018-01-19 17:32:19 +0000
@@ -90,7 +90,7 @@
     >>> revision = find_tags_by_class(
     ...         user_browser.contents, 'revision-details', only_first=True)
     >>> print revision.a
-    <a href="http://bazaar.launchpad.dev/~eric/fooix/trunk/revision/5";>5</a>
+    <a href="https://bazaar.launchpad.dev/~eric/fooix/trunk/revision/5";>5</a>
 
 
 Commit messages
@@ -302,7 +302,7 @@
     >>> browser.open(
     ...     'http://code.launchpad.dev/~name12/+junk/junk.dev')
     >>> print browser.getLink('All revisions').url
-    http://bazaar.launchpad.dev/~name12/+junk/junk.dev/changes
+    https://bazaar.launchpad.dev/~name12/+junk/junk.dev/changes
 
 If the branch is private, the browse code link is not shown. In order to
 see the private branch, we need to log in as a user that is able to see

=== modified file 'lib/lp/registry/stories/product/xx-product-code-trunk.txt'
--- lib/lp/registry/stories/product/xx-product-code-trunk.txt	2016-09-19 11:47:33 +0000
+++ lib/lp/registry/stories/product/xx-product-code-trunk.txt	2018-01-19 17:32:19 +0000
@@ -119,7 +119,7 @@
         Configure code for this project
         (http://launchpad.dev/fooix/+configure-code)
       Browse the code
-        (http://bazaar.launchpad.dev/~eric/fooix/trunk/files)
+        (https://bazaar.launchpad.dev/~eric/fooix/trunk/files)
 
 
 Projects with development focus branches
@@ -142,7 +142,7 @@
     Links:
       lp://dev/fooix (http://code.launchpad.dev/~eric/fooix/trunk)
       Browse the code
-        (http://bazaar.launchpad.dev/~eric/fooix/trunk/files)
+        (https://bazaar.launchpad.dev/~eric/fooix/trunk/files)
 
     >>> owner_browser.open('http://launchpad.dev/fooix')
     >>> print_development_focus(owner_browser)
@@ -159,7 +159,7 @@
         Configure code for this project
         (http://launchpad.dev/fooix/+configure-code)
       Browse the code
-        (http://bazaar.launchpad.dev/~eric/fooix/trunk/files)
+        (https://bazaar.launchpad.dev/~eric/fooix/trunk/files)
 
 
 Private development focus branches

=== modified file 'lib/lp/services/config/schema-lazr.conf'
--- lib/lp/services/config/schema-lazr.conf	2017-09-07 13:25:13 +0000
+++ lib/lp/services/config/schema-lazr.conf	2018-01-19 17:32:19 +0000
@@ -266,17 +266,17 @@
 # datatype: boolean
 launch: False
 
+# Obsolete URL prefix, formerly used for links to the Bazaar code browser
+# for public branches.  This can be removed once no production configs refer
+# to it.
+#
+# datatype: urlbase
+codebrowse_root: http://bazaar.launchpad.net/
+
 # The URL prefix for links to the Bazaar code browser.  Links are
 # formed by appending the branch's unique name to the root URL.
 #
 # datatype: urlbase
-codebrowse_root: http://bazaar.launchpad.net/
-
-# The URL prefix for https links to the Bazaar code browser, which
-# allows access to private branches authenticated with OpenID.  Links
-# are formed by appending the branch's unique name to the root URL.
-#
-# datatype: urlbase
 secure_codebrowse_root: https://bazaar.launchpad.net/
 
 

=== modified file 'utilities/community-contributions.py'
--- utilities/community-contributions.py	2016-05-03 12:25:09 +0000
+++ utilities/community-contributions.py	2018-01-19 17:32:19 +0000
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 # -*- coding: utf-8 -*-
 #
-# Copyright 2009-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Show what Launchpad community contributors have done.
@@ -54,7 +54,7 @@
     sys.stderr.write("""ERROR: Unable to import from 'editmoin'. How to solve:
 Get editmoin.py from launchpadlib's "contrib/" directory:
 
-  http://bazaar.launchpad.net/~lazr-developers/launchpadlib/trunk/annotate/head%3A/contrib/editmoin.py
+  https://bazaar.launchpad.net/~lazr-developers/launchpadlib/trunk/annotate/head%3A/contrib/editmoin.py
 
 (Put it in the same directory as this script and everything should work.)
 """)
@@ -66,7 +66,6 @@
     return x.encode('utf-8', 'xmlcharrefreplace')
 
 
-
 # The output contains two classes of contributors: people who don't
 # work for Canonical at all, and people who do work for Canonical but
 # not on the Launchpad team.
@@ -343,18 +342,18 @@
         else:
             date_str = "(NO DATE)"
 
-        rev_url_base = "http://bazaar.launchpad.net/%s/revision/"; % (
+        rev_url_base = "https://bazaar.launchpad.net/%s/revision/"; % (
             self.branch_info.loggerhead_path)
 
         # In loggerhead, you can use either a revision number or a
         # revision ID.  In other words, these would reach the same page:
         #
-        # http://bazaar.launchpad.net/~launchpad-pqm/launchpad/devel/\
+        # https://bazaar.launchpad.net/~launchpad-pqm/launchpad/devel/\
         # revision/9202
         #
         #   -and-
         #
-        # http://bazaar.launchpad.net/~launchpad-pqm/launchpad/devel/\
+        # https://bazaar.launchpad.net/~launchpad-pqm/launchpad/devel/\
         # revision/launchpad@xxxxxxxxxxxxxxxxx-20090821221206-\
         # ritpv21q8w61gbpt
         #
@@ -637,11 +636,12 @@
 cron job running as wgrant on devpad (though if there are no new \
 contributions, the page's timestamp won't change).  The code that \
 generates this page is \
-[[http://bazaar.launchpad.net/%7Elaunchpad-pqm/launchpad/devel/annotate/head%3A/utilities/community-contributions.py|utilities/community-contributions.py]] \
+[[https://bazaar.launchpad.net/%7Elaunchpad-pqm/launchpad/devel/annotate/head%3A/utilities/community-contributions.py|utilities/community-contributions.py]] \
 in the Launchpad tree.''-~
 
 """
 
+
 def main():
     quiet = False
     dry_run = False
@@ -698,8 +698,7 @@
         # Do everything.
         b = Branch.open(branch_info.path)
 
-        logger = log.Logger(b, {'direction' : 'reverse',
-                                'levels' : 0, })
+        logger = log.Logger(b, {'direction': 'reverse', 'levels': 0})
         if not quiet:
             print "Calculating (this may take a while)..."
 
@@ -708,12 +707,14 @@
         logger.show(lec)  # Won't "show" anything -- just gathers data.
 
     page_contents = page_intro + lec.result()
+
     def update_if_modified(moinfile):
         if moinfile._unescape(moinfile.body) == page_contents:
             return 0  # Nothing changed, so cancel the edit.
         else:
             moinfile.body = page_contents
             return 1
+
     if not dry_run:
         if not quiet:
             print "Updating wiki..."


Follow ups