mirror of
https://github.com/inspec/inspec
synced 2024-11-10 23:24:18 +00:00
Add has_mfa_enabled? to aws_iam_root_account (#80)
Signed-off-by: Chris Redekop <chris.redekop@d2l.com>
This commit is contained in:
parent
033bc13aa0
commit
c77d442007
2 changed files with 22 additions and 0 deletions
|
@ -16,6 +16,10 @@ class AwsIamRootUser < Inspec.resource(1)
|
|||
summary_account['AccountAccessKeysPresent']
|
||||
end
|
||||
|
||||
def has_mfa_enabled?
|
||||
summary_account['AccountMFAEnabled'] == 1
|
||||
end
|
||||
|
||||
def to_s
|
||||
'AWS Root-User'
|
||||
end
|
||||
|
|
|
@ -19,4 +19,22 @@ class AwsIamRootUserTest < Minitest::Test
|
|||
|
||||
assert_equal expected_keys, AwsIamRootUser.new(@mock_conn).access_key_count
|
||||
end
|
||||
|
||||
def test_has_mfa_enabled_returns_true_when_account_mfa_devices_is_one
|
||||
test_summary_map = OpenStruct.new(
|
||||
summary_map: { 'AccountMFAEnabled' => 1 },
|
||||
)
|
||||
@mock_client.expect :get_account_summary, test_summary_map
|
||||
|
||||
assert_equal true, AwsIamRootUser.new(@mock_conn).has_mfa_enabled?
|
||||
end
|
||||
|
||||
def test_has_mfa_enabled_returns_false_when_account_mfa_devices_is_zero
|
||||
test_summary_map = OpenStruct.new(
|
||||
summary_map: { 'AccountMFAEnabled' => 0 },
|
||||
)
|
||||
@mock_client.expect :get_account_summary, test_summary_map
|
||||
|
||||
assert_equal false, AwsIamRootUser.new(@mock_conn).has_mfa_enabled?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue