Merge lp:~jml/launchpad/zeca-is-keyserver into lp:launchpad
- zeca-is-keyserver
- Merge into devel
Status: | Merged |
---|---|
Approved by: | Julian Edwards |
Approved revision: | no longer in the source branch. |
Merged at revision: | 12401 |
Proposed branch: | lp:~jml/launchpad/zeca-is-keyserver |
Merge into: | lp:launchpad |
Diff against target: |
1049 lines (+312/-253) 25 files modified
Makefile (+1/-1) configs/testrunner/launchpad-lazr.conf (+2/-2) lib/canonical/config/schema-lazr.conf (+4/-5) lib/canonical/launchpad/doc/gpghandler.txt (+5/-8) lib/canonical/launchpad/doc/logintoken-pages.txt (+4/-6) lib/canonical/launchpad/ftests/gpgkeys/README (+5/-5) lib/canonical/librarian/testing/server.py (+2/-3) lib/lp/archivepublisher/tests/archive-signing.txt (+6/-9) lib/lp/archivepublisher/tests/test_publisher.py (+8/-10) lib/lp/registry/browser/tests/gpg-views.txt (+4/-5) lib/lp/registry/stories/gpg-coc/01-claimgpg.txt (+5/-7) lib/lp/registry/stories/gpg-coc/11-handle-special-keys.txt (+4/-6) lib/lp/registry/stories/person/xx-person-editgpgkeys-invalid-key.txt (+4/-6) lib/lp/soyuz/doc/soyuz-set-of-uploads.txt (+6/-6) lib/lp/soyuz/doc/soyuz-upload.txt (+6/-6) lib/lp/testing/keyserver/__init__.py (+7/-3) lib/lp/testing/keyserver/harness.py (+20/-111) lib/lp/testing/keyserver/testkeyserver.tac (+12/-17) lib/lp/testing/keyserver/tests/test_harness.py (+27/-9) lib/lp/testing/keyserver/tests/test_locate_key.py (+7/-13) lib/lp/testing/keyserver/tests/test_web.py (+132/-0) lib/lp/testing/keyserver/web.py (+27/-11) lib/lp/testing/matchers.py (+11/-0) lp-sfood-packages (+0/-1) utilities/start-dev-soyuz.sh (+3/-3) |
To merge this branch: | bzr merge lp:~jml/launchpad/zeca-is-keyserver |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Julian Edwards (community) | Approve | ||
Review via email: mp+50166@code.launchpad.net |
Commit message
[r=julian-
Description of the change
You might know about 'zeca'. It's a test key server that lives in our tree and gets used a reasonable amount by soyuz tests.
This branch moves it from canonical.zeca to lp.testing.
Along the way, I made several cleanups:
* Various flakes & copyright bumps
* Added a DocTestMatches matcher that uses our standard flags
* Restructured the keyserver package so that 'harness' (the whole point) is not kept in tests but is instead promoted
* Refactored the way it arranges the web resource hierarchy so the resources themselves are complete
* Changed some doctests to be Python tests, and made them slightly more unit-y
Preview Diff
1 | === modified file 'Makefile' |
2 | --- Makefile 2011-02-05 06:11:48 +0000 |
3 | +++ Makefile 2011-02-17 22:26:32 +0000 |
4 | @@ -394,7 +394,7 @@ |
5 | /var/tmp/mailman-xmlrpc.test \ |
6 | /var/tmp/ppa \ |
7 | /var/tmp/ppa.test \ |
8 | - /var/tmp/zeca |
9 | + /var/tmp/testkeyserver |
10 | # /var/tmp/launchpad_mailqueue is created read-only on ec2test |
11 | # instances. |
12 | if [ -w /var/tmp/launchpad_mailqueue ]; then $(RM) -rf /var/tmp/launchpad_mailqueue; fi |
13 | |
14 | === modified file 'configs/testrunner/launchpad-lazr.conf' |
15 | --- configs/testrunner/launchpad-lazr.conf 2010-09-17 09:16:27 +0000 |
16 | +++ configs/testrunner/launchpad-lazr.conf 2011-02-17 22:26:32 +0000 |
17 | @@ -242,5 +242,5 @@ |
18 | [vhosts] |
19 | use_https: False |
20 | |
21 | -[zeca] |
22 | -root: /var/tmp/zeca.test |
23 | +[testkeyserver] |
24 | +root: /var/tmp/testkeyserver.test |
25 | |
26 | === modified file 'lib/canonical/config/schema-lazr.conf' |
27 | --- lib/canonical/config/schema-lazr.conf 2011-02-03 03:49:36 +0000 |
28 | +++ lib/canonical/config/schema-lazr.conf 2011-02-17 22:26:32 +0000 |
29 | @@ -2091,13 +2091,12 @@ |
30 | debug_log: /var/tmp/windmill-testrunner.log |
31 | |
32 | |
33 | -# Stubed Key server for test proposes, it's able to server |
34 | -# in SKS format, a restricted set of keys. (fixed address at |
35 | -# localhost:11371) |
36 | -[zeca] |
37 | +# Stubed Key server for test proposes, it's able to serve |
38 | +# in SKS format, a restricted set of keys. |
39 | +[testkeyserver] |
40 | # Directory to be created to store the pre-installed key-files |
41 | # datatype: string |
42 | -root: /var/tmp/zeca |
43 | +root: /var/tmp/testkeyserver |
44 | |
45 | |
46 | # Configuration specific for code that is running in the Zopeless |
47 | |
48 | === modified file 'lib/canonical/launchpad/doc/gpghandler.txt' |
49 | --- lib/canonical/launchpad/doc/gpghandler.txt 2010-10-19 18:44:31 +0000 |
50 | +++ lib/canonical/launchpad/doc/gpghandler.txt 2011-02-17 22:26:32 +0000 |
51 | @@ -288,11 +288,11 @@ |
52 | IGPGHandler also allow callsites to upload the public part of a local |
53 | key to the configuration keyserver. |
54 | |
55 | -We will setup and use the test-keyserver (zeca). |
56 | +We will set up and use the test-keyserver. |
57 | |
58 | - >>> from canonical.zeca.ftests.harness import ZecaTestSetup |
59 | - >>> z = ZecaTestSetup() |
60 | - >>> z.setUp() |
61 | + >>> from lp.testing.keyserver import KeyServerTac |
62 | + >>> tac = KeyServerTac() |
63 | + >>> tac.setUp() |
64 | |
65 | Upload the just-generated key to the keyserver so that we can reset |
66 | the local keyring. |
67 | @@ -323,13 +323,10 @@ |
68 | |
69 | >>> gpghandler.uploadPublicKey(new_key.fingerprint) |
70 | |
71 | -Let's shut zeca down. |
72 | - |
73 | - >>> z.tearDown() |
74 | - |
75 | An attempt to upload a key when the keyserver is unreachable results |
76 | in a error. |
77 | |
78 | + >>> tac.tearDown() |
79 | >>> gpghandler.uploadPublicKey(new_key.fingerprint) |
80 | Traceback (most recent call last): |
81 | ... |
82 | |
83 | === modified file 'lib/canonical/launchpad/doc/logintoken-pages.txt' |
84 | --- lib/canonical/launchpad/doc/logintoken-pages.txt 2010-10-18 22:24:59 +0000 |
85 | +++ lib/canonical/launchpad/doc/logintoken-pages.txt 2011-02-17 22:26:32 +0000 |
86 | @@ -40,9 +40,9 @@ |
87 | ... fingerprint='A419AE861E88BC9E04B9C26FBA2B9389DFD20543') |
88 | |
89 | # Start our stub GPG keyserver so that the key can be fetched by the page. |
90 | - >>> from canonical.zeca.ftests.harness import ZecaTestSetup |
91 | - >>> z = ZecaTestSetup() |
92 | - >>> z.setUp() |
93 | + >>> from lp.testing.keyserver import KeyServerTac |
94 | + >>> tac = KeyServerTac() |
95 | + >>> tac.setUp() |
96 | |
97 | >>> request = LaunchpadTestRequest( |
98 | ... SERVER_URL='http://launchpad.dev', |
99 | @@ -58,6 +58,4 @@ |
100 | ... notification.message |
101 | ... for notification in validategpg_view.request.notifications) |
102 | The key 1024D/DFD20543 was successfully validated... |
103 | - |
104 | - # Tear down the stub keyserver. |
105 | - >>> z.tearDown() |
106 | + >>> tac.tearDown() |
107 | |
108 | === modified file 'lib/canonical/launchpad/ftests/gpgkeys/README' |
109 | --- lib/canonical/launchpad/ftests/gpgkeys/README 2006-08-10 22:42:32 +0000 |
110 | +++ lib/canonical/launchpad/ftests/gpgkeys/README 2011-02-17 22:26:32 +0000 |
111 | @@ -1,9 +1,9 @@ |
112 | |
113 | -Keys in lib/canonical/launchpad/ftests/gpgkeys should be symlinked to |
114 | -entries in lib/canonical/zeca/ftests/keys. There should be symlinks for |
115 | -each individual subkey ID; for instance, for a regular sign-and-encrypt |
116 | -key there will be a symlink for the main signing subkey and one for the |
117 | -encryption subkey. |
118 | +Keys in lib/canonical/launchpad/ftests/gpgkeys should be symlinked to entries |
119 | +in lib/lp/testing/keyserver/tests/keys. There should be symlinks for each |
120 | +individual subkey ID; for instance, for a regular sign-and-encrypt key there |
121 | +will be a symlink for the main signing subkey and one for the encryption |
122 | +subkey. |
123 | |
124 | Some information on the keys in this directory: |
125 | |
126 | |
127 | === modified file 'lib/canonical/librarian/testing/server.py' |
128 | --- lib/canonical/librarian/testing/server.py 2011-01-19 03:36:08 +0000 |
129 | +++ lib/canonical/librarian/testing/server.py 2011-02-17 22:26:32 +0000 |
130 | @@ -1,4 +1,4 @@ |
131 | -# Copyright 2009-2010 Canonical Ltd. This software is licensed under the |
132 | +# Copyright 2009-2011 Canonical Ltd. This software is licensed under the |
133 | # GNU Affero General Public License version 3 (see the file LICENSE). |
134 | |
135 | """Fixture for the librarians.""" |
136 | @@ -9,7 +9,6 @@ |
137 | 'LibrarianServerFixture', |
138 | ] |
139 | |
140 | -import atexit |
141 | import os |
142 | import shutil |
143 | import tempfile |
144 | @@ -216,7 +215,7 @@ |
145 | @property |
146 | def logfile(self): |
147 | # Store the log in the server root; if its wanted after a test, that |
148 | - # test can use addDetail to grab the log and include it in its |
149 | + # test can use addDetail to grab the log and include it in its |
150 | # error. |
151 | try: |
152 | return os.path.join(self.root, 'librarian.log') |
153 | |
154 | === modified file 'lib/lp/archivepublisher/tests/archive-signing.txt' |
155 | --- lib/lp/archivepublisher/tests/archive-signing.txt 2010-10-18 22:24:59 +0000 |
156 | +++ lib/lp/archivepublisher/tests/archive-signing.txt 2011-02-17 22:26:32 +0000 |
157 | @@ -19,11 +19,11 @@ |
158 | top-level 'Release' file, named 'Release.gpg' and a ASCII-armoded |
159 | export of the public GPG key (name 'key.gpg') |
160 | |
161 | -We will setup and use the test-keyserver (zeca). |
162 | +We will set up and use the test-keyserver. |
163 | |
164 | - >>> from canonical.zeca.ftests.harness import ZecaTestSetup |
165 | - >>> z = ZecaTestSetup() |
166 | - >>> z.setUp() |
167 | + >>> from lp.testing.keyserver import KeyServerTac |
168 | + >>> tac = KeyServerTac() |
169 | + >>> tac.setUp() |
170 | |
171 | |
172 | Querying 'pending signing key' PPAs |
173 | @@ -427,12 +427,9 @@ |
174 | AssertionError: No signing key available for PPA for Celso Providelo |
175 | |
176 | We'll purge 'signing_keys_root' and the PPA repository root so that |
177 | -other tests don't choke on it. |
178 | +other tests don't choke on it, and shut down the server. |
179 | |
180 | >>> import shutil |
181 | >>> shutil.rmtree(config.personalpackagearchive.signing_keys_root) |
182 | >>> shutil.rmtree(config.personalpackagearchive.root) |
183 | - |
184 | -Let's shut zeca down. |
185 | - |
186 | - >>> z.tearDown() |
187 | + >>> tac.tearDown() |
188 | |
189 | === modified file 'lib/lp/archivepublisher/tests/test_publisher.py' |
190 | --- lib/lp/archivepublisher/tests/test_publisher.py 2011-02-04 05:11:00 +0000 |
191 | +++ lib/lp/archivepublisher/tests/test_publisher.py 2011-02-17 22:26:32 +0000 |
192 | @@ -23,11 +23,8 @@ |
193 | from canonical.database.constants import UTC_NOW |
194 | from canonical.launchpad.ftests.keys_for_tests import gpgkeysdir |
195 | from canonical.launchpad.interfaces.gpghandler import IGPGHandler |
196 | -from canonical.zeca.ftests.harness import ZecaTestSetup |
197 | -from lp.archivepublisher.config import ( |
198 | - Config, |
199 | - getPubConfig, |
200 | - ) |
201 | +from lp.testing.keyserver import KeyServerTac |
202 | +from lp.archivepublisher.config import getPubConfig |
203 | from lp.archivepublisher.diskpool import DiskPool |
204 | from lp.archivepublisher.interfaces.archivesigningkey import ( |
205 | IArchiveSigningKey, |
206 | @@ -1043,8 +1040,9 @@ |
207 | distribution=self.ubuntutest, private=True) |
208 | ppa.buildd_secret = "geheim" |
209 | |
210 | - # Setup the publisher for it and publish its repository. |
211 | - archive_publisher = getPublisher(ppa, [], self.logger) |
212 | + # Set up the publisher for it and publish its repository. |
213 | + # 'getPublisher' is what actually configures the htaccess file. |
214 | + getPublisher(ppa, [], self.logger) |
215 | pubconf = getPubConfig(ppa) |
216 | htaccess_path = os.path.join(pubconf.htaccessroot, ".htaccess") |
217 | self.assertTrue(os.path.exists(htaccess_path)) |
218 | @@ -1286,8 +1284,8 @@ |
219 | self.assertTrue(cprov.archive.signing_key is None) |
220 | |
221 | # Start the test keyserver, so the signing_key can be uploaded. |
222 | - z = ZecaTestSetup() |
223 | - z.setUp() |
224 | + tac = KeyServerTac() |
225 | + tac.setUp() |
226 | |
227 | # Set a signing key for Celso's PPA. |
228 | key_path = os.path.join(gpgkeysdir, 'ppa-sample@canonical.com.sec') |
229 | @@ -1309,4 +1307,4 @@ |
230 | signature.fingerprint, cprov.archive.signing_key.fingerprint) |
231 | |
232 | # All done, turn test-keyserver off. |
233 | - z.tearDown() |
234 | + tac.tearDown() |
235 | |
236 | === modified file 'lib/lp/registry/browser/tests/gpg-views.txt' |
237 | --- lib/lp/registry/browser/tests/gpg-views.txt 2010-10-09 16:36:22 +0000 |
238 | +++ lib/lp/registry/browser/tests/gpg-views.txt 2011-02-17 22:26:32 +0000 |
239 | @@ -7,9 +7,9 @@ |
240 | |
241 | Set up the key server: |
242 | |
243 | - >>> from canonical.zeca.ftests.harness import ZecaTestSetup |
244 | - >>> z = ZecaTestSetup() |
245 | - >>> z.setUp() |
246 | + >>> from lp.testing.keyserver import KeyServerTac |
247 | + >>> tac = KeyServerTac() |
248 | + >>> tac.setUp() |
249 | |
250 | Grab the sample user: |
251 | |
252 | @@ -135,5 +135,4 @@ |
253 | ... |
254 | UnexpectedFormData: Action not permitted: None |
255 | |
256 | -Tear down the key server. |
257 | - >>> z.tearDown() |
258 | + >>> tac.tearDown() |
259 | |
260 | === modified file 'lib/lp/registry/stories/gpg-coc/01-claimgpg.txt' |
261 | --- lib/lp/registry/stories/gpg-coc/01-claimgpg.txt 2010-11-06 12:50:22 +0000 |
262 | +++ lib/lp/registry/stories/gpg-coc/01-claimgpg.txt 2011-02-17 22:26:32 +0000 |
263 | @@ -4,13 +4,13 @@ |
264 | == Setup == |
265 | |
266 | >>> import email |
267 | - >>> from canonical.zeca.ftests.harness import ZecaTestSetup |
268 | + >>> from lp.testing.keyserver import KeyServerTac |
269 | >>> from lp.services.mail import stub |
270 | |
271 | -Setup the stub KeyServer: |
272 | +Set up the stub KeyServer: |
273 | |
274 | - >>> z = ZecaTestSetup() |
275 | - >>> z.setUp() |
276 | + >>> tac = KeyServerTac() |
277 | + >>> tac.setUp() |
278 | |
279 | |
280 | == Claim an encrypting GPG key == |
281 | @@ -358,6 +358,4 @@ |
282 | |
283 | == Teardown == |
284 | |
285 | -Kill stub KeyServer: |
286 | - |
287 | - >>> z.tearDown() |
288 | + >>> tac.tearDown() |
289 | |
290 | === modified file 'lib/lp/registry/stories/gpg-coc/11-handle-special-keys.txt' |
291 | --- lib/lp/registry/stories/gpg-coc/11-handle-special-keys.txt 2010-10-18 22:24:59 +0000 |
292 | +++ lib/lp/registry/stories/gpg-coc/11-handle-special-keys.txt 2011-02-17 22:26:32 +0000 |
293 | @@ -2,11 +2,11 @@ |
294 | special: either invalid, broken, revoked, expired, or already imported. |
295 | |
296 | >>> import email |
297 | - >>> from canonical.zeca.ftests.harness import ZecaTestSetup |
298 | + >>> from lp.testing.keyserver import KeyServerTac |
299 | >>> from lp.services.mail import stub |
300 | |
301 | - >>> z = ZecaTestSetup() |
302 | - >>> z.setUp() |
303 | + >>> tac = KeyServerTac() |
304 | + >>> tac.setUp() |
305 | |
306 | >>> sign_only = "447D BF38 C4F9 C4ED 7522 46B7 7D88 9137 17B0 5A8F" |
307 | >>> preimported = "A419AE861E88BC9E04B9C26FBA2B9389DFD20543" |
308 | @@ -26,7 +26,5 @@ |
309 | ... |
310 | ...has already been imported... |
311 | |
312 | -Finally, kill zeca: |
313 | - |
314 | - >>> z.tearDown() |
315 | + >>> tac.tearDown() |
316 | |
317 | |
318 | === modified file 'lib/lp/registry/stories/person/xx-person-editgpgkeys-invalid-key.txt' |
319 | --- lib/lp/registry/stories/person/xx-person-editgpgkeys-invalid-key.txt 2010-10-18 22:24:59 +0000 |
320 | +++ lib/lp/registry/stories/person/xx-person-editgpgkeys-invalid-key.txt 2011-02-17 22:26:32 +0000 |
321 | @@ -6,12 +6,12 @@ |
322 | >>> from canonical.launchpad.interfaces.authtoken import LoginTokenType |
323 | >>> from canonical.launchpad.ftests import login, logout, ANONYMOUS |
324 | >>> from canonical.launchpad.interfaces.logintoken import ILoginTokenSet |
325 | - >>> from canonical.zeca.ftests.harness import ZecaTestSetup |
326 | + >>> from lp.testing.keyserver import KeyServerTac |
327 | >>> from lp.registry.interfaces.person import IPersonSet |
328 | |
329 | >>> tokenset = getUtility(ILoginTokenSet) |
330 | - >>> z = ZecaTestSetup() |
331 | - >>> z.setUp() |
332 | + >>> tac = KeyServerTac() |
333 | + >>> tac.setUp() |
334 | |
335 | The following keys are used in these tests: |
336 | |
337 | @@ -116,7 +116,5 @@ |
338 | >>> logout() |
339 | |
340 | |
341 | -Kill stub KeyServer |
342 | - |
343 | - >>> z.tearDown() |
344 | + >>> tac.tearDown() |
345 | |
346 | |
347 | === modified file 'lib/lp/soyuz/doc/soyuz-set-of-uploads.txt' |
348 | --- lib/lp/soyuz/doc/soyuz-set-of-uploads.txt 2010-12-22 20:46:21 +0000 |
349 | +++ lib/lp/soyuz/doc/soyuz-set-of-uploads.txt 2011-02-17 22:26:32 +0000 |
350 | @@ -3,7 +3,7 @@ |
351 | This test will: |
352 | |
353 | * Pre-create the directory structure |
354 | - * Turn on the zeca keyserver |
355 | + * Turn on the test keyserver |
356 | * Run process-upload.py |
357 | * Check result |
358 | * Mark packages as ACCEPTED |
359 | @@ -54,13 +54,13 @@ |
360 | database and services to receive it. Since we're using |
361 | 'sample.person@canonical.com' as our Changed-By address and his |
362 | key has signed all the relevant uploads in the suite of uploads we're |
363 | -using, this essentially boils down to ensuring that zeca and the |
364 | +using, this essentially boils down to ensuring that test keyserver and the |
365 | librarian are running and making sure that the key is attached to the |
366 | relevant launchpad person. |
367 | |
368 | - >>> from canonical.zeca.ftests.harness import ZecaTestSetup |
369 | - >>> zeca = ZecaTestSetup() |
370 | - >>> zeca.setUp() |
371 | + >>> from lp.testing.keyserver import KeyServerTac |
372 | + >>> keyserver = KeyServerTac() |
373 | + >>> keyserver.setUp() |
374 | |
375 | Import public keyring into current LPDB. |
376 | |
377 | @@ -757,5 +757,5 @@ |
378 | >>> shutil.rmtree("/var/tmp/archive/") |
379 | >>> shutil.rmtree(temp_dir) |
380 | |
381 | - >>> zeca.tearDown() |
382 | + >>> keyserver.tearDown() |
383 | |
384 | |
385 | === modified file 'lib/lp/soyuz/doc/soyuz-upload.txt' |
386 | --- lib/lp/soyuz/doc/soyuz-upload.txt 2010-12-03 18:28:03 +0000 |
387 | +++ lib/lp/soyuz/doc/soyuz-upload.txt 2011-02-17 22:26:32 +0000 |
388 | @@ -10,7 +10,7 @@ |
389 | * Import gpg key for katie |
390 | * Register gpg key for katie |
391 | * Register the katie user in the right team |
392 | - * Turn on the zeca keyserver |
393 | + * Turn on the test keyserver |
394 | * Include the non_free component in the database |
395 | * Run process-upload.py |
396 | * Check result |
397 | @@ -261,13 +261,13 @@ |
398 | ... active=True) |
399 | |
400 | |
401 | -Now we want to turn on the zeca key server to provide the key we |
402 | +Now we want to turn on the test key server to provide the key we |
403 | just imported. Remember that process-upload.py is running as |
404 | a different process. |
405 | |
406 | - >>> from canonical.zeca.ftests.harness import ZecaTestSetup |
407 | - >>> zeca = ZecaTestSetup() |
408 | - >>> zeca.setUp() |
409 | + >>> from lp.testing.keyserver import KeyServerTac |
410 | + >>> keyserver = KeyServerTac() |
411 | + >>> keyserver.setUp() |
412 | |
413 | |
414 | Include non-free in the database. This will be done by the |
415 | @@ -770,7 +770,7 @@ |
416 | Remove the test archive from filesystem. |
417 | |
418 | >>> shutil.rmtree("/var/tmp/archive/") |
419 | - >>> zeca.tearDown() |
420 | + >>> keyserver.tearDown() |
421 | |
422 | |
423 | Feito! ;-) |
424 | |
425 | === renamed directory 'lib/canonical/zeca' => 'lib/lp/testing/keyserver' |
426 | === modified file 'lib/lp/testing/keyserver/__init__.py' |
427 | --- lib/canonical/zeca/__init__.py 2009-06-25 05:39:50 +0000 |
428 | +++ lib/lp/testing/keyserver/__init__.py 2011-02-17 22:26:32 +0000 |
429 | @@ -1,6 +1,10 @@ |
430 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
431 | -# GNU Affero General Public License version 3 (see the file LICENSE). |
432 | +# Copyright 2009-2011 Canonical Ltd. This software is licensed under the GNU |
433 | +# Affero General Public License version 3 (see the file LICENSE). |
434 | |
435 | # pylint: disable-msg=W0401,W0403 |
436 | |
437 | -from zeca import * |
438 | +__all__ = [ |
439 | + 'KeyServerTac', |
440 | + ] |
441 | + |
442 | +from lp.testing.keyserver.harness import KeyServerTac |
443 | |
444 | === renamed file 'lib/canonical/zeca/ftests/harness.py' => 'lib/lp/testing/keyserver/harness.py' |
445 | --- lib/canonical/zeca/ftests/harness.py 2010-09-28 06:04:27 +0000 |
446 | +++ lib/lp/testing/keyserver/harness.py 2011-02-17 22:26:32 +0000 |
447 | @@ -1,4 +1,4 @@ |
448 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
449 | +# Copyright 2009-2011 Canonical Ltd. This software is licensed under the |
450 | # GNU Affero General Public License version 3 (see the file LICENSE). |
451 | |
452 | __metaclass__ = type |
453 | @@ -6,133 +6,42 @@ |
454 | import os |
455 | import shutil |
456 | |
457 | -import canonical |
458 | from canonical.config import config |
459 | from canonical.launchpad.daemons.tachandler import TacTestSetup |
460 | |
461 | |
462 | -keysdir = os.path.join(os.path.dirname(__file__), 'keys') |
463 | - |
464 | - |
465 | -class ZecaTestSetup(TacTestSetup): |
466 | - r"""Setup a zeca for use by functional tests |
467 | - |
468 | - >>> fixture = ZecaTestSetup() |
469 | - >>> fixture.setUp() |
470 | - |
471 | - Make sure the server is running |
472 | - |
473 | - >>> root_url = 'http://%s:%d' % ( |
474 | - ... config.gpghandler.host, config.gpghandler.port) |
475 | - |
476 | - We have a hamless application root page |
477 | - |
478 | - >>> from urllib import urlopen |
479 | - |
480 | - >>> print urlopen(root_url).read() |
481 | - Copyright 2004-2009 Canonical Ltd. |
482 | - <BLANKLINE> |
483 | - |
484 | - A key index lookup form via GET. |
485 | - |
486 | - >>> print urlopen( |
487 | - ... '%s/pks/lookup?op=index&search=0xDFD20543' % root_url |
488 | - ... ).read() |
489 | - <html> |
490 | - ... |
491 | - <title>Results for Key 0xDFD20543</title> |
492 | - ... |
493 | - pub 1024D/DFD20543 2005-04-13 Sample Person (revoked) <sample.revoked@canonical.com> |
494 | - ... |
495 | - |
496 | - A key content lookup form via GET. |
497 | - |
498 | - >>> print urlopen( |
499 | - ... '%s/pks/lookup?op=get&' |
500 | - ... 'search=0xA419AE861E88BC9E04B9C26FBA2B9389DFD20543' % root_url |
501 | - ... ).read() |
502 | - <html> |
503 | - ... |
504 | - <title>Results for Key 0xA419AE861E88BC9E04B9C26FBA2B9389DFD20543</title> |
505 | - ... |
506 | - -----BEGIN PGP PUBLIC KEY BLOCK----- |
507 | - Version: GnuPG v1.4.9 (GNU/Linux) |
508 | - <BLANKLINE> |
509 | - mQGiBEJdmOcRBADkNJPTBuCIefBdRAhvWyD9SSVHh8GHQWS7l9sRLEsirQkKz1yB |
510 | - ... |
511 | - |
512 | - We can also request a key ID instead of a fingerprint, and it will glob |
513 | - for the fingerprint. |
514 | - |
515 | - >>> print urlopen( |
516 | - ... '%s/pks/lookup?op=get&' |
517 | - ... 'search=0xDFD20543' % root_url |
518 | - ... ).read() |
519 | - <html> |
520 | - ... |
521 | - <title>Results for Key 0xDFD20543</title> |
522 | - ... |
523 | - -----BEGIN PGP PUBLIC KEY BLOCK----- |
524 | - Version: GnuPG v1.4.9 (GNU/Linux) |
525 | - <BLANKLINE> |
526 | - mQGiBEJdmOcRBADkNJPTBuCIefBdRAhvWyD9SSVHh8GHQWS7l9sRLEsirQkKz1yB |
527 | - ... |
528 | - |
529 | - If we request a nonexistent key, we get a nice error. |
530 | - |
531 | - >>> print urlopen( |
532 | - ... '%s/pks/lookup?op=get&' |
533 | - ... 'search=0xDFD20544' % root_url |
534 | - ... ).read() |
535 | - <html> |
536 | - ... |
537 | - <title>Results for Key 0xDFD20544</title> |
538 | - ... |
539 | - Key Not Found |
540 | - ... |
541 | - |
542 | - A key submit form via POST (see doc/gpghandler.txt for more information). |
543 | - |
544 | - >>> print urlopen('%s/pks/add' % root_url).read() |
545 | - <html> |
546 | - ... |
547 | - <title>Submit a key</title> |
548 | - ... |
549 | - |
550 | - >>> fixture.tearDown() |
551 | - |
552 | - And again for luck |
553 | - |
554 | - >>> fixture.setUp() |
555 | - |
556 | - >>> print urlopen(root_url).readline() |
557 | - Copyright 2004-2009 Canonical Ltd. |
558 | - <BLANKLINE> |
559 | - |
560 | - >>> fixture.tearDown() |
561 | - """ |
562 | +KEYS_DIR = os.path.join(os.path.dirname(__file__), 'tests/keys') |
563 | + |
564 | + |
565 | +class KeyServerTac(TacTestSetup): |
566 | + """A test key server for use by functional tests.""" |
567 | + |
568 | def setUpRoot(self): |
569 | """Recreate root directory and copy needed keys""" |
570 | if os.path.isdir(self.root): |
571 | shutil.rmtree(self.root) |
572 | - shutil.copytree(keysdir, self.root) |
573 | + shutil.copytree(KEYS_DIR, self.root) |
574 | |
575 | @property |
576 | def root(self): |
577 | - return config.zeca.root |
578 | + return config.testkeyserver.root |
579 | |
580 | @property |
581 | def tacfile(self): |
582 | - return os.path.abspath(os.path.join( |
583 | - os.path.dirname(canonical.__file__), os.pardir, os.pardir, |
584 | - 'daemons/zeca.tac' |
585 | - )) |
586 | + return os.path.abspath( |
587 | + os.path.join(os.path.dirname(__file__), 'testkeyserver.tac')) |
588 | |
589 | @property |
590 | def pidfile(self): |
591 | - return os.path.join(self.root, 'zeca.pid') |
592 | + return os.path.join(self.root, 'testkeyserver.pid') |
593 | |
594 | @property |
595 | def logfile(self): |
596 | - return os.path.join(self.root, 'zeca.log') |
597 | - |
598 | + return os.path.join(self.root, 'testkeyserver.log') |
599 | + |
600 | + |
601 | + @property |
602 | + def url(self): |
603 | + """The URL that the web server will be running on.""" |
604 | + return 'http://%s:%d' % ( |
605 | + config.gpghandler.host, config.gpghandler.port) |
606 | |
607 | === renamed file 'daemons/zeca.tac' => 'lib/lp/testing/keyserver/testkeyserver.tac' |
608 | --- daemons/zeca.tac 2010-10-20 18:43:29 +0000 |
609 | +++ lib/lp/testing/keyserver/testkeyserver.tac 2011-02-17 22:26:32 +0000 |
610 | @@ -2,33 +2,28 @@ |
611 | # GNU Affero General Public License version 3 (see the file LICENSE). |
612 | |
613 | # Twisted Application Configuration file. |
614 | -# Use with "twistd2.3 -y <file.tac>", e.g. "twistd -noy server.tac" |
615 | +# Use with "twistd -y <file.tac>", e.g. "twistd -noy server.tac" |
616 | |
617 | -from twisted.application import service, internet, strports |
618 | +from twisted.application import service, strports |
619 | from twisted.web import server |
620 | |
621 | from canonical.config import config |
622 | from canonical.launchpad.daemons import readyservice |
623 | from canonical.launchpad.scripts import execute_zcml_for_scripts |
624 | -from canonical.zeca import Zeca, KeyServer, LookUp, SubmitKey |
625 | +from lp.testing.keyserver.web import KeyServerResource |
626 | |
627 | # Needed for using IGPGHandler for processing key submit. |
628 | execute_zcml_for_scripts() |
629 | |
630 | -root = config.zeca.root |
631 | - |
632 | -application = service.Application('Zeca') |
633 | -zecaService = service.IServiceCollection(application) |
634 | +application = service.Application('testkeyserver') |
635 | +svc = service.IServiceCollection(application) |
636 | |
637 | # Service that announces when the daemon is ready |
638 | -readyservice.ReadyService().setServiceParent(zecaService) |
639 | - |
640 | -zeca = Zeca() |
641 | -keyserver = KeyServer() |
642 | -keyserver.putChild('lookup', LookUp(root)) |
643 | -keyserver.putChild('add', SubmitKey(root)) |
644 | -zeca.putChild('pks', keyserver) |
645 | - |
646 | -site = server.Site(zeca) |
647 | +readyservice.ReadyService().setServiceParent(svc) |
648 | + |
649 | +site = server.Site(KeyServerResource(config.testkeyserver.root)) |
650 | site.displayTracebacks = False |
651 | -strports.service('11371', site).setServiceParent(zecaService) |
652 | + |
653 | +# Run on the port that gpghandler is configured to hit. |
654 | +port = 'tcp:%s' % (config.gpghandler.port,) |
655 | +strports.service(port, site).setServiceParent(svc) |
656 | |
657 | === renamed directory 'lib/canonical/zeca/ftests' => 'lib/lp/testing/keyserver/tests' |
658 | === modified symlink 'lib/lp/testing/keyserver/tests/keys/0x33C0A61893A5DC5EB325B29E415A12CAC2F30234.get' |
659 | === target changed u'../../../launchpad/ftests/gpgkeys/ftpmaster@canonical.com.pub' => u'../../../../../canonical/launchpad/ftests/gpgkeys/ftpmaster@canonical.com.pub' |
660 | === modified symlink 'lib/lp/testing/keyserver/tests/keys/0x340CA3BB270E2716C9EE0B768E7EB7086C64A8C5.get' |
661 | === target changed u'../../../launchpad/ftests/gpgkeys/foo.bar@canonical.com.pub' => u'../../../../../canonical/launchpad/ftests/gpgkeys/foo.bar@canonical.com.pub' |
662 | === modified symlink 'lib/lp/testing/keyserver/tests/keys/0x447DBF38C4F9C4ED752246B77D88913717B05A8F.get' |
663 | === target changed u'../../../launchpad/ftests/gpgkeys/sign.only@canonical.com.pub' => u'../../../../../canonical/launchpad/ftests/gpgkeys/sign.only@canonical.com.pub' |
664 | === modified symlink 'lib/lp/testing/keyserver/tests/keys/0x84D205F03E1E67096CB54E262BE83793AACCD97C.get' |
665 | === target changed u'../../../launchpad/ftests/gpgkeys/revoked.key@canonical.com.pub' => u'../../../../../canonical/launchpad/ftests/gpgkeys/revoked.key@canonical.com.pub' |
666 | === modified symlink 'lib/lp/testing/keyserver/tests/keys/0x961F4EB829D7D304A77477822BC8401620687895.get' |
667 | === target changed u'../../../launchpad/ftests/gpgkeys/daniel.silverstone@canonical.com.pub' => u'../../../../../canonical/launchpad/ftests/gpgkeys/daniel.silverstone@canonical.com.pub' |
668 | === modified symlink 'lib/lp/testing/keyserver/tests/keys/0xA419AE861E88BC9E04B9C26FBA2B9389DFD20543.get' |
669 | === target changed u'../../../launchpad/ftests/gpgkeys/test@canonical.com.pub' => u'../../../../../canonical/launchpad/ftests/gpgkeys/test@canonical.com.pub' |
670 | === modified symlink 'lib/lp/testing/keyserver/tests/keys/0xC85826521A6EF6A6037BB3F79FF2583E681B6469.get' |
671 | === target changed u'../../../launchpad/ftests/gpgkeys/celso.providelo@canonical.com.pub' => u'../../../../../canonical/launchpad/ftests/gpgkeys/celso.providelo@canonical.com.pub' |
672 | === modified symlink 'lib/lp/testing/keyserver/tests/keys/0xECA5B797586F2E27381A16CFDE6C9167046C6D63.get' |
673 | === target changed u'../../../launchpad/ftests/gpgkeys/expired.key@canonical.com.pub' => u'../../../../../canonical/launchpad/ftests/gpgkeys/expired.key@canonical.com.pub' |
674 | === modified symlink 'lib/lp/testing/keyserver/tests/keys/README' |
675 | === target changed u'../../../launchpad/ftests/gpgkeys/README' => u'../../../../../canonical/launchpad/ftests/gpgkeys/README' |
676 | === modified file 'lib/lp/testing/keyserver/tests/test_harness.py' |
677 | --- lib/canonical/zeca/ftests/test_harness.py 2010-07-14 14:11:15 +0000 |
678 | +++ lib/lp/testing/keyserver/tests/test_harness.py 2011-02-17 22:26:32 +0000 |
679 | @@ -1,13 +1,31 @@ |
680 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
681 | +# Copyright 2009-2011 Canonical Ltd. This software is licensed under the |
682 | # GNU Affero General Public License version 3 (see the file LICENSE). |
683 | |
684 | __metaclass__ = type |
685 | |
686 | -import doctest |
687 | - |
688 | -from canonical.launchpad.testing.systemdocs import default_optionflags |
689 | - |
690 | -def test_suite(): |
691 | - return doctest.DocTestSuite( |
692 | - 'canonical.zeca.ftests.harness', optionflags=default_optionflags) |
693 | - |
694 | +from urllib import urlopen |
695 | + |
696 | +from canonical.config import config |
697 | + |
698 | +from lp.testing import TestCase |
699 | +from lp.testing.keyserver import KeyServerTac |
700 | +from lp.testing.keyserver.web import GREETING |
701 | + |
702 | + |
703 | +class TestKeyServerTac(TestCase): |
704 | + |
705 | + def test_url(self): |
706 | + # The url is the one that gpghandler is configured to hit. |
707 | + fixture = KeyServerTac() |
708 | + self.assertEqual( |
709 | + 'http://%s:%d' % ( |
710 | + config.gpghandler.host, config.gpghandler.port), |
711 | + fixture.url) |
712 | + |
713 | + def test_starts_properly(self): |
714 | + # Make sure the tac starts properly and that we can load the page. |
715 | + fixture = KeyServerTac() |
716 | + fixture.setUp() |
717 | + self.addCleanup(fixture.tearDown) |
718 | + content = urlopen(fixture.url).readline() |
719 | + self.assertEqual(GREETING, content) |
720 | |
721 | === modified file 'lib/lp/testing/keyserver/tests/test_locate_key.py' |
722 | --- lib/canonical/zeca/ftests/test_locate_key.py 2009-08-20 13:52:59 +0000 |
723 | +++ lib/lp/testing/keyserver/tests/test_locate_key.py 2011-02-17 22:26:32 +0000 |
724 | @@ -1,13 +1,13 @@ |
725 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
726 | -# GNU Affero General Public License version 3 (see the file LICENSE). |
727 | +# Copyright 2009-2011 Canonical Ltd. This software is licensed under the GNU |
728 | +# Affero General Public License version 3 (see the file LICENSE). |
729 | |
730 | -import unittest |
731 | import os.path |
732 | |
733 | -from canonical.zeca.zeca import locate_key |
734 | - |
735 | - |
736 | -class LocateKeyTestCase(unittest.TestCase): |
737 | +from lp.testing import TestCase |
738 | +from lp.testing.keyserver.web import locate_key |
739 | + |
740 | + |
741 | +class LocateKeyTestCase(TestCase): |
742 | root = os.path.join(os.path.dirname(__file__), 'keys') |
743 | |
744 | def assertKeyFile(self, suffix, filename): |
745 | @@ -35,9 +35,3 @@ |
746 | def test_locate_key_no_match(self): |
747 | self.assertKeyFile('0xDEADBEEF.get', None) |
748 | |
749 | - |
750 | -def test_suite(): |
751 | - suite = unittest.TestSuite() |
752 | - suite.addTest(unittest.makeSuite(LocateKeyTestCase)) |
753 | - return suite |
754 | - |
755 | |
756 | === added file 'lib/lp/testing/keyserver/tests/test_web.py' |
757 | --- lib/lp/testing/keyserver/tests/test_web.py 1970-01-01 00:00:00 +0000 |
758 | +++ lib/lp/testing/keyserver/tests/test_web.py 2011-02-17 22:26:32 +0000 |
759 | @@ -0,0 +1,132 @@ |
760 | +# Copyright 2011 Canonical Ltd. This software is licensed under the |
761 | +# GNU Affero General Public License version 3 (see the file LICENSE). |
762 | + |
763 | +"""Tests for the web resources of the testkeyserver.""" |
764 | + |
765 | +__metaclass__ = type |
766 | + |
767 | +import os |
768 | +import shutil |
769 | + |
770 | +from testtools.deferredruntest import AsynchronousDeferredRunTest |
771 | + |
772 | +from twisted.internet.endpoints import serverFromString |
773 | +from twisted.web.client import getPage |
774 | +from twisted.web.server import Site |
775 | + |
776 | +from lp.testing import TestCase |
777 | +from lp.testing.keyserver.harness import KEYS_DIR |
778 | +from lp.testing.keyserver.web import KeyServerResource |
779 | +from lp.testing.matchers import DocTestMatches |
780 | + |
781 | + |
782 | +class TestWebResources(TestCase): |
783 | + |
784 | + run_tests_with = AsynchronousDeferredRunTest.make_factory(timeout=2) |
785 | + |
786 | + def setUpKeysDirectory(self): |
787 | + path = self.makeTemporaryDirectory() |
788 | + path = os.path.join(path, 'keys') |
789 | + shutil.copytree(KEYS_DIR, path) |
790 | + return path |
791 | + |
792 | + def makeService(self): |
793 | + """Run a test key server on whatever port we have available.""" |
794 | + from twisted.internet import reactor |
795 | + resource = KeyServerResource(self.setUpKeysDirectory()) |
796 | + site = Site(resource) |
797 | + endpoint = serverFromString(reactor, 'tcp:0') |
798 | + return endpoint.listen(site) |
799 | + |
800 | + def fetchResource(self, listening_port, path): |
801 | + """GET the content at 'path' from the web server at 'listening_port'. |
802 | + """ |
803 | + url = 'http://localhost:%s/%s' % ( |
804 | + listening_port.getHost().port, |
805 | + path.lstrip('/')) |
806 | + return getPage(url) |
807 | + |
808 | + def getURL(self, path): |
809 | + """Start a test key server and get the content at 'path'.""" |
810 | + d = self.makeService() |
811 | + def service_started(port): |
812 | + self.addCleanup(port.stopListening) |
813 | + return self.fetchResource(port, path) |
814 | + return d.addCallback(service_started) |
815 | + |
816 | + def assertContentMatches(self, path, content): |
817 | + """Assert that the key server content at 'path' matches 'content'.""" |
818 | + d = self.getURL(path) |
819 | + return d.addCallback(self.assertThat, DocTestMatches(content)) |
820 | + |
821 | + def test_index_lookup(self): |
822 | + # A key index lookup form via GET. |
823 | + return self.assertContentMatches( |
824 | + '/pks/lookup?op=index&search=0xDFD20543', |
825 | + '''\ |
826 | +<html> |
827 | +... |
828 | +<title>Results for Key 0xDFD20543</title> |
829 | +... |
830 | +pub 1024D/DFD20543 2005-04-13 Sample Person (revoked) <sample.revoked@canonical.com> |
831 | +... |
832 | +''') |
833 | + |
834 | + def test_content_lookup(self): |
835 | + # A key content lookup form via GET. |
836 | + return self.assertContentMatches( |
837 | + '/pks/lookup?op=get&' |
838 | + 'search=0xA419AE861E88BC9E04B9C26FBA2B9389DFD20543', |
839 | + '''\ |
840 | +<html> |
841 | +... |
842 | +<title>Results for Key 0xA419AE861E88BC9E04B9C26FBA2B9389DFD20543</title> |
843 | +... |
844 | +-----BEGIN PGP PUBLIC KEY BLOCK----- |
845 | +Version: GnuPG v1.4.9 (GNU/Linux) |
846 | +<BLANKLINE> |
847 | +mQGiBEJdmOcRBADkNJPTBuCIefBdRAhvWyD9SSVHh8GHQWS7l9sRLEsirQkKz1yB |
848 | +... |
849 | +''') |
850 | + |
851 | + def test_lookup_key_id(self): |
852 | + # We can also request a key ID instead of a fingerprint, and it will |
853 | + # glob for the fingerprint. |
854 | + return self.assertContentMatches( |
855 | + '/pks/lookup?op=get&search=0xDFD20543', |
856 | + '''\ |
857 | +<html> |
858 | +... |
859 | +<title>Results for Key 0xDFD20543</title> |
860 | +... |
861 | +-----BEGIN PGP PUBLIC KEY BLOCK----- |
862 | +Version: GnuPG v1.4.9 (GNU/Linux) |
863 | +<BLANKLINE> |
864 | +mQGiBEJdmOcRBADkNJPTBuCIefBdRAhvWyD9SSVHh8GHQWS7l9sRLEsirQkKz1yB |
865 | +... |
866 | +''') |
867 | + |
868 | + def test_nonexistent_key(self): |
869 | + # If we request a nonexistent key, we get a nice error. |
870 | + return self.assertContentMatches( |
871 | + '/pks/lookup?op=get&search=0xDFD20544', |
872 | + '''\ |
873 | +<html> |
874 | +... |
875 | +<title>Results for Key 0xDFD20544</title> |
876 | +... |
877 | +Key Not Found |
878 | +... |
879 | +''') |
880 | + |
881 | + def test_add_key(self): |
882 | + # A key submit form via POST (see doc/gpghandler.txt for more |
883 | + # information). |
884 | + return self.assertContentMatches( |
885 | + '/pks/add', |
886 | + '''\ |
887 | +<html> |
888 | +... |
889 | +<title>Submit a key</title> |
890 | +... |
891 | +''') |
892 | |
893 | === renamed file 'lib/canonical/zeca/zeca.py' => 'lib/lp/testing/keyserver/web.py' |
894 | --- lib/canonical/zeca/zeca.py 2009-08-20 13:52:29 +0000 |
895 | +++ lib/lp/testing/keyserver/web.py 2011-02-17 22:26:32 +0000 |
896 | @@ -1,4 +1,4 @@ |
897 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
898 | +# Copyright 2009-2011 Canonical Ltd. This software is licensed under the |
899 | # GNU Affero General Public License version 3 (see the file LICENSE). |
900 | |
901 | """GPG Key Information Server Prototype. |
902 | @@ -12,7 +12,7 @@ |
903 | - 'add': adds a key to the collection (does not update the index) |
904 | |
905 | It only depends on GPG for key submission; for retrieval and searching |
906 | -it just looks for files in the root (eg. /var/tmp/zeca). The files |
907 | +it just looks for files in the root (eg. /var/tmp/testkeyserver). The files |
908 | are named like this: |
909 | |
910 | 0x<keyid|fingerprint>.<operation> |
911 | @@ -24,16 +24,12 @@ |
912 | note: remove the lines containing 'sub' or 'secret' keys |
913 | |
914 | $ gpg --export -a cprov > 0x681B6469.get |
915 | - |
916 | """ |
917 | |
918 | __metaclass__ = type |
919 | |
920 | __all__ = [ |
921 | - 'KeyServer', |
922 | - 'LookUp', |
923 | - 'SubmitKey', |
924 | - 'Zeca', |
925 | + 'KeyServerResource', |
926 | ] |
927 | |
928 | import glob |
929 | @@ -45,8 +41,11 @@ |
930 | from zope.component import getUtility |
931 | |
932 | from canonical.launchpad.interfaces.gpghandler import ( |
933 | - GPGKeyNotFoundError, IGPGHandler, MoreThanOneGPGKeyFound, |
934 | - SecretGPGKeyImportDetected) |
935 | + GPGKeyNotFoundError, |
936 | + IGPGHandler, |
937 | + MoreThanOneGPGKeyFound, |
938 | + SecretGPGKeyImportDetected, |
939 | + ) |
940 | |
941 | |
942 | GREETING = 'Copyright 2004-2009 Canonical Ltd.\n' |
943 | @@ -79,23 +78,40 @@ |
944 | return path |
945 | |
946 | |
947 | -class Zeca(Resource): |
948 | +class _BaseResource(Resource): |
949 | + |
950 | def getChild(self, name, request): |
951 | + """Redirect trailing slash correctly.""" |
952 | if name == '': |
953 | return self |
954 | return Resource.getChild( |
955 | self, name, request) |
956 | |
957 | + |
958 | +class KeyServerResource(_BaseResource): |
959 | + """Root resource for the test keyserver.""" |
960 | + |
961 | + def __init__(self, root): |
962 | + _BaseResource.__init__(self) |
963 | + self.putChild('pks', PksResource(root)) |
964 | + |
965 | def render_GET(self, request): |
966 | return GREETING |
967 | |
968 | |
969 | -class KeyServer(Zeca): |
970 | +class PksResource(_BaseResource): |
971 | + |
972 | + def __init__(self, root): |
973 | + _BaseResource.__init__(self) |
974 | + self.putChild('lookup', LookUp(root)) |
975 | + self.putChild('add', SubmitKey(root)) |
976 | + |
977 | def render_GET(self, request): |
978 | return 'Welcome To Fake SKS service.\n' |
979 | |
980 | |
981 | class LookUp(Resource): |
982 | + |
983 | isLeaf = True |
984 | permitted_actions = ['index', 'get'] |
985 | |
986 | |
987 | === modified file 'lib/lp/testing/matchers.py' |
988 | --- lib/lp/testing/matchers.py 2011-01-12 20:48:19 +0000 |
989 | +++ lib/lp/testing/matchers.py 2011-02-17 22:26:32 +0000 |
990 | @@ -4,6 +4,7 @@ |
991 | __metaclass__ = type |
992 | __all__ = [ |
993 | 'Contains', |
994 | + 'DocTestMatches', |
995 | 'DoesNotCorrectlyProvide', |
996 | 'DoesNotProvide', |
997 | 'HasQueryCount', |
998 | @@ -18,6 +19,7 @@ |
999 | from testtools.content_type import UTF8_TEXT |
1000 | from testtools.matchers import ( |
1001 | Equals, |
1002 | + DocTestMatches as OriginalDocTestMatches, |
1003 | Matcher, |
1004 | Mismatch, |
1005 | MismatchesAll, |
1006 | @@ -302,3 +304,12 @@ |
1007 | return None |
1008 | else: |
1009 | return MismatchesAll(mismatches) |
1010 | + |
1011 | + |
1012 | +def DocTestMatches(example): |
1013 | + """See if a string matches a doctest example. |
1014 | + |
1015 | + Uses the default doctest flags used across Launchpad. |
1016 | + """ |
1017 | + from canonical.launchpad.testing.systemdocs import default_optionflags |
1018 | + return OriginalDocTestMatches(example, default_optionflags) |
1019 | |
1020 | === modified file 'lp-sfood-packages' |
1021 | --- lp-sfood-packages 2010-03-21 16:35:28 +0000 |
1022 | +++ lp-sfood-packages 2011-02-17 22:26:32 +0000 |
1023 | @@ -17,7 +17,6 @@ |
1024 | lp/archivepublisher |
1025 | lp/app |
1026 | lp/answers |
1027 | -canonical/zeca |
1028 | canonical/widgets |
1029 | canonical/tests |
1030 | canonical/testing |
1031 | |
1032 | === modified file 'utilities/start-dev-soyuz.sh' |
1033 | --- utilities/start-dev-soyuz.sh 2010-03-10 11:52:19 +0000 |
1034 | +++ utilities/start-dev-soyuz.sh 2011-02-17 22:26:32 +0000 |
1035 | @@ -8,11 +8,11 @@ |
1036 | bin/twistd \ |
1037 | --logfile "/var/tmp/development-$1.log" \ |
1038 | --pidfile "/var/tmp/development-$1.pid" \ |
1039 | - -y "daemons/$1.tac" |
1040 | + -y "$2" |
1041 | } |
1042 | |
1043 | -start_twistd zeca |
1044 | -start_twistd buildd-manager |
1045 | +start_twistd testkeyserver lib/lp/testing/keyserver/testkeyserver.tac |
1046 | +start_twistd buildd-manager daemons/buildd-manager.tac |
1047 | |
1048 | echo "Starting poppy." |
1049 | mkdir -p /var/tmp/poppy |
Thanks a bunch for fixing some "legacy" crap!
I have a few comments but it looks good to land.
58 - >>> from canonical. zeca.ftests. harness import ZecaTestSetup keyserver import KeyServerTac
59 - >>> z = ZecaTestSetup()
60 + >>> from lp.testing.
61 + >>> z = KeyServerTac()
62 >>> z.setUp()
Can you give it a better name than z! This happens in a few places, I won't enumerate them all.
63 uploadPublicKey (new_key. fingerprint)
64 Upload the just-generated key to the keyserver so that we can reset
65 @@ -323,7 +323,7 @@
66
67 >>> gpghandler.
68
69 -Let's shut zeca down.
70 +Let's shut the test keyserver down.
71
72 >>> z.tearDown()
That's a completely redundant piece of text, you might as well remove it. (in more than once place)
Everything else looks great!