default-key in gpg.conf fails with GnuPG 2.1
the test suite currently only has one test failing left:
ERROR: test_multiple_secrets (tests.test_ui.SigningTests)
test if we pick the right key define in gpg.conf
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests/test_ui.py", line 178, in test_multiple_secrets
self.ui.sign_key()
File "tests/../monkeysign/ui.py", line 361, in sign_key
if not self.tmpkeyring.sign_key(pattern, alluids):
File "tests/../monkeysign/gpg.py", line 526, in sign_key
raise GpgRuntimeError(self.context.returncode, _('unable to confirm key signing: %s') % e.found().decode('utf-8'))
GpgRuntimeError: [Errno 0] unable to confirm key signing: [GNUPG:] INV_SGNR 9
This is the case when the secret key material is not present. But the thing is: the material is present, as we can see from previous --list-secret-keys
output:
command: ['gpg', '--command-fd', '0', '--with-fingerprint', '--list-options', 'show-sig-subpackets,show-uid-validity,show-unusable-uids,show-unusable-subkeys,show-keyring,show-sig-expire', '--armor', '--status-fd', '2', '--quiet', '--batch', '--fixed-list-mode', '--no-tty', '--with-colons', '--use-agent', '--homedir', '/tmp/pygpg-nc4NBa', '--list-secret-keys']
ret: 0 stdout: sec:-:1024:1:86E4E70A96F47C6A:1342795252:::-:::scESC:::+::::
fpr:::::::::3F94240C918E63590B04152E86E4E70A96F47C6A:
grp:::::::::558EB5B4989C679BED1556AD01779D43C9E821FC:
uid:-::::1376258501::5DDAF07DDB202F2251458399C54178537B81B134::Second Test Key <unittests@monkeysphere.info>:::::::::
uid:-::::1342795252::214CB0EDA28F3CA8754A4D43B7CDB7B114171B3C::Test Key <foo@example.com>:::::::::
ssb:-:1024:1:894EE34814B46386:1342795252::::::e:::+:::
fpr:::::::::F2A23173AB8E4CC5D70C13BA894EE34814B46386:
grp:::::::::28D7441EEA6A648FE26D8B2A2DA87D7086370A3F:
sec:-:1024:1:A31E75E4323F39BD:1343322119:::-:::scESC:::+::::
fpr:::::::::DF3AB14A341AEBBF9452D181A31E75E4323F39BD:
grp:::::::::E5942F6A2B53F3D779C450BE0311E29DE0293033:
uid:-::::1343322119::F20711B9992D598A91E3569EB562A9FEB07399A9::Monkeysphere second test key <bar@example.com>:::::::::
ssb:-:1024:1:824B853D9D78642E:1343322119::::::e:::+:::
fpr:::::::::325A640D6EC0A6631DA7A5DA824B853D9D78642E:
grp:::::::::1A77DC84474A2C680F9A56FB3B92940ED64D6ACA:
stderr:
The secret key is hardcoded in the gpg.conf
in that test, using this bit of code:
with open(os.path.join(self.ui.keyring.homedir, 'gpg.conf'), 'w') as f:
f.write('default-key 323F39BD')
Thinking that gpg 2.1 doesn't like short keyids, I have tried the following patch:
diff --git a/tests/test_ui.py b/tests/test_ui.py
index d050733..abe4195 100755
--- a/tests/test_ui.py
+++ b/tests/test_ui.py
@@ -162,7 +162,7 @@ def test_multiple_secrets(self):
"""test if we pick the right key define in gpg.conf"""
# configure gpg to use the second test key as a default key
with open(os.path.join(self.ui.keyring.homedir, 'gpg.conf'), 'w') as f:
- f.write('default-key 323F39BD')
+ f.write('default-key DF3AB14A341AEBBF9452D181A31E75E4323F39BD')
# needed because we created a new gpg.conf
self.ui.prepare()
self.assertTrue(os.path.exists(os.path.join(self.ui.tmpkeyring.homedir, 'gpg.conf')))
... but that also fails in a similar fashion.