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

Proposed by Colin Watson
Status: Merged
Merged at revision: 18539
Proposed branch: lp:~cjwatson/launchpad/always-https-codebrowse
Merge into: lp:launchpad
Diff against target: 306 lines (+33/-44)
8 files modified
configs/development/launchpad-lazr.conf (+0/-1)
lib/launchpad_loggerhead/tests.py (+4/-12)
lib/lp/code/model/branch.py (+2/-5)
lib/lp/code/model/tests/test_branch.py (+5/-5)
lib/lp/code/stories/branches/xx-branch-index.txt (+2/-2)
lib/lp/registry/stories/product/xx-product-code-trunk.txt (+3/-3)
lib/lp/services/config/schema-lazr.conf (+7/-7)
utilities/community-contributions.py (+10/-9)
To merge this branch: bzr merge lp:~cjwatson/launchpad/always-https-codebrowse
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+336376@code.launchpad.net

Commit message

Construct all links to Bazaar codebrowse using HTTPS.

Description of the change

Especially relevant since bazaar.launchpad.net serves JS.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
36authentication_endpoint: http://xmlrpc-private.launchpad.dev:8087/authserver36authentication_endpoint: http://xmlrpc-private.launchpad.dev:8087/authserver
37codehosting_endpoint: http://xmlrpc-private.launchpad.dev:8087/codehosting37codehosting_endpoint: http://xmlrpc-private.launchpad.dev:8087/codehosting
38supermirror_root: http://bazaar.launchpad.dev/38supermirror_root: http://bazaar.launchpad.dev/
39codebrowse_root: http://bazaar.launchpad.dev/
40secure_codebrowse_root: https://bazaar.launchpad.dev/39secure_codebrowse_root: https://bazaar.launchpad.dev/
41internal_branch_by_id_root: http://bazaar-internal.launchpad.dev/40internal_branch_by_id_root: http://bazaar-internal.launchpad.dev/
42internal_codebrowse_root: http://localhost:8080/41internal_codebrowse_root: http://localhost:8080/
4342
=== 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 @@
1# Copyright 2010 Canonical Ltd. This software is licensed under the1# Copyright 2010-2018 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4import cStringIO
5import errno
6import logging
7import re
8import socket
9import urllib4import urllib
105
11import lazr.uri6import lazr.uri
12from paste import httpserver
13from paste.httpexceptions import HTTPExceptionHandler7from paste.httpexceptions import HTTPExceptionHandler
14import wsgi_intercept8import wsgi_intercept
15from wsgi_intercept.urllib2_intercept import (9from wsgi_intercept.urllib2_intercept import (
@@ -17,7 +11,6 @@
17 uninstall_opener,11 uninstall_opener,
18 )12 )
19import wsgi_intercept.zope_testbrowser13import wsgi_intercept.zope_testbrowser
20import zope.event
2114
22from launchpad_loggerhead.app import RootApp15from launchpad_loggerhead.app import RootApp
23from launchpad_loggerhead.session import SessionHandler16from launchpad_loggerhead.session import SessionHandler
@@ -37,14 +30,14 @@
37def session_scribbler(app, test):30def session_scribbler(app, test):
38 """Squirrel away the session variable."""31 """Squirrel away the session variable."""
39 def scribble(environ, start_response):32 def scribble(environ, start_response):
40 test.session = environ[SESSION_VAR] # Yay for mutables.33 test.session = environ[SESSION_VAR] # Yay for mutables.
41 return app(environ, start_response)34 return app(environ, start_response)
42 return scribble35 return scribble
4336
4437
45def dummy_destination(environ, start_response):38def dummy_destination(environ, start_response):
46 """Return a fake response."""39 """Return a fake response."""
47 start_response('200 OK', [('Content-type','text/plain')])40 start_response('200 OK', [('Content-type', 'text/plain')])
48 return ['This is a dummy destination.\n']41 return ['This is a dummy destination.\n']
4942
5043
@@ -52,7 +45,7 @@
52 """A mock root app that doesn't require open id."""45 """A mock root app that doesn't require open id."""
53 def _complete_login(self, environ, start_response):46 def _complete_login(self, environ, start_response):
54 environ[SESSION_VAR]['user'] = 'bob'47 environ[SESSION_VAR]['user'] = 'bob'
55 start_response('200 OK', [('Content-type','text/plain')])48 start_response('200 OK', [('Content-type', 'text/plain')])
56 return ['\n']49 return ['\n']
5750
5851
@@ -85,7 +78,6 @@
85 app = HTTPExceptionHandler(app)78 app = HTTPExceptionHandler(app)
86 app = SessionHandler(app, SESSION_VAR, SECRET)79 app = SessionHandler(app, SESSION_VAR, SECRET)
87 self.cookie_name = app.cookie_handler.cookie_name80 self.cookie_name = app.cookie_handler.cookie_name
88 self.intercept(config.codehosting.codebrowse_root, app)
89 self.intercept(config.codehosting.secure_codebrowse_root, app)81 self.intercept(config.codehosting.secure_codebrowse_root, app)
90 self.intercept(allvhosts.configs['mainsite'].rooturl,82 self.intercept(allvhosts.configs['mainsite'].rooturl,
91 dummy_destination)83 dummy_destination)
9284
=== 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 @@
1# Copyright 2009-2017 Canonical Ltd. This software is licensed under the1# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4__metaclass__ = type4__metaclass__ = type
@@ -699,10 +699,7 @@
699699
700 def getCodebrowseUrl(self, *extras):700 def getCodebrowseUrl(self, *extras):
701 """See `IBranch`."""701 """See `IBranch`."""
702 if self.private:702 root = config.codehosting.secure_codebrowse_root
703 root = config.codehosting.secure_codebrowse_root
704 else:
705 root = config.codehosting.codebrowse_root
706 return urlutils.join(root, self.unique_name, *extras)703 return urlutils.join(root, self.unique_name, *extras)
707704
708 def getCodebrowseUrlForRevision(self, revision):705 def getCodebrowseUrlForRevision(self, revision):
709706
=== 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 @@
1# Copyright 2009-2017 Canonical Ltd. This software is licensed under the1# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Tests for Branches."""4"""Tests for Branches."""
@@ -2281,14 +2281,14 @@
2281 layer = DatabaseFunctionalLayer2281 layer = DatabaseFunctionalLayer
22822282
2283 def test_simple(self):2283 def test_simple(self):
2284 # The basic codebrowse URL for a public branch is a 'http' url.2284 # The basic codebrowse URL for a public branch is an 'https' URL.
2285 branch = self.factory.makeAnyBranch()2285 branch = self.factory.makeAnyBranch()
2286 self.assertEqual(2286 self.assertEqual(
2287 'http://bazaar.launchpad.dev/' + branch.unique_name,2287 'https://bazaar.launchpad.dev/' + branch.unique_name,
2288 branch.getCodebrowseUrl())2288 branch.getCodebrowseUrl())
22892289
2290 def test_private(self):2290 def test_private(self):
2291 # The codebrowse URL for a private branch is a 'https' url.2291 # The codebrowse URL for a private branch is an 'https' URL.
2292 owner = self.factory.makePerson()2292 owner = self.factory.makePerson()
2293 branch = self.factory.makeAnyBranch(2293 branch = self.factory.makeAnyBranch(
2294 owner=owner, information_type=InformationType.USERDATA)2294 owner=owner, information_type=InformationType.USERDATA)
@@ -2301,7 +2301,7 @@
2301 # Any arguments to getCodebrowseUrl are appended to the URL.2301 # Any arguments to getCodebrowseUrl are appended to the URL.
2302 branch = self.factory.makeAnyBranch()2302 branch = self.factory.makeAnyBranch()
2303 self.assertEqual(2303 self.assertEqual(
2304 'http://bazaar.launchpad.dev/' + branch.unique_name + '/a/b',2304 'https://bazaar.launchpad.dev/' + branch.unique_name + '/a/b',
2305 branch.getCodebrowseUrl('a', 'b'))2305 branch.getCodebrowseUrl('a', 'b'))
23062306
2307 def test_source_code_url(self):2307 def test_source_code_url(self):
23082308
=== 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 @@
90 >>> revision = find_tags_by_class(90 >>> revision = find_tags_by_class(
91 ... user_browser.contents, 'revision-details', only_first=True)91 ... user_browser.contents, 'revision-details', only_first=True)
92 >>> print revision.a92 >>> print revision.a
93 <a href="http://bazaar.launchpad.dev/~eric/fooix/trunk/revision/5">5</a>93 <a href="https://bazaar.launchpad.dev/~eric/fooix/trunk/revision/5">5</a>
9494
9595
96Commit messages96Commit messages
@@ -302,7 +302,7 @@
302 >>> browser.open(302 >>> browser.open(
303 ... 'http://code.launchpad.dev/~name12/+junk/junk.dev')303 ... 'http://code.launchpad.dev/~name12/+junk/junk.dev')
304 >>> print browser.getLink('All revisions').url304 >>> print browser.getLink('All revisions').url
305 http://bazaar.launchpad.dev/~name12/+junk/junk.dev/changes305 https://bazaar.launchpad.dev/~name12/+junk/junk.dev/changes
306306
307If the branch is private, the browse code link is not shown. In order to307If the branch is private, the browse code link is not shown. In order to
308see the private branch, we need to log in as a user that is able to see308see the private branch, we need to log in as a user that is able to see
309309
=== 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 @@
119 Configure code for this project119 Configure code for this project
120 (http://launchpad.dev/fooix/+configure-code)120 (http://launchpad.dev/fooix/+configure-code)
121 Browse the code121 Browse the code
122 (http://bazaar.launchpad.dev/~eric/fooix/trunk/files)122 (https://bazaar.launchpad.dev/~eric/fooix/trunk/files)
123123
124124
125Projects with development focus branches125Projects with development focus branches
@@ -142,7 +142,7 @@
142 Links:142 Links:
143 lp://dev/fooix (http://code.launchpad.dev/~eric/fooix/trunk)143 lp://dev/fooix (http://code.launchpad.dev/~eric/fooix/trunk)
144 Browse the code144 Browse the code
145 (http://bazaar.launchpad.dev/~eric/fooix/trunk/files)145 (https://bazaar.launchpad.dev/~eric/fooix/trunk/files)
146146
147 >>> owner_browser.open('http://launchpad.dev/fooix')147 >>> owner_browser.open('http://launchpad.dev/fooix')
148 >>> print_development_focus(owner_browser)148 >>> print_development_focus(owner_browser)
@@ -159,7 +159,7 @@
159 Configure code for this project159 Configure code for this project
160 (http://launchpad.dev/fooix/+configure-code)160 (http://launchpad.dev/fooix/+configure-code)
161 Browse the code161 Browse the code
162 (http://bazaar.launchpad.dev/~eric/fooix/trunk/files)162 (https://bazaar.launchpad.dev/~eric/fooix/trunk/files)
163163
164164
165Private development focus branches165Private development focus branches
166166
=== 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 @@
266# datatype: boolean266# datatype: boolean
267launch: False267launch: False
268268
269# Obsolete URL prefix, formerly used for links to the Bazaar code browser
270# for public branches. This can be removed once no production configs refer
271# to it.
272#
273# datatype: urlbase
274codebrowse_root: http://bazaar.launchpad.net/
275
269# The URL prefix for links to the Bazaar code browser. Links are276# The URL prefix for links to the Bazaar code browser. Links are
270# formed by appending the branch's unique name to the root URL.277# formed by appending the branch's unique name to the root URL.
271#278#
272# datatype: urlbase279# datatype: urlbase
273codebrowse_root: http://bazaar.launchpad.net/
274
275# The URL prefix for https links to the Bazaar code browser, which
276# allows access to private branches authenticated with OpenID. Links
277# are formed by appending the branch's unique name to the root URL.
278#
279# datatype: urlbase
280secure_codebrowse_root: https://bazaar.launchpad.net/280secure_codebrowse_root: https://bazaar.launchpad.net/
281281
282282
283283
=== 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 @@
1#!/usr/bin/python1#!/usr/bin/python
2# -*- coding: utf-8 -*-2# -*- coding: utf-8 -*-
3#3#
4# Copyright 2009-2016 Canonical Ltd. This software is licensed under the4# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
5# GNU Affero General Public License version 3 (see the file LICENSE).5# GNU Affero General Public License version 3 (see the file LICENSE).
66
7"""Show what Launchpad community contributors have done.7"""Show what Launchpad community contributors have done.
@@ -54,7 +54,7 @@
54 sys.stderr.write("""ERROR: Unable to import from 'editmoin'. How to solve:54 sys.stderr.write("""ERROR: Unable to import from 'editmoin'. How to solve:
55Get editmoin.py from launchpadlib's "contrib/" directory:55Get editmoin.py from launchpadlib's "contrib/" directory:
5656
57 http://bazaar.launchpad.net/~lazr-developers/launchpadlib/trunk/annotate/head%3A/contrib/editmoin.py57 https://bazaar.launchpad.net/~lazr-developers/launchpadlib/trunk/annotate/head%3A/contrib/editmoin.py
5858
59(Put it in the same directory as this script and everything should work.)59(Put it in the same directory as this script and everything should work.)
60""")60""")
@@ -66,7 +66,6 @@
66 return x.encode('utf-8', 'xmlcharrefreplace')66 return x.encode('utf-8', 'xmlcharrefreplace')
6767
6868
69
70# The output contains two classes of contributors: people who don't69# The output contains two classes of contributors: people who don't
71# work for Canonical at all, and people who do work for Canonical but70# work for Canonical at all, and people who do work for Canonical but
72# not on the Launchpad team.71# not on the Launchpad team.
@@ -343,18 +342,18 @@
343 else:342 else:
344 date_str = "(NO DATE)"343 date_str = "(NO DATE)"
345344
346 rev_url_base = "http://bazaar.launchpad.net/%s/revision/" % (345 rev_url_base = "https://bazaar.launchpad.net/%s/revision/" % (
347 self.branch_info.loggerhead_path)346 self.branch_info.loggerhead_path)
348347
349 # In loggerhead, you can use either a revision number or a348 # In loggerhead, you can use either a revision number or a
350 # revision ID. In other words, these would reach the same page:349 # revision ID. In other words, these would reach the same page:
351 #350 #
352 # http://bazaar.launchpad.net/~launchpad-pqm/launchpad/devel/\351 # https://bazaar.launchpad.net/~launchpad-pqm/launchpad/devel/\
353 # revision/9202352 # revision/9202
354 #353 #
355 # -and-354 # -and-
356 #355 #
357 # http://bazaar.launchpad.net/~launchpad-pqm/launchpad/devel/\356 # https://bazaar.launchpad.net/~launchpad-pqm/launchpad/devel/\
358 # revision/launchpad@pqm.canonical.com-20090821221206-\357 # revision/launchpad@pqm.canonical.com-20090821221206-\
359 # ritpv21q8w61gbpt358 # ritpv21q8w61gbpt
360 #359 #
@@ -637,11 +636,12 @@
637cron job running as wgrant on devpad (though if there are no new \636cron job running as wgrant on devpad (though if there are no new \
638contributions, the page's timestamp won't change). The code that \637contributions, the page's timestamp won't change). The code that \
639generates this page is \638generates this page is \
640[[http://bazaar.launchpad.net/%7Elaunchpad-pqm/launchpad/devel/annotate/head%3A/utilities/community-contributions.py|utilities/community-contributions.py]] \639[[https://bazaar.launchpad.net/%7Elaunchpad-pqm/launchpad/devel/annotate/head%3A/utilities/community-contributions.py|utilities/community-contributions.py]] \
641in the Launchpad tree.''-~640in the Launchpad tree.''-~
642641
643"""642"""
644643
644
645def main():645def main():
646 quiet = False646 quiet = False
647 dry_run = False647 dry_run = False
@@ -698,8 +698,7 @@
698 # Do everything.698 # Do everything.
699 b = Branch.open(branch_info.path)699 b = Branch.open(branch_info.path)
700700
701 logger = log.Logger(b, {'direction' : 'reverse',701 logger = log.Logger(b, {'direction': 'reverse', 'levels': 0})
702 'levels' : 0, })
703 if not quiet:702 if not quiet:
704 print "Calculating (this may take a while)..."703 print "Calculating (this may take a while)..."
705704
@@ -708,12 +707,14 @@
708 logger.show(lec) # Won't "show" anything -- just gathers data.707 logger.show(lec) # Won't "show" anything -- just gathers data.
709708
710 page_contents = page_intro + lec.result()709 page_contents = page_intro + lec.result()
710
711 def update_if_modified(moinfile):711 def update_if_modified(moinfile):
712 if moinfile._unescape(moinfile.body) == page_contents:712 if moinfile._unescape(moinfile.body) == page_contents:
713 return 0 # Nothing changed, so cancel the edit.713 return 0 # Nothing changed, so cancel the edit.
714 else:714 else:
715 moinfile.body = page_contents715 moinfile.body = page_contents
716 return 1716 return 1
717
717 if not dry_run:718 if not dry_run:
718 if not quiet:719 if not quiet:
719 print "Updating wiki..."720 print "Updating wiki..."