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_publicandexport_privateallowing you to export the currently loaded public/private key in KeyManager - Added
export_keywhich 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_keypairto useexport_key - Added
identify_algorithmwhich returns the string algorithm e.g.'ed25519'for a given cryptography PublicKey / PrivateKey instance - Added attribute
type_name_mapwhich maps public/private key cryptography types to their string algorithm name - Improved exception handling in
load_keyensuring most common key decoding errors raiseInvalidFormatinstead of different package exceptions
- Added
- Added
Mockerclass tohelpers.common- useful for mocking classes, or used as a makeshift replacement for modules/classes that couldn't be imported - Added
mock_decoratortohelpers.decorators- intended to be used withMocker- it's a decorator which simply... does nothing. purely pass-thru - Added
HAS_CRYPTOHAS_SETUPPY_COMMONHAS_SETUPPY_BUMPandHAS_SETUPPY_COMMANDStohelpers.pluginallowing 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
Mockerto ensure the tests work without PyTest installed) - Added PyTest skipping to tests/test_net.py for dnspython tests (uses
Mockerjust like test_cache) - Created a base class
CryptoBaseClassfor cryptography tests intest_crypto.py- Moved signing/verification into a helper method
_sign_verifyin 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
Mockerclass
- 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
Mockerandmock_decorator - Re-generated toctree files for various modules including
cryptoandtests