2.2.0 - Added export_private/public to KeyManager, add Mocker class plus more
The below list is mostly exhaustive list of all core changes in this version. Some small things may have been missed, but the majority
of changes are written below.
New Features / Additions
privex.helpers.crypto.KeyManager
- Added
export_public
andexport_private
allowing you to export the currently loaded public/private key in KeyManager - Added
export_key
which serialises a cryptography PrivateKey / PublicKey - intended for internal use by KeyManager, but
may be useful to others, so it's available as a public class method. - Refactored
generate_keypair
to useexport_key
- Added
identify_algorithm
which returns the string algorithm e.g.'ed25519'
for a given cryptography PublicKey / PrivateKey instance - Added attribute
type_name_map
which maps public/private key cryptography types to their string algorithm name - Improved exception handling in
load_key
ensuring most common key decoding errors raiseInvalidFormat
instead of different package exceptions
- Added
- Added
Mocker
class tohelpers.common
- useful for mocking classes, or used as a makeshift replacement for modules/classes that couldn't be imported - Added
mock_decorator
tohelpers.decorators
- intended to be used withMocker
- it's a decorator which simply... does nothing. purely pass-thru - Added
HAS_CRYPTO
HAS_SETUPPY_COMMON
HAS_SETUPPY_BUMP
andHAS_SETUPPY_COMMANDS
tohelpers.plugin
allowing for easier detection whether certain
modules are available or not (e.g. due to a user not having a certain dependency package installed).
Testing
- Re-wrote parts of the "How to use the unit tests" docs in
tests/__init__.py
- Added PyTest skipping to tests/test_cache.py for redis tests (uses the new
Mocker
to ensure the tests work without PyTest installed) - Added PyTest skipping to tests/test_net.py for dnspython tests (uses
Mocker
just like test_cache) - Created a base class
CryptoBaseClass
for cryptography tests intest_crypto.py
- Moved signing/verification into a helper method
_sign_verify
in this base class
- Moved signing/verification into a helper method
- Added new tests
- Split up KeyManager tests into
TestKeyManagerLoad
,TestKeyManagerGeneration
, andTestKeyManagerSignVerifyEncrypt
- Added unit tests for outputting key pairs to files with
KeyManager.output_keypair
- Added several unit tests for outputting and then loading key pairs from files with
KeyManager.load_keyfile
- Added relatively thorough unit tests for the new
Mocker
class
- Split up KeyManager tests into
Documentation
- Lots of small changes.
- Removed
:noindex:
from a lot of files because it was causing linking to classes/modules in pydoc comments to break.
This unfortunately means Sphinx throws a lot of warnings, but can't find a way to fix this without breaking class/module linking. - Added docs for
Mocker
andmock_decorator
- Re-generated toctree files for various modules including
crypto
andtests