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
1=== modified file 'configs/development/launchpad-lazr.conf'
2--- configs/development/launchpad-lazr.conf 2017-09-07 13:25:13 +0000
3+++ configs/development/launchpad-lazr.conf 2018-01-19 17:32:19 +0000
4@@ -36,7 +36,6 @@
5 authentication_endpoint: http://xmlrpc-private.launchpad.dev:8087/authserver
6 codehosting_endpoint: http://xmlrpc-private.launchpad.dev:8087/codehosting
7 supermirror_root: http://bazaar.launchpad.dev/
8-codebrowse_root: http://bazaar.launchpad.dev/
9 secure_codebrowse_root: https://bazaar.launchpad.dev/
10 internal_branch_by_id_root: http://bazaar-internal.launchpad.dev/
11 internal_codebrowse_root: http://localhost:8080/
12
13=== modified file 'lib/launchpad_loggerhead/tests.py'
14--- lib/launchpad_loggerhead/tests.py 2018-01-02 10:54:31 +0000
15+++ lib/launchpad_loggerhead/tests.py 2018-01-19 17:32:19 +0000
16@@ -1,15 +1,9 @@
17-# Copyright 2010 Canonical Ltd. This software is licensed under the
18+# Copyright 2010-2018 Canonical Ltd. This software is licensed under the
19 # GNU Affero General Public License version 3 (see the file LICENSE).
20
21-import cStringIO
22-import errno
23-import logging
24-import re
25-import socket
26 import urllib
27
28 import lazr.uri
29-from paste import httpserver
30 from paste.httpexceptions import HTTPExceptionHandler
31 import wsgi_intercept
32 from wsgi_intercept.urllib2_intercept import (
33@@ -17,7 +11,6 @@
34 uninstall_opener,
35 )
36 import wsgi_intercept.zope_testbrowser
37-import zope.event
38
39 from launchpad_loggerhead.app import RootApp
40 from launchpad_loggerhead.session import SessionHandler
41@@ -37,14 +30,14 @@
42 def session_scribbler(app, test):
43 """Squirrel away the session variable."""
44 def scribble(environ, start_response):
45- test.session = environ[SESSION_VAR] # Yay for mutables.
46+ test.session = environ[SESSION_VAR] # Yay for mutables.
47 return app(environ, start_response)
48 return scribble
49
50
51 def dummy_destination(environ, start_response):
52 """Return a fake response."""
53- start_response('200 OK', [('Content-type','text/plain')])
54+ start_response('200 OK', [('Content-type', 'text/plain')])
55 return ['This is a dummy destination.\n']
56
57
58@@ -52,7 +45,7 @@
59 """A mock root app that doesn't require open id."""
60 def _complete_login(self, environ, start_response):
61 environ[SESSION_VAR]['user'] = 'bob'
62- start_response('200 OK', [('Content-type','text/plain')])
63+ start_response('200 OK', [('Content-type', 'text/plain')])
64 return ['\n']
65
66
67@@ -85,7 +78,6 @@
68 app = HTTPExceptionHandler(app)
69 app = SessionHandler(app, SESSION_VAR, SECRET)
70 self.cookie_name = app.cookie_handler.cookie_name
71- self.intercept(config.codehosting.codebrowse_root, app)
72 self.intercept(config.codehosting.secure_codebrowse_root, app)
73 self.intercept(allvhosts.configs['mainsite'].rooturl,
74 dummy_destination)
75
76=== modified file 'lib/lp/code/model/branch.py'
77--- lib/lp/code/model/branch.py 2017-11-24 17:22:34 +0000
78+++ lib/lp/code/model/branch.py 2018-01-19 17:32:19 +0000
79@@ -1,4 +1,4 @@
80-# Copyright 2009-2017 Canonical Ltd. This software is licensed under the
81+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
82 # GNU Affero General Public License version 3 (see the file LICENSE).
83
84 __metaclass__ = type
85@@ -699,10 +699,7 @@
86
87 def getCodebrowseUrl(self, *extras):
88 """See `IBranch`."""
89- if self.private:
90- root = config.codehosting.secure_codebrowse_root
91- else:
92- root = config.codehosting.codebrowse_root
93+ root = config.codehosting.secure_codebrowse_root
94 return urlutils.join(root, self.unique_name, *extras)
95
96 def getCodebrowseUrlForRevision(self, revision):
97
98=== modified file 'lib/lp/code/model/tests/test_branch.py'
99--- lib/lp/code/model/tests/test_branch.py 2018-01-02 16:10:26 +0000
100+++ lib/lp/code/model/tests/test_branch.py 2018-01-19 17:32:19 +0000
101@@ -1,4 +1,4 @@
102-# Copyright 2009-2017 Canonical Ltd. This software is licensed under the
103+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
104 # GNU Affero General Public License version 3 (see the file LICENSE).
105
106 """Tests for Branches."""
107@@ -2281,14 +2281,14 @@
108 layer = DatabaseFunctionalLayer
109
110 def test_simple(self):
111- # The basic codebrowse URL for a public branch is a 'http' url.
112+ # The basic codebrowse URL for a public branch is an 'https' URL.
113 branch = self.factory.makeAnyBranch()
114 self.assertEqual(
115- 'http://bazaar.launchpad.dev/' + branch.unique_name,
116+ 'https://bazaar.launchpad.dev/' + branch.unique_name,
117 branch.getCodebrowseUrl())
118
119 def test_private(self):
120- # The codebrowse URL for a private branch is a 'https' url.
121+ # The codebrowse URL for a private branch is an 'https' URL.
122 owner = self.factory.makePerson()
123 branch = self.factory.makeAnyBranch(
124 owner=owner, information_type=InformationType.USERDATA)
125@@ -2301,7 +2301,7 @@
126 # Any arguments to getCodebrowseUrl are appended to the URL.
127 branch = self.factory.makeAnyBranch()
128 self.assertEqual(
129- 'http://bazaar.launchpad.dev/' + branch.unique_name + '/a/b',
130+ 'https://bazaar.launchpad.dev/' + branch.unique_name + '/a/b',
131 branch.getCodebrowseUrl('a', 'b'))
132
133 def test_source_code_url(self):
134
135=== modified file 'lib/lp/code/stories/branches/xx-branch-index.txt'
136--- lib/lp/code/stories/branches/xx-branch-index.txt 2015-06-27 04:10:49 +0000
137+++ lib/lp/code/stories/branches/xx-branch-index.txt 2018-01-19 17:32:19 +0000
138@@ -90,7 +90,7 @@
139 >>> revision = find_tags_by_class(
140 ... user_browser.contents, 'revision-details', only_first=True)
141 >>> print revision.a
142- <a href="http://bazaar.launchpad.dev/~eric/fooix/trunk/revision/5">5</a>
143+ <a href="https://bazaar.launchpad.dev/~eric/fooix/trunk/revision/5">5</a>
144
145
146 Commit messages
147@@ -302,7 +302,7 @@
148 >>> browser.open(
149 ... 'http://code.launchpad.dev/~name12/+junk/junk.dev')
150 >>> print browser.getLink('All revisions').url
151- http://bazaar.launchpad.dev/~name12/+junk/junk.dev/changes
152+ https://bazaar.launchpad.dev/~name12/+junk/junk.dev/changes
153
154 If the branch is private, the browse code link is not shown. In order to
155 see the private branch, we need to log in as a user that is able to see
156
157=== modified file 'lib/lp/registry/stories/product/xx-product-code-trunk.txt'
158--- lib/lp/registry/stories/product/xx-product-code-trunk.txt 2016-09-19 11:47:33 +0000
159+++ lib/lp/registry/stories/product/xx-product-code-trunk.txt 2018-01-19 17:32:19 +0000
160@@ -119,7 +119,7 @@
161 Configure code for this project
162 (http://launchpad.dev/fooix/+configure-code)
163 Browse the code
164- (http://bazaar.launchpad.dev/~eric/fooix/trunk/files)
165+ (https://bazaar.launchpad.dev/~eric/fooix/trunk/files)
166
167
168 Projects with development focus branches
169@@ -142,7 +142,7 @@
170 Links:
171 lp://dev/fooix (http://code.launchpad.dev/~eric/fooix/trunk)
172 Browse the code
173- (http://bazaar.launchpad.dev/~eric/fooix/trunk/files)
174+ (https://bazaar.launchpad.dev/~eric/fooix/trunk/files)
175
176 >>> owner_browser.open('http://launchpad.dev/fooix')
177 >>> print_development_focus(owner_browser)
178@@ -159,7 +159,7 @@
179 Configure code for this project
180 (http://launchpad.dev/fooix/+configure-code)
181 Browse the code
182- (http://bazaar.launchpad.dev/~eric/fooix/trunk/files)
183+ (https://bazaar.launchpad.dev/~eric/fooix/trunk/files)
184
185
186 Private development focus branches
187
188=== modified file 'lib/lp/services/config/schema-lazr.conf'
189--- lib/lp/services/config/schema-lazr.conf 2017-09-07 13:25:13 +0000
190+++ lib/lp/services/config/schema-lazr.conf 2018-01-19 17:32:19 +0000
191@@ -266,17 +266,17 @@
192 # datatype: boolean
193 launch: False
194
195+# Obsolete URL prefix, formerly used for links to the Bazaar code browser
196+# for public branches. This can be removed once no production configs refer
197+# to it.
198+#
199+# datatype: urlbase
200+codebrowse_root: http://bazaar.launchpad.net/
201+
202 # The URL prefix for links to the Bazaar code browser. Links are
203 # formed by appending the branch's unique name to the root URL.
204 #
205 # datatype: urlbase
206-codebrowse_root: http://bazaar.launchpad.net/
207-
208-# The URL prefix for https links to the Bazaar code browser, which
209-# allows access to private branches authenticated with OpenID. Links
210-# are formed by appending the branch's unique name to the root URL.
211-#
212-# datatype: urlbase
213 secure_codebrowse_root: https://bazaar.launchpad.net/
214
215
216
217=== modified file 'utilities/community-contributions.py'
218--- utilities/community-contributions.py 2016-05-03 12:25:09 +0000
219+++ utilities/community-contributions.py 2018-01-19 17:32:19 +0000
220@@ -1,7 +1,7 @@
221 #!/usr/bin/python
222 # -*- coding: utf-8 -*-
223 #
224-# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
225+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
226 # GNU Affero General Public License version 3 (see the file LICENSE).
227
228 """Show what Launchpad community contributors have done.
229@@ -54,7 +54,7 @@
230 sys.stderr.write("""ERROR: Unable to import from 'editmoin'. How to solve:
231 Get editmoin.py from launchpadlib's "contrib/" directory:
232
233- http://bazaar.launchpad.net/~lazr-developers/launchpadlib/trunk/annotate/head%3A/contrib/editmoin.py
234+ https://bazaar.launchpad.net/~lazr-developers/launchpadlib/trunk/annotate/head%3A/contrib/editmoin.py
235
236 (Put it in the same directory as this script and everything should work.)
237 """)
238@@ -66,7 +66,6 @@
239 return x.encode('utf-8', 'xmlcharrefreplace')
240
241
242-
243 # The output contains two classes of contributors: people who don't
244 # work for Canonical at all, and people who do work for Canonical but
245 # not on the Launchpad team.
246@@ -343,18 +342,18 @@
247 else:
248 date_str = "(NO DATE)"
249
250- rev_url_base = "http://bazaar.launchpad.net/%s/revision/" % (
251+ rev_url_base = "https://bazaar.launchpad.net/%s/revision/" % (
252 self.branch_info.loggerhead_path)
253
254 # In loggerhead, you can use either a revision number or a
255 # revision ID. In other words, these would reach the same page:
256 #
257- # http://bazaar.launchpad.net/~launchpad-pqm/launchpad/devel/\
258+ # https://bazaar.launchpad.net/~launchpad-pqm/launchpad/devel/\
259 # revision/9202
260 #
261 # -and-
262 #
263- # http://bazaar.launchpad.net/~launchpad-pqm/launchpad/devel/\
264+ # https://bazaar.launchpad.net/~launchpad-pqm/launchpad/devel/\
265 # revision/launchpad@pqm.canonical.com-20090821221206-\
266 # ritpv21q8w61gbpt
267 #
268@@ -637,11 +636,12 @@
269 cron job running as wgrant on devpad (though if there are no new \
270 contributions, the page's timestamp won't change). The code that \
271 generates this page is \
272-[[http://bazaar.launchpad.net/%7Elaunchpad-pqm/launchpad/devel/annotate/head%3A/utilities/community-contributions.py|utilities/community-contributions.py]] \
273+[[https://bazaar.launchpad.net/%7Elaunchpad-pqm/launchpad/devel/annotate/head%3A/utilities/community-contributions.py|utilities/community-contributions.py]] \
274 in the Launchpad tree.''-~
275
276 """
277
278+
279 def main():
280 quiet = False
281 dry_run = False
282@@ -698,8 +698,7 @@
283 # Do everything.
284 b = Branch.open(branch_info.path)
285
286- logger = log.Logger(b, {'direction' : 'reverse',
287- 'levels' : 0, })
288+ logger = log.Logger(b, {'direction': 'reverse', 'levels': 0})
289 if not quiet:
290 print "Calculating (this may take a while)..."
291
292@@ -708,12 +707,14 @@
293 logger.show(lec) # Won't "show" anything -- just gathers data.
294
295 page_contents = page_intro + lec.result()
296+
297 def update_if_modified(moinfile):
298 if moinfile._unescape(moinfile.body) == page_contents:
299 return 0 # Nothing changed, so cancel the edit.
300 else:
301 moinfile.body = page_contents
302 return 1
303+
304 if not dry_run:
305 if not quiet:
306 print "Updating wiki..."