Skip to content

Commit

Permalink
tests: generate signing subkey
Browse files Browse the repository at this point in the history
Since the subkeys-only keyring feature is enabled by default
(source_keyring_dir != "no"), signing with the GnuPG's defaults fails.

Generate a signing subkey using gpg2 --quick-add-key.
  • Loading branch information
marmarek committed Dec 21, 2024
1 parent 49385e9 commit bd30173
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions splitgpg2tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ def setUp(self):
self.skipTest('gpg2 not installed')
elif p.returncode != 0:
self.fail('key generation failed: {}{}'.format(stdout, stderr))

cmd = 'gpg2 --with-colons --list-key user@localhost'
p = self.backend.run(cmd, passio_popen=True, passio_stderr=True)
(stdout, stderr) = p.communicate()
self.assertEqual(p.returncode, 0,
'{} failed: {}{}'.format(cmd, stdout.decode(), stderr.decode()))
fpr = [l for l in stdout.splitlines() if l.startswith(b'fpr:')][0]
fpr = fpr.decode().split(":")[9]
# add signing subkey
p = self.backend.run(
f"gpg2 --batch --passphrase "" --quick-add-key "
f"{fpr} rsa sign never",
passio_popen=True,
passio_stderr=True)
stdout, stderr = p.communicate()
if p.returncode != 0:
self.fail('subkey generation failed: {}{}'.format(
stdout, stderr))
if 'whonix' in self.template:
self.backend.run("date -s +10min", user="root", wait=True)

Expand Down

0 comments on commit bd30173

Please sign in to comment.