mirror of
https://github.com/inspec/inspec
synced 2024-11-23 21:23:29 +00:00
Update resource based on PR feedback
Signed-off-by: Chris Redekop <chris.redekop@d2l.com>
This commit is contained in:
parent
3f22a54aa6
commit
0ab4ae7d6e
2 changed files with 11 additions and 15 deletions
|
@ -18,9 +18,7 @@ class AwsIamAccessKey < Inspec.resource(1)
|
||||||
|
|
||||||
def exists?
|
def exists?
|
||||||
!access_key.nil?
|
!access_key.nil?
|
||||||
rescue AccessKeyNotFoundError
|
rescue AccessKeyNotFoundError, Aws::IAM::Errors::NoSuchEntity
|
||||||
false
|
|
||||||
rescue Aws::IAM::Errors::NoSuchEntity
|
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -85,14 +85,13 @@ class AwsIamAccessKeyTest < Minitest::Test
|
||||||
def test_get_access_key_raises_when_no_access_keys_found
|
def test_get_access_key_raises_when_no_access_keys_found
|
||||||
validator = mock_validator
|
validator = mock_validator
|
||||||
|
|
||||||
begin
|
e = assert_raises AwsIamAccessKey::AccessKeyNotFoundError do
|
||||||
iam_client_decorator(validator).get_access_key(Username, Id)
|
iam_client_decorator(validator).get_access_key(Username, Id)
|
||||||
flunk
|
end
|
||||||
rescue AwsIamAccessKey::AccessKeyNotFoundError => e
|
|
||||||
assert_match(/.*access key not found.*/, e.message)
|
assert_match(/.*access key not found.*/, e.message)
|
||||||
assert_match(/.*#{Username}.*/, e.message)
|
assert_match(/.*#{Username}.*/, e.message)
|
||||||
assert_match(/.*#{Id}.*/, e.message)
|
assert_match(/.*#{Id}.*/, e.message)
|
||||||
end
|
|
||||||
|
|
||||||
validator.verify
|
validator.verify
|
||||||
end
|
end
|
||||||
|
@ -100,15 +99,14 @@ class AwsIamAccessKeyTest < Minitest::Test
|
||||||
def test_get_access_key_raises_when_matching_access_key_not_found
|
def test_get_access_key_raises_when_matching_access_key_not_found
|
||||||
validator = mock_validator
|
validator = mock_validator
|
||||||
|
|
||||||
begin
|
e = assert_raises AwsIamAccessKey::AccessKeyNotFoundError do
|
||||||
iam_client_decorator(validator, [stub_access_key(id: 'Foo')])
|
iam_client_decorator(validator, [stub_access_key(id: 'Foo')])
|
||||||
.get_access_key(Username, Id)
|
.get_access_key(Username, Id)
|
||||||
flunk
|
end
|
||||||
rescue AwsIamAccessKey::AccessKeyNotFoundError => e
|
|
||||||
assert_match(/.*access key not found.*/, e.message)
|
assert_match(/.*access key not found.*/, e.message)
|
||||||
assert_match(/.*#{Username}.*/, e.message)
|
assert_match(/.*#{Username}.*/, e.message)
|
||||||
assert_match(/.*#{Id}.*/, e.message)
|
assert_match(/.*#{Id}.*/, e.message)
|
||||||
end
|
|
||||||
|
|
||||||
validator.verify
|
validator.verify
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue