-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for multiple secrets directories (#12)
* Add support for multiple secrets directories
- Loading branch information
Showing
8 changed files
with
126 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.1.3' | ||
__version__ = '0.2.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import pytest | ||
|
||
|
||
def test_merge(settings_model, monkeypatch, secrets_dir): | ||
monkeypatch.setenv('DB__USER', 'user') | ||
secrets_dir.add_files( | ||
('dir1/app_key', 'secret1'), | ||
('dir1/db___password', 'secret2'), | ||
('dir2/db___password', 'secret3'), | ||
) | ||
Settings = settings_model( | ||
model_config=dict( | ||
env_nested_delimiter='__', | ||
secrets_dir=[secrets_dir / 'dir1', secrets_dir / 'dir2'], | ||
secrets_nested_delimiter='___', | ||
), | ||
) | ||
conf = Settings() | ||
assert conf.app_key == 'secret1' | ||
assert conf.db.password == 'secret3' # noqa: S105 | ||
|
||
|
||
def test_missing(settings_model, monkeypatch, secrets_dir): | ||
monkeypatch.setenv('DB__USER', 'user') | ||
Settings = settings_model( | ||
model_config=dict( | ||
env_nested_delimiter='__', | ||
secrets_dir=[secrets_dir / 'dir1', secrets_dir / 'dir2'], | ||
secrets_nested_delimiter='___', | ||
), | ||
) | ||
with pytest.warns(UserWarning) as warninfo: | ||
Settings() | ||
assert len(warninfo) == 2 | ||
assert all('does not exist' in w.message.args[0] for w in warninfo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters