mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-03-30 02:16:52 +00:00
Unit test for empty AWS variables
This commit is contained in:
parent
ace459bec5
commit
75d4832e98
2 changed files with 4 additions and 2 deletions
|
|
@ -31,7 +31,7 @@ def get_aws_secrets_from_env() -> Set[str]:
|
|||
for env_var in (
|
||||
'AWS_SECRET_ACCESS_KEY', 'AWS_SECURITY_TOKEN', 'AWS_SESSION_TOKEN',
|
||||
):
|
||||
if env_var in os.environ:
|
||||
if env_var in os.environ and os.environ[env_var]:
|
||||
keys.add(os.environ[env_var])
|
||||
return keys
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ def check_file_for_aws_keys(
|
|||
for key in keys:
|
||||
# naively match the entire file, low chance of incorrect
|
||||
# collision
|
||||
if key and key in text_body:
|
||||
if key in text_body:
|
||||
bad_files.append(BadFile(filename, key[:4].ljust(28, '*')))
|
||||
return bad_files
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ def test_get_aws_credentials_file_from_env(env_vars, values):
|
|||
({'AWS_SECRET_ACCESS_KEY': 'foo'}, {'foo'}),
|
||||
({'AWS_SECURITY_TOKEN': 'foo'}, {'foo'}),
|
||||
({'AWS_SESSION_TOKEN': 'foo'}, {'foo'}),
|
||||
({'AWS_SESSION_TOKEN': ''}, set()),
|
||||
({'AWS_SESSION_TOKEN': 'foo', 'AWS_SECURITY_TOKEN': ''}, {'foo'}),
|
||||
({'AWS_DUMMY_KEY': 'foo', 'AWS_SECRET_ACCESS_KEY': 'bar'}, {'bar'}),
|
||||
(
|
||||
{'AWS_SECRET_ACCESS_KEY': 'foo', 'AWS_SECURITY_TOKEN': 'bar'},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue