mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-06-29 06:00:45 +00:00
[ISS-1258][DC] updating the detect_aws_credentials to support temp json files
This commit is contained in:
parent
fa6b006f0e
commit
10ce480836
3 changed files with 70 additions and 7 deletions
|
|
@ -7,6 +7,7 @@ import pytest
|
|||
from pre_commit_hooks.detect_aws_credentials import get_aws_cred_files_from_env
|
||||
from pre_commit_hooks.detect_aws_credentials import get_aws_secrets_from_env
|
||||
from pre_commit_hooks.detect_aws_credentials import get_aws_secrets_from_file
|
||||
from pre_commit_hooks.detect_aws_credentials import get_aws_secrets_from_json_file
|
||||
from pre_commit_hooks.detect_aws_credentials import main
|
||||
from testing.util import get_resource_path
|
||||
|
||||
|
|
@ -67,6 +68,22 @@ def test_get_aws_secrets_from_env(env_vars, values):
|
|||
with patch.dict('os.environ', env_vars, clear=True):
|
||||
assert get_aws_secrets_from_env() == values
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
('filename', 'expected_keys'),
|
||||
(
|
||||
(
|
||||
'aws_temp_secrets_file.json',
|
||||
{"tempAccessKeyId", "tempSecretAccessKey", "tempSessionToken"},
|
||||
),
|
||||
('nonsense.txt', set()),
|
||||
('ok_json.json', set()),
|
||||
),
|
||||
)
|
||||
def test_get_aws_secrets_from_json_file(filename, expected_keys):
|
||||
"""Test that reading secrets from files works."""
|
||||
keys = get_aws_secrets_from_json_file(get_resource_path(filename))
|
||||
assert keys == expected_keys
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
('filename', 'expected_keys'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue