Skip to content

2.2.0 - Added export_private/public to KeyManager, add Mocker class plus more

Compare
Choose a tag to compare
@Someguy123 Someguy123 released this 04 Nov 12:52
· 61 commits to master since this release

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 and export_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 use export_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 raise InvalidFormat instead of different package exceptions
  • Added Mocker class to helpers.common - useful for mocking classes, or used as a makeshift replacement for modules/classes that couldn't be imported
  • Added mock_decorator to helpers.decorators - intended to be used with Mocker - it's a decorator which simply... does nothing. purely pass-thru
  • Added HAS_CRYPTO HAS_SETUPPY_COMMON HAS_SETUPPY_BUMP and HAS_SETUPPY_COMMANDS to helpers.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 in test_crypto.py
    • Moved signing/verification into a helper method _sign_verify in this base class
  • Added new tests
    • Split up KeyManager tests into TestKeyManagerLoad, TestKeyManagerGeneration, and TestKeyManagerSignVerifyEncrypt
    • 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

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 and mock_decorator
  • Re-generated toctree files for various modules including crypto and tests