Add flag to detect-aws-credentials to allow missing keys

In the event that there exists no configuration for AWS credentials and
they are not exported in to the current environment, a flag may be
passed to allow exiting the hook successfully.

Resolves #174

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
This commit is contained in:
Mike Fiedler 2017-02-10 08:26:26 -05:00
parent 20f04626a1
commit 312e721ce9
No known key found for this signature in database
GPG key ID: 5E1134F2FAF158B9
2 changed files with 23 additions and 0 deletions

View file

@ -130,3 +130,17 @@ def test_non_existent_credentials(mock_secrets_env, mock_secrets_file, capsys):
'and environment variables.\nPlease ensure you have the '
'correct setting for --credentials-file\n'
)
@patch('pre_commit_hooks.detect_aws_credentials.get_aws_secrets_from_file')
@patch('pre_commit_hooks.detect_aws_credentials.get_aws_secrets_from_env')
def test_non_existent_credentials_with_allow_flag(mock_secrets_env, mock_secrets_file):
"""Test behavior with no configured AWS secrets and flag to allow when missing."""
mock_secrets_env.return_value = set()
mock_secrets_file.return_value = set()
ret = main((
get_resource_path('aws_config_without_secrets.ini'),
"--credentials-file=testing/resources/credentailsfilethatdoesntexist",
"--allow-missing-credentials"
))
assert ret == 0