Merge lp:click/devel into lp:click

Proposed by Colin Watson on 2016-09-16
Status: Merged
Approved by: Colin Watson on 2016-09-16
Approved revision: 630
Merged at revision: 618
Proposed branch: lp:click/devel
Merge into: lp:click
Diff against target: 100 lines (+35/-10)
2 files modified
click/tests/integration/test_signatures.py (+27/-10)
debian/changelog (+8/-0)
To merge this branch: bzr merge lp:click/devel
Reviewer Review Type Date Requested Status
Colin Watson Approve on 2016-09-16
Review via email: mp+305989@code.launchpad.net

Commit message

Fix debsigs-related autopkgtests.

Description of the change

Fix debsigs-related autopkgtests.

To post a comment you must log in.
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'click/tests/integration/test_signatures.py'
2--- click/tests/integration/test_signatures.py 2016-08-11 10:35:54 +0000
3+++ click/tests/integration/test_signatures.py 2016-09-16 17:42:44 +0000
4@@ -24,6 +24,7 @@
5
6 import apt
7
8+from click import osextras
9 from .helpers import (
10 require_root,
11 ClickTestCase,
12@@ -60,11 +61,15 @@
13 """Sign the click at filepath"""
14 env = copy.copy(os.environ)
15 env["GNUPGHOME"] = os.path.abspath(self.gpghome)
16- subprocess.check_call(
17- ["debsigs",
18- "--sign=%s" % signature_type,
19- "--default-key=%s" % self.keyid,
20- filepath], env=env)
21+ try:
22+ subprocess.check_call(
23+ ["debsigs",
24+ "--sign=%s" % signature_type,
25+ "--default-key=%s" % self.keyid,
26+ filepath], env=env)
27+ finally:
28+ if osextras.find_on_path("gpgconf"):
29+ subprocess.call(["gpgconf", "--kill", "gpg-agent"])
30
31 def install_signature_policy(self):
32 """Install/update the system-wide signature policy"""
33@@ -179,17 +184,27 @@
34 self.datadir = os.path.join(os.path.dirname(__file__), "data")
35 origin_keyring_dir = os.path.abspath(
36 os.path.join(self.datadir, "origin-keyring"))
37- keyid = get_keyid_from_gpghome(origin_keyring_dir)
38- self.debsigs = Debsigs(origin_keyring_dir, keyid)
39+ gpghome = self.make_gpghome(origin_keyring_dir)
40+ keyid = get_keyid_from_gpghome(gpghome)
41+ self.debsigs = Debsigs(gpghome, keyid)
42 self.debsigs.install_signature_policy()
43
44 def tearDown(self):
45 self.debsigs.uninstall_signature_policy()
46
47+ def make_gpghome(self, source):
48+ gpghome = os.path.join(self.temp_dir, "gnupg")
49+ if os.path.exists(gpghome):
50+ shutil.rmtree(gpghome)
51+ shutil.copytree(source, gpghome)
52+ os.chmod(gpghome, 0o700)
53+ return gpghome
54+
55 def test_debsig_install_valid_signature(self):
56 name = "org.example.debsig-valid-sig"
57 path_to_click = self._make_click(name, framework="")
58 self.debsigs.sign(path_to_click)
59+ subprocess.call(["cp", path_to_click, os.path.join("/home/cjwatson/src/ubuntu/click/click", os.path.basename(path_to_click))])
60 subprocess.check_call(
61 [self.click_binary, "install",
62 "--user=%s" % self.user,
63@@ -206,8 +221,9 @@
64 name = "org.example.debsig-no-keyring-sig"
65 path_to_click = self._make_click(name, framework="")
66 evil_keyring_dir = os.path.join(self.datadir, "evil-keyring")
67- keyid = get_keyid_from_gpghome(evil_keyring_dir)
68- debsig_bad = Debsigs(evil_keyring_dir, keyid)
69+ gpghome = self.make_gpghome(evil_keyring_dir)
70+ keyid = get_keyid_from_gpghome(gpghome)
71+ debsig_bad = Debsigs(gpghome, keyid)
72 debsig_bad.sign(path_to_click)
73 # and ensure its really not there
74 self.assertClickInvalidSignatureError(["install", path_to_click])
75@@ -349,7 +365,8 @@
76 good_gpg_origin = f.read()
77 # and append a valid signature from a non-keyring key
78 evil_keyring_dir = os.path.join(self.datadir, "evil-keyring")
79- debsig_bad = Debsigs(evil_keyring_dir, "18B38B9AC1B67A0D")
80+ gpghome = self.make_gpghome(evil_keyring_dir)
81+ debsig_bad = Debsigs(gpghome, "18B38B9AC1B67A0D")
82 debsig_bad.sign(path_to_click)
83 subprocess.check_call(
84 ["ar", "-x", path_to_click, "_gpgorigin"], cwd=self.temp_dir)
85
86=== modified file 'debian/changelog'
87--- debian/changelog 2016-08-28 21:00:53 +0000
88+++ debian/changelog 2016-09-16 17:42:44 +0000
89@@ -1,3 +1,11 @@
90+click (0.4.45.1) UNRELEASED; urgency=medium
91+
92+ * Kill gpg-agent (if possible) after running debsigs in integration tests.
93+ * Copy integration test GPG keyring to a temporary directory so that the
94+ GPG agent socket name doesn't end up being too long.
95+
96+ -- Colin Watson <cjwatson@ubuntu.com> Fri, 16 Sep 2016 18:38:59 +0100
97+
98 click (0.4.45+16.10.20160828.1-0ubuntu1) yakkety; urgency=medium
99
100 * Emit more debugging information when libclickpreload/libgimockpreload

Subscribers

People subscribed via source and target branches

to all changes: