Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Refactored the secrets.py module #273

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

cdsre
Copy link

@cdsre cdsre commented Apr 7, 2024

Refactored the secrets.py module removing the env and vault secret manager code and refactored them into their own modules in a new secretmanager package. Also refactored the tests. All tests continue to pass

(venv) cdsre@cdsre-NBLK-WAX9X:~/PycharmProjects/chaostoolkit-lib$ pytest tests/secretmanagers/test*
Test session starts (platform: linux, Python 3.10.12, pytest 7.4.4, pytest-sugar 1.0.0)
cachedir: .pytest_cache
rootdir: /home/cdsre/PycharmProjects/chaostoolkit-lib
configfile: pyproject.toml
plugins: anyio-4.3.0, requests-mock-1.11.0, sugar-1.0.0, cov-4.1.0
collected 16 items                                                                                                                                                                                   

 tests/secretmanagers/test_env.py::test_should_load_environment ✓                                                                                                                        6% ▋         
 tests/secretmanagers/test_env.py::test_should_load_nested_environment ✓                                                                                                                12% █▍        
 tests/secretmanagers/test_env.py::test_should_load_inline ✓                                                                                                                            19% █▉        
 tests/secretmanagers/test_env.py::test_should_merge_properly ✓                                                                                                                         25% ██▌       
 tests/secretmanagers/test_vault.py::test_should_auth_with_approle ✓                                                                                                                    31% ███▎      
 tests/secretmanagers/test_vault.py::test_should_catch_approle_invalid_secret_id_abort_the_run ✓                                                                                        38% ███▊      
 tests/secretmanagers/test_vault.py::test_should_auth_with_token ✓                                                                                                                      44% ████▍     
 tests/secretmanagers/test_vault.py::test_should_auth_with_service_account ✓                                                                                                            50% █████     
 tests/secretmanagers/test_vault.py::test_should_catch_service_account_invalid_abort_the_run ✓                                                                                          56% █████▋    
 tests/secretmanagers/test_vault.py::test_read_secrets_from_vault_with_kv_version_1 ✓                                                                                                   62% ██████▍   
 tests/secretmanagers/test_vault.py::test_read_secrets_from_vault_with_kv_version_2 ✓                                                                                                   69% ██████▉   
 tests/secretmanagers/test_vault.py::test_override_load_environmen_with_var ✓                                                                                                           75% ███████▌  
 tests/secretmanagers/test_vault.py::test_should_override_load_inline_with_var ✓                                                                                                        81% ████████▎ 
 tests/secretmanagers/test_vault.py::test_vault_add_subkeys ✓                                                                                                                           88% ████████▊ 
 tests/secretmanagers/test_vault.py::test_vault_replace_entire_declare ✓                                                                                                                94% █████████▍
 tests/secretmanagers/test_vault.py::test_override_vault_with_vars ✓                                                                                                                   100% ██████████

---------- coverage: platform linux, python 3.10.12-final-0 ----------
Name                               Stmts   Miss  Cover   Missing
----------------------------------------------------------------
chaoslib/__init__.py                 188    153    19%   41-42, 60-79, 92-107, 111, 117-130, 136-149, 160-174, 202-267, 278-296, 311-330, 348-356, 369, 384-389
chaoslib/activity.py                 164    164     0%   1-339
chaoslib/caching.py                   46     46     0%   3-92
chaoslib/configuration.py             60     60     0%   1-200
chaoslib/control/__init__.py         216    216     0%   1-507
chaoslib/control/python.py            91     91     0%   1-204
chaoslib/deprecation.py               31     31     0%   1-69
chaoslib/discovery/__init__.py         2      2     0%   1-8
chaoslib/discovery/discover.py       109    109     0%   1-227
chaoslib/discovery/package.py         53     53     0%   1-122
chaoslib/exit.py                      48     48     0%   43-163
chaoslib/experiment.py                67     67     0%   1-185
chaoslib/extension.py                 51     51     0%   1-105
chaoslib/hypothesis.py               205    205     0%   1-425
chaoslib/info.py                      26     26     0%   1-56
chaoslib/loader.py                    71     71     0%   1-133
chaoslib/log.py                      108     55    49%   3-4, 20-22, 35-44, 83-84, 93-99, 113, 117-129, 150-151, 154-155, 168, 171-191, 197, 200-206
chaoslib/notification.py              92     92     0%   1-237
chaoslib/provider/http.py             52     52     0%   1-130
chaoslib/provider/process.py          48     48     0%   1-111
chaoslib/provider/python.py           74     74     0%   1-148
chaoslib/rollback.py                  19     19     0%   1-51
chaoslib/run.py                      511    511     0%   1-1154
chaoslib/secretmanagers/env.py        12      1    92%   14
chaoslib/secretmanagers/vault.py      67     10    85%   11-12, 73-77, 82-83, 104-105, 186-187
chaoslib/settings.py                  62     46    26%   30-43, 53-59, 66, 96-132
chaoslib/types.py                     71     27    62%   77-90, 101-112, 122-124
----------------------------------------------------------------
TOTAL                               2590   2328    10%

4 files skipped due to complete coverage.


Results (0.45s):
      16 passed

…t secret manager code and refacotred them into their own modules in a new secretmanager package. Also refacotored the tests

Signed-off-by: Chris Doyle <[email protected]>
Copy link
Contributor

@Lawouach Lawouach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cdsre that does look like a solid start!

Can you:

  • ensure the linter is happy
  • add a changelog entry

Cheers

@cdsre
Copy link
Author

cdsre commented Jul 2, 2024

@Lawouach Sorry for the late reply on this one. I have pulled the latest from ctk-lib and have updated to fix the linter and change log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants