Skip to content

Commit 96bc698

Browse files
committed
2.2.0 - Added export_private/public to KeyManager
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`
1 parent e151da2 commit 96bc698

164 files changed

Lines changed: 2234 additions & 124 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ __pycache__
66
.vscode
77

88
# PyPi build files
9+
.coverage
910
build
1011
dist
1112
*.egg-info

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ before_install:
1515
- sudo apt-get install -qy iputils-ping
1616
install:
1717
- pip install -U '.[dev]'
18-
script: pytest --cov=./privex -v
18+
script: pytest --cov=./privex -rxXs -v
1919
after_success:
2020
- codecov

docs/source/_templates/autosummary/class.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
.. autoclass:: {{ objname }}
66

77
{% block methods %}
8-
.. automethod:: __init__
8+
.. automethod:: __init__
9+
:noindex:
910

1011
{% if methods %}
1112
Methods

docs/source/helpers/cache/privex.helpers.cache.MemoryCache.MemoryCache.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ MemoryCache
44
.. currentmodule:: privex.helpers.cache.MemoryCache
55

66
.. autoclass:: MemoryCache
7-
:noindex:
8-
7+
98
.. automethod:: __init__
109
:noindex:
1110

docs/source/helpers/cache/privex.helpers.cache.RedisCache.RedisCache.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ RedisCache
44
.. currentmodule:: privex.helpers.cache.RedisCache
55

66
.. autoclass:: RedisCache
7-
:noindex:
87

98

109
.. automethod:: __init__
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
\_\_init\_\_
2+
============
3+
4+
.. currentmodule:: privex.helpers.common
5+
6+
.. automethod:: Mocker.__init__
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
add\_mock\_module
2+
=================
3+
4+
.. currentmodule:: privex.helpers.common
5+
6+
.. automethod:: Mocker.add_mock_module
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
make\_mock\_class
2+
=================
3+
4+
.. currentmodule:: privex.helpers.common
5+
6+
.. automethod:: Mocker.make_mock_class
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Mocker
2+
======
3+
4+
.. currentmodule:: privex.helpers.common
5+
6+
.. autoclass:: Mocker
7+
:noindex:
8+
9+
.. automethod:: __init__
10+
:noindex:
11+
12+
13+
Methods
14+
^^^^^^^
15+
16+
.. rubric:: Methods
17+
18+
.. autosummary::
19+
:toctree: mocker
20+
21+
~Mocker.__init__
22+
~Mocker.add_mock_module
23+
~Mocker.make_mock_class
24+
25+
26+
27+
28+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export\_key
2+
===========
3+
4+
.. currentmodule:: privex.helpers.crypto.KeyManager
5+
6+
.. automethod:: KeyManager.export_key

0 commit comments

Comments
 (0)