Commit Graph

26 Commits

Author SHA1 Message Date
Levente Polyak
099df52a04
feature(keyringctl): support query expressions for packet field selection
Instead of simply string matching a line, we now traverse the packet as
a tree and match the path based on a depth first search.

While traversing, we support logical OR and current depth * wildcard
processed as a component based query expression.

Callee's are adjusted to specifically select the appropriate Issuer at
the correct depth.

Fixes #185
2022-07-20 21:34:37 +02:00
Levente Polyak
f908838822
fix(trust): do not count revoked main keys for packager trust
If a main key is revoked we do not want to use those keys to count
the required trust threshold.
2022-02-25 21:36:35 +01:00
Levente Polyak
37ad62d6e5
feature(keyringctl): add clean functionality to match import-clean
De-duplicate not needed certifications by cleaning the keyring after
import to remove old files when processing revocations. This basically
adds the functionality compared to import-clean.
2021-12-08 20:50:45 +01:00
Levente Polyak
0ceb6c743e
fix(keyringctl): avoid simplified uid collisions using a hash
Add a postfix hash of the raw uid data to the filenames to avoid
collisions with the simplified uid.
2021-11-30 22:54:17 +01:00
Levente Polyak
b32c37bec1
feature(keyringctl): raise exception on duplicate uid data 2021-11-30 22:54:17 +01:00
Levente Polyak
c651bdc61e
feature(keyringctl): add option to filter listing by trust 2021-11-30 22:54:17 +01:00
Levente Polyak
e9dc04df32
feature(keyringctl): split direct key packets into own directory 2021-11-30 22:54:16 +01:00
David Runge
e43a28f4a7
Simplify libkeyringctl.keyring.convert_certificate
libkeyringctl/keyring.py:
Simplify `convert_certificate()` by splitting out the conversion of
signature packets to `convert_signature_packet()` and the persistence of
packet material to `persist_key_material()`.
Add `convert_pubkey_signature_packet()`,
`convert_uid_signature_packet()` and
`convert_subkey_signature_packet()` to deal with the conversion of
public key signatures, UID signatures and subkey signatures
(respectively).

tests/test_keyring.py:
Add tests for `convert_certificate()`, `convert_signature_packet()`,
`convert_{pubkey,uid,subkey}_signature_packet()` and
`persist_subkey_revocations()`.
2021-11-30 22:54:16 +01:00
David Runge
bb30e3d2fd
Add tests for list and inspect functions
tests/test_keyring.py:
Add tests for `list_keyring()` and `inspect_keyring()`.
2021-11-30 22:54:16 +01:00
David Runge
743d2bb3bb
Add tests for introspection and export
libkeyringctl/keyring.py:
Change `get_packets_from_path()` to use full conditional statements
which is easier to cover in tests.

tests/test_keyring.py:
Add simple tests for `get_packets_from_path()`,
`get_packets_from_listing()`, `export()` and `build()`.
2021-11-30 22:54:16 +01:00
David Runge
3d8e88dfaf
Add tests for convert and export functionality
tests/test_keyring.py:
Add basic tests for `convert()`, `export_ownertrust()` and
`export_revoked()`.
2021-11-30 22:54:16 +01:00
Levente Polyak
e8fb9d17b3
chore(keyringctl): add test for simplify_ascii 2021-11-30 22:54:16 +01:00
Levente Polyak
bce5bc550e
feature(keyringctl): rework str simplification for printable uids 2021-11-30 22:54:16 +01:00
David Runge
17d27e2274
Add unit test for libkeyringctl.sequoia.packet_kinds
tests/test_sequoia.py:
Add unit test for libkeyringctl.sequoia.packet_kinds.
2021-11-30 22:54:15 +01:00
Levente Polyak
0456e9a5f8
fix(tests): use working dir via fixture instead of cluttering cwd 2021-11-30 22:54:15 +01:00
David Runge
ddf19a4362
Add first unit tests for libkeyringctl.keyring
tests/test_keyring.py:
Add tests for `is_pgp_fingerprint()`,
`transform_{fingerprint,username}_to_keyring_path()`,
`derive_username_from_fingerprint()` and get_fingerprints_from_paths()`.
2021-11-30 22:54:15 +01:00
David Runge
16bed8ac4a
Add fixtures for valid and invalid fingerprints
tests/conftest.py:
Add `valid_fingerprint()` and `valid_subkey_fingerprint()` fixtures to
produce a generic "valid" PGP fingerprint string.
Add the `invalid_fingerprint()` fixture to generate a set of "invalid"
fingerprint strings.
2021-11-30 22:54:15 +01:00
Levente Polyak
d9e9453d84
feature(keyringctl): write all packet files with full issuer fingerprint
This avoids collision between same issuer using key-id and full
fingerprint in different versions of a packet, like signature.
2021-11-30 22:54:15 +01:00
Levente Polyak
279765b22a
fix(keyringctl): fix system stderr case due to wrongly written test
CalledProcessError returns bytes for our invocations, the fix that
decoded bytes of stdout was purely to make the mocked test happy while
breaking the actual usage. Restore the behavior and fix the wrong mocked
data.
2021-11-30 22:54:14 +01:00
Levente Polyak
cd585f4be2
chore(keyringctl): increase test coverage and fix trust expectations 2021-11-30 22:54:14 +01:00
Levente Polyak
7513e71b3f
chore(keyringctl): add key revocation trust tests 2021-11-30 22:54:14 +01:00
Levente Polyak
86eb172ac3
chore(keyringctl): add missing type annotations for tests 2021-11-30 22:54:14 +01:00
David Runge
358e840f8f
Add unit tests for util functions
tests/test_util.py:
Add tests for `cwd()`, `natural_sort_path()`, `system()`,
`absolute_path()`, `transform_fd_to_tmpfile()`, `get_cert_paths()`,
`get_parent_cert_paths()` and `contains_fingerprint()`.
2021-11-30 22:54:14 +01:00
David Runge
c1f59488e5
Add unit tests for code calling sequoia
tests/test_sequoia.py:
Add unit tests for `keyring_split()`, `keyring_merge()`,
`packet_split()`, `packet_join()`, `inspect()`, `packet_dump()`,
`packet_dump_field()`, `packet_signature_creation_time()`, and
`latest_certification()`.
2021-11-30 22:54:14 +01:00
David Runge
52e0936524
Add unit test for git integration
tests/test_git.py:
Add unit test for `git_changed_files()`.
2021-11-30 22:54:14 +01:00
David Runge
4597fba6ba
Rename test directory to tests
tests/*:
The existing coverage configuration is setup to use/ omit a tests
directory.
2021-11-30 22:54:13 +01:00