mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-04 19:26:52 +00:00
Merge pull request #60 from arahayrabedian/master
AWS credential checking
This commit is contained in:
commit
99574324eb
10 changed files with 129 additions and 0 deletions
35
tests/detect_aws_credentials_test.py
Normal file
35
tests/detect_aws_credentials_test.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import pytest
|
||||
|
||||
from pre_commit_hooks.detect_aws_credentials import main
|
||||
from testing.util import get_resource_path
|
||||
|
||||
|
||||
# Input filename, expected return value
|
||||
TESTS = (
|
||||
('with_no_secrets.txt', 0),
|
||||
('with_secrets.txt', 1),
|
||||
('nonsense.txt', 0),
|
||||
('ok_json.json', 0),
|
||||
)
|
||||
|
||||
NO_CREDENTIALS_TEST = (
|
||||
('with_secrets.txt', 2),
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(('filename', 'expected_retval'), TESTS)
|
||||
def test_detect_aws_credentials(filename, expected_retval):
|
||||
# with a valid credentials file
|
||||
ret = main(
|
||||
[get_resource_path(filename), "--credentials-file=testing/resources/sample_aws_credentials"]
|
||||
)
|
||||
assert ret == expected_retval
|
||||
|
||||
|
||||
@pytest.mark.parametrize(('filename', 'expected_retval'), NO_CREDENTIALS_TEST)
|
||||
def test_non_existent_credentials(filename, expected_retval):
|
||||
# with a non-existent credentials file
|
||||
ret = main(
|
||||
[get_resource_path(filename), "--credentials-file=testing/resources/credentailsfilethatdoesntexist"]
|
||||
)
|
||||
assert ret == expected_retval
|
||||
Loading…
Add table
Add a link
Reference in a new issue