Skip to content

Instantly share code, notes, and snippets.

@clonejo
Created February 20, 2023 21:16
Show Gist options
  • Save clonejo/d5649915e3ce2a0628468c3cf493419a to your computer and use it in GitHub Desktop.
Save clonejo/d5649915e3ce2a0628468c3cf493419a to your computer and use it in GitHub Desktop.
`--> GPGBINARY=gpg2 pytest -k test_scan_keys -s
=============================================== test session starts ===============================================
platform linux -- Python 3.10.9, pytest-7.2.1, pluggy-1.0.0
rootdir: /home/clonejo/code/python-gnupg
plugins: flake8-1.1.1, enabler-2.0.0, cov-4.0.0, black-0.3.12, mypy-0.10.3, checkdocs-2.7.1
collected 41 items / 38 deselected / 3 selected
test_gnupg.py gpg2 --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --with-colons --homedir /tmp/keys-lp13e6kv --version
gpg2 --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --with-colons --homedir /tmp/keys-lp13e6kv --debug-quick-random --dry-run --import-options import-show --import /tmp/pygpg-test-7nblxwbl
gpg: keybox '/tmp/keys-lp13e6kv/pubring.kbx' created
gpg: /tmp/keys-lp13e6kv/trustdb.gpg: trustdb created
gpg: Total number processed: 2
[GNUPG:] IMPORT_RES 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0
pub:-:1024:17:967612475CED2E14:1216864513:::-:::scESC::::::::0:
fpr:::::::::4F6B5D46198BB40D1BD16B2C967612475CED2E14:
uid:-::::1216864513::5FE71F003D4EE074F680BC83FF9610339E6AE6E9::Gary Gross (A test user) <gary.gross@gamma.com>::::::::::0:
sub:-:2048:16:5431DEFBB92FC240:1216864513::::::e:::::::
fpr:::::::::ECBF43C6BAC47DCE06B8AF6C5431DEFBB92FC240:
pub:-:1024:17:6EDB2A64BBACC600:1216864597:::-:::scESC::::::::0:
fpr:::::::::A5024856AAC72420AA7198526EDB2A64BBACC600:
uid:-::::1216864597::0B2FC6EB572669101A340D19D60051D8D9D4C79A::Danny Davis (A test user) <danny.davis@delta.com>::::::::::0:
sub:-:2048:16:B50B2D38595BBE7C:1216864597::::::e:::::::
fpr:::::::::E8011929C27BEFE6B011C59DB50B2D38595BBE7C:
uids={'Danny Davis (A test user) <danny.davis@delta.com>', 'Gary Gross (A test user) <gary.gross@gamma.com>'}
expected={'Danny Davis (A test user) <danny.davis@delta.com>', 'Gary Gross (A test user) <gary.gross@gamma.com>'}
.gpg2 --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --with-colons --homedir /tmp/keys-03hc7lqk --version
gpg2 --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --with-colons --homedir /tmp/keys-03hc7lqk --debug-quick-random --dry-run --import-options import-show --import
gpg: keybox '/tmp/keys-03hc7lqk/pubring.kbx' created
gpg: /tmp/keys-03hc7lqk/trustdb.gpg: trustdb created
gpg: Total number processed: 2
[GNUPG:] IMPORT_RES 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0
pub:-:1024:17:967612475CED2E14:1216864513:::-:::scESC::::::::0:
fpr:::::::::4F6B5D46198BB40D1BD16B2C967612475CED2E14:
uid:-::::1216864513::5FE71F003D4EE074F680BC83FF9610339E6AE6E9::Gary Gross (A test user) <gary.gross@gamma.com>::::::::::0:
sub:-:2048:16:5431DEFBB92FC240:1216864513::::::e:::::::
fpr:::::::::ECBF43C6BAC47DCE06B8AF6C5431DEFBB92FC240:
pub:-:1024:17:6EDB2A64BBACC600:1216864597:::-:::scESC::::::::0:
fpr:::::::::A5024856AAC72420AA7198526EDB2A64BBACC600:
uid:-::::1216864597::0B2FC6EB572669101A340D19D60051D8D9D4C79A::Danny Davis (A test user) <danny.davis@delta.com>::::::::::0:
sub:-:2048:16:B50B2D38595BBE7C:1216864597::::::e:::::::
fpr:::::::::E8011929C27BEFE6B011C59DB50B2D38595BBE7C:
.
======================================== 2 passed, 38 deselected in 0.02s =========================================
.-(~/code/python-gnupg)--------------------------------------------------------------------------(clonejo@ghastly)-
`--> GPGBINARY=gpg-sq pytest -k test_scan_keys -s
=============================================== test session starts ===============================================
platform linux -- Python 3.10.9, pytest-7.2.1, pluggy-1.0.0
rootdir: /home/clonejo/code/python-gnupg
plugins: flake8-1.1.1, enabler-2.0.0, cov-4.0.0, black-0.3.12, mypy-0.10.3, checkdocs-2.7.1
collected 41 items / 38 deselected / 3 selected
test_gnupg.py gpg-sq --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --with-colons --homedir /tmp/keys-afdou7cf --version
gpg-sq --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --with-colons --homedir /tmp/keys-afdou7cf --debug-quick-random --dry-run --import-options import-show --import /tmp/pygpg-test-jpq1xbtp
[GNUPG:] KEY_CONSIDERED 4F6B5D46198BB40D1BD16B2C967612475CED2E14 0
gpg: key 967612475CED2E14: public key "Gary Gross (A test user) <gary.gross@gamma.com>" imported
[GNUPG:] IMPORTED 967612475CED2E14 Gary Gross (A test user) <gary.gross@gamma.com>
[GNUPG:] IMPORT_OK 1 4F6B5D46198BB40D1BD16B2C967612475CED2E14
[GNUPG:] KEY_CONSIDERED A5024856AAC72420AA7198526EDB2A64BBACC600 0
gpg: key 6EDB2A64BBACC600: public key "Danny Davis (A test user) <danny.davis@delta.com>" imported
[GNUPG:] IMPORTED 6EDB2A64BBACC600 Danny Davis (A test user) <danny.davis@delta.com>
[GNUPG:] IMPORT_OK 1 A5024856AAC72420AA7198526EDB2A64BBACC600
gpg: Total number processed: 2
gpg: imported: 2
[GNUPG:] IMPORT_RES 2 0 2 0 0 0 0 0 0 0 0 0 0 0 0
uids=set()
expected={'Gary Gross (A test user) <gary.gross@gamma.com>', 'Danny Davis (A test user) <danny.davis@delta.com>'}
Fgpg-sq --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --with-colons --homedir /tmp/keys-nwgp6xsw --version
gpg-sq --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --with-colons --homedir /tmp/keys-nwgp6xsw --debug-quick-random --dry-run --import-options import-show --import
[GNUPG:] KEY_CONSIDERED 4F6B5D46198BB40D1BD16B2C967612475CED2E14 0
gpg: key 967612475CED2E14: public key "Gary Gross (A test user) <gary.gross@gamma.com>" imported
[GNUPG:] IMPORTED 967612475CED2E14 Gary Gross (A test user) <gary.gross@gamma.com>
[GNUPG:] IMPORT_OK 1 4F6B5D46198BB40D1BD16B2C967612475CED2E14
[GNUPG:] KEY_CONSIDERED A5024856AAC72420AA7198526EDB2A64BBACC600 0
gpg: key 6EDB2A64BBACC600: public key "Danny Davis (A test user) <danny.davis@delta.com>" imported
[GNUPG:] IMPORTED 6EDB2A64BBACC600 Danny Davis (A test user) <danny.davis@delta.com>
[GNUPG:] IMPORT_OK 1 A5024856AAC72420AA7198526EDB2A64BBACC600
gpg: Total number processed: 2
gpg: imported: 2
[GNUPG:] IMPORT_RES 2 0 2 0 0 0 0 0 0 0 0 0 0 0 0
F
==================================================== FAILURES =====================================================
___________________________________________ GPGTestCase.test_scan_keys ____________________________________________
self = <test_gnupg.GPGTestCase testMethod=test_scan_keys>
def test_scan_keys(self):
"Test that external key files can be scanned"
# Don't use SkipTest for now, as not available for Python < 2.7
if self.gpg.version < (2, 1): # pragma: no cover
expected = set([
'Andrew Able (A test user) <andrew.able@alpha.com>',
'Barbara Brown (A test user) <barbara.brown@beta.com>',
'Charlie Clark (A test user) <charlie.clark@gamma.com>',
])
test_files = ('test_pubring.gpg', 'test_secring.gpg')
key_fn = None
else:
expected = set([
'Gary Gross (A test user) <gary.gross@gamma.com>',
'Danny Davis (A test user) <danny.davis@delta.com>',
])
fd, key_fn = tempfile.mkstemp(prefix='pygpg-test-')
os.write(fd, KEYS_TO_IMPORT.encode('ascii'))
os.close(fd)
test_files = (key_fn,)
try:
for fn in test_files:
logger.debug('scanning keys in %s', fn)
data = self.gpg.scan_keys(fn)
self.assertEqual(0, data.returncode, 'Non-zero return code')
uids = set()
for d in data:
uids.add(d['uids'][0])
print(f"uids={uids!r}")
print(f"expected={expected!r}")
> self.assertEqual(uids, expected)
E AssertionError: Items in the second set but not the first:
E 'Gary Gross (A test user) <gary.gross@gamma.com>'
E 'Danny Davis (A test user) <danny.davis@delta.com>'
test_gnupg.py:740: AssertionError
_________________________________________ GPGTestCase.test_scan_keys_mem __________________________________________
self = <test_gnupg.GPGTestCase testMethod=test_scan_keys_mem>
def test_scan_keys_mem(self):
"Test that external keys in memory can be scanned"
expected = set([
'Gary Gross (A test user) <gary.gross@gamma.com>',
'Danny Davis (A test user) <danny.davis@delta.com>',
])
for key in (KEYS_TO_IMPORT,):
logger.debug('testing scan_keys')
data = self.gpg.scan_keys_mem(key)
self.assertEqual(0, data.returncode, 'Non-zero return code')
uids = set()
for d in data:
uids.add(d['uids'][0])
> self.assertEqual(uids, expected)
E AssertionError: Items in the second set but not the first:
E 'Gary Gross (A test user) <gary.gross@gamma.com>'
E 'Danny Davis (A test user) <danny.davis@delta.com>'
test_gnupg.py:758: AssertionError
============================================= short test summary info =============================================
FAILED test_gnupg.py::GPGTestCase::test_scan_keys - AssertionError: Items in the second set but not the first:
FAILED test_gnupg.py::GPGTestCase::test_scan_keys_mem - AssertionError: Items in the second set but not the first:
======================================== 2 failed, 38 deselected in 0.10s =========================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment