pytest-gnupg-fixtures
Overview
Pytest fixtures to dynamically create GnuPG instances for testing.
Getting Started
Update setup.py to include:
from distutils.core import setup
setup(
tests_require=["pytest-gnupg-fixtures"]
)
All fixtures should be automatically included via the pytest11 entry point.
from pytest_gnupg_fixtures import GnuPGKeypair # Optional, for typing
def test_custom_signer(gnupg_keypair: GnuPGKeypair):
custom_signer = CustomSigner(
keyid=gnupg_keypair.fingerprints[1],
passphrase=gnupg_keypair.passphrase,
homedir=gnupg_keypair.gnupg_home,
)
assert "PGP SIGNATURE" in custom_signer.sign("my data")
- Tested with python 3.8
Installation
From pypi.org
$ pip install pytest_gnupg_fixtures
From source code
$ git clone https://github.com/crashvb/pytest-gnupg-fixtures
$ cd pytest-gnupg-fixtures
$ virtualenv env
$ source env/bin/activate
$ python -m pip install --editable .[dev]
Fixtures
gnupg_email
Provides a generated email to use as part of the uid for the keypair.
gnupg_gen_key_conf
Provides the path to a templated GnuPG script file that is used to generate a temporary keypair. If a user-defined script (tests/gnupg_gen_key.conf) can be located, it is used. Otherwise, an embedded script template is copied to temporary location and returned. This fixture is used by the gnupg_keypair fixture.
The$GNUGP_EMAIL and $GNUPG_PASSPHRASE variables will be populated within the template during generation of the keypair.
gnupg_keypair
Provides a keypair within a temporary GnuPG trust store.
NamedTuple Fields
The following fields are defined in the tuple provided by this fixture:
- email - from gnupg_email
- fingerprints - A list of key fingerprints. Typically: pubkey, subkey...
- gnupg_home - from gnupg_trust_store
- keyid - The public key id of the temporary keypair.
- gen_key_conf - from gnupg_gen_key_conf
- passphrase - from gnupg_passphrase
- script - The path to the instantiated script from gnupg_gen_key_conf
- uids A list of uids existing within the trust store.
Typing is provided by pytest_gnupg_fixtures.GnuPGKeypair.
gnupg_passphrase
Provides a generated passphrase to use for the keypair.
gnupg_trust_store
Provides a temporary, initialized, GnuPG trust store that is contains no keys. This fixture is used by the gnupg_keypair fixture.
NamedTuple Fields
The following fields are defined in the tuple provided by this fixture:
- gnupg_home - The path to the temporary trust store.
Typing is provided by pytest_gnupg_fixtures.GnuPGTrustStore.
Limitations
- This has been coded to work with gpg2.
- The generated keypair is very simple. TBD if this will be expanded to support a more realistic configuration.
Development
Metadata
Release files for pytest-gnupg-fixtures 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytest_gnupg_fixtures-0.1.6.tar.gz | 6.1 kB | Without provenance | Details for pytest_gnupg_fixtures-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_gnupg_fixtures-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for pytest_gnupg_fixtures-0.1.6-py3-none-any.whl |
Total release size: 17.7 kB
Release files / pytest_gnupg_fixtures-0.1.6.tar.gz
| Download URL | pytest_gnupg_fixtures-0.1.6.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8fd17caf1a44743e524aa8a7ce3028d5ebbdb9c6fb8d9fe8caea24adc005f726
|
|
BLAKE2b-256 checksum How to use checksums |
893e8d69d95bd83a054e916cdd0d52242b57386bcc099a053d29037240428303
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.3
|
Release files / pytest_gnupg_fixtures-0.1.6-py3-none-any.whl
| Download URL | pytest_gnupg_fixtures-0.1.6-py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
deda26ce49ab9538d9a7758a3f3c27ff2fd7b051d1e29c864c7ba9a0ddd48405
|
|
BLAKE2b-256 checksum How to use checksums |
fa661d2113c9c3e50c2d7c2b0d62637caa3853dbbd897ac8647ed2363f16f21f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.3
|
Security for pytest-gnupg-fixtures 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.