Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
Update func test to match updates
Browse files Browse the repository at this point in the history
Signed-off-by: Rony Xavier <rxavier@mitre.org>
  • Loading branch information
Rony Xavier committed Apr 9, 2021
1 parent 8b3a013 commit 616cf32
Showing 1 changed file with 29 additions and 22 deletions.
51 changes: 29 additions & 22 deletions test/functional/inspec_plugin_functional_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,104 +4,111 @@ class InspecPluginFunctionalTest < Minitest::Test
def test_with_a_single_pass_non_expired_attestation
hdf_json = JSON.parse(File.read('test_hdf.json'))
assert_equal('passed', hdf_json['profiles'][0]['controls'][0]['results'][0]['status'])
assert_match(%r(Automated test returned as passed.\n Attestation:\n Status: passed\n Explanation: Non-expired Status passed\n), hdf_json['profiles'][0]['controls'][0]['results'][0]['message'])
assert_equal('passed', hdf_json['profiles'][0]['controls'][0]['results'][1]['status'])

message = hdf_json['profiles'][0]['controls'][0]['results'][1]['message']
assert_match(%r(Attestation:), message)
assert_match(%r(Status: passed), message)
assert_match(%r(Explanation: Non-expired Status passed), message)
assert_match(%r(Updated By: John Doe, ISSO), message)
assert_match(%r(Frequency: annually), message)
refute_nil(hdf_json['profiles'][0]['controls'][0]['attestation'])
end


def test_with_a_multiple_pass_non_expired_attestation
hdf_json = JSON.parse(File.read('test_hdf.json'))
assert_equal('passed', hdf_json['profiles'][0]['controls'][1]['results'][0]['status'])
assert_equal('passed', hdf_json['profiles'][0]['controls'][1]['results'][1]['status'])
assert_match(%r(Automated test returned as passed.\n Attestation:\n Status: passed\n Explanation: Non-expired Status passed\n), hdf_json['profiles'][0]['controls'][1]['results'][0]['message'])
assert_match(%r(Automated test returned as passed.\n Attestation:\n Status: passed\n Explanation: Non-expired Status passed\n), hdf_json['profiles'][0]['controls'][1]['results'][1]['message'])
assert_equal('passed', hdf_json['profiles'][0]['controls'][1]['results'][2]['status'])
refute_nil(hdf_json['profiles'][0]['controls'][1]['attestation'])
end

def test_with_a_single_fail_non_expired_attestation
hdf_json = JSON.parse(File.read('test_hdf.json'))
assert_equal('passed', hdf_json['profiles'][0]['controls'][2]['results'][0]['status'])
assert_match(%r(\nexpected false\n got true\n\n Attestation:\n Status: passed\n Explanation: Non-expired Status passed\n), hdf_json['profiles'][0]['controls'][2]['results'][0]['message'])
assert_equal('failed', hdf_json['profiles'][0]['controls'][2]['results'][0]['status'])
assert_equal('passed', hdf_json['profiles'][0]['controls'][2]['results'][1]['status'])
refute_nil(hdf_json['profiles'][0]['controls'][2]['attestation'])
end

def test_with_a_multiple_fail_non_expired_attestation
hdf_json = JSON.parse(File.read('test_hdf.json'))
assert_equal('passed', hdf_json['profiles'][0]['controls'][3]['results'][0]['status'])
assert_equal('passed', hdf_json['profiles'][0]['controls'][3]['results'][1]['status'])
assert_match(%r(\nexpected false\n got true\n\n Attestation:\n Status: passed\n Explanation: Non-expired Status passed\n), hdf_json['profiles'][0]['controls'][3]['results'][0]['message'])
assert_match(%r(\nexpected true\n got false\n\n Attestation:\n Status: passed\n Explanation: Non-expired Status passed\n), hdf_json['profiles'][0]['controls'][3]['results'][1]['message'])
assert_equal('failed', hdf_json['profiles'][0]['controls'][3]['results'][0]['status'])
assert_equal('failed', hdf_json['profiles'][0]['controls'][3]['results'][1]['status'])
assert_equal('passed', hdf_json['profiles'][0]['controls'][3]['results'][2]['status'])
refute_nil(hdf_json['profiles'][0]['controls'][3]['attestation'])
end

def test_with_a_single_skip_non_expired_attestation
hdf_json = JSON.parse(File.read('test_hdf.json'))
assert_equal('passed', hdf_json['profiles'][0]['controls'][4]['results'][0]['status'])
assert_match(%r(Manual Test\n Attestation:\n Status: passed\n Explanation: Non-expired Status passed\n), hdf_json['profiles'][0]['controls'][4]['results'][0]['message'])
assert_equal('skipped', hdf_json['profiles'][0]['controls'][4]['results'][0]['status'])
assert_equal('passed', hdf_json['profiles'][0]['controls'][4]['results'][1]['status'])
refute_nil(hdf_json['profiles'][0]['controls'][4]['attestation'])
end
def test_with_a_multiple_skip_non_expired_attestation
hdf_json = JSON.parse(File.read('test_hdf.json'))
assert_equal('passed', hdf_json['profiles'][0]['controls'][5]['results'][0]['status'])
assert_equal('passed', hdf_json['profiles'][0]['controls'][5]['results'][1]['status'])
assert_match(%r(Manual Test2\n Attestation:\n Status: passed\n Explanation: Non-expired Status passed\n), hdf_json['profiles'][0]['controls'][5]['results'][0]['message'])
assert_match(%r(Manual Test2\n Attestation:\n Status: passed\n Explanation: Non-expired Status passed\n), hdf_json['profiles'][0]['controls'][5]['results'][1]['message'])
assert_equal('skipped', hdf_json['profiles'][0]['controls'][5]['results'][0]['status'])
assert_equal('skipped', hdf_json['profiles'][0]['controls'][5]['results'][1]['status'])
assert_equal('passed', hdf_json['profiles'][0]['controls'][5]['results'][2]['status'])
refute_nil(hdf_json['profiles'][0]['controls'][5]['attestation'])
end
def test_with_a_mixed_statuses_non_expired_attestation
hdf_json = JSON.parse(File.read('test_hdf.json'))
assert_equal('passed', hdf_json['profiles'][0]['controls'][6]['results'][0]['status'])
assert_equal('skipped', hdf_json['profiles'][0]['controls'][6]['results'][0]['status'])
assert_equal('passed', hdf_json['profiles'][0]['controls'][6]['results'][1]['status'])
assert_equal('passed', hdf_json['profiles'][0]['controls'][6]['results'][2]['status'])
assert_match(%r(Manual Test\n Attestation:\n Status: passed\n Explanation: Non-expired Status passed\n), hdf_json['profiles'][0]['controls'][6]['results'][0]['message'])
assert_match(%r(Automated test returned as passed.\n Attestation:\n Status: passed\n Explanation: Non-expired Status passed\n), hdf_json['profiles'][0]['controls'][6]['results'][1]['message'])
assert_match(%r(\nexpected false\n got true\n\n Attestation:\n Status: passed\n Explanation: Non-expired Status passed\n), hdf_json['profiles'][0]['controls'][6]['results'][2]['message'])
assert_equal('failed', hdf_json['profiles'][0]['controls'][6]['results'][2]['status'])
assert_equal('passed', hdf_json['profiles'][0]['controls'][6]['results'][3]['status'])
refute_nil(hdf_json['profiles'][0]['controls'][6]['attestation'])
end
def test_with_a_no_statuses_non_expired_attestation
hdf_json = JSON.parse(File.read('test_hdf.json'))
assert_equal('passed', hdf_json['profiles'][0]['controls'][7]['results'][0]['status'])
assert_match(%r(\n Attestation:\n Status: passed\n Explanation: Non-expired Status passed\n), hdf_json['profiles'][0]['controls'][7]['results'][0]['message'])
refute_nil(hdf_json['profiles'][0]['controls'][7]['attestation'])
end
def test_with_a_single_pass_expired_attestation
hdf_json = JSON.parse(File.read('test_hdf.json'))
assert_equal('passed', hdf_json['profiles'][0]['controls'][8]['results'][0]['status'])
assert_nil(hdf_json['profiles'][0]['controls'][8]['results'][1])
refute_nil(hdf_json['profiles'][0]['controls'][8]['attestation'])
end
def test_with_a_multiple_pass_expired_attestation
hdf_json = JSON.parse(File.read('test_hdf.json'))
assert_equal('passed', hdf_json['profiles'][0]['controls'][9]['results'][0]['status'])
assert_equal('passed', hdf_json['profiles'][0]['controls'][9]['results'][1]['status'])
assert_nil(hdf_json['profiles'][0]['controls'][9]['results'][2])
refute_nil(hdf_json['profiles'][0]['controls'][9]['attestation'])
end
def test_with_a_single_fail_expired_attestation
hdf_json = JSON.parse(File.read('test_hdf.json'))
assert_equal('failed', hdf_json['profiles'][0]['controls'][10]['results'][0]['status'])
assert_nil(hdf_json['profiles'][0]['controls'][10]['results'][1])
refute_nil(hdf_json['profiles'][0]['controls'][10]['attestation'])
end
def test_with_a_multiple_fail_expired_attestation
hdf_json = JSON.parse(File.read('test_hdf.json'))
assert_equal('failed', hdf_json['profiles'][0]['controls'][11]['results'][0]['status'])
assert_equal('failed', hdf_json['profiles'][0]['controls'][11]['results'][1]['status'])
assert_nil(hdf_json['profiles'][0]['controls'][11]['results'][2])
refute_nil(hdf_json['profiles'][0]['controls'][11]['attestation'])
end
def test_with_a_single_skip_expired_attestation
hdf_json = JSON.parse(File.read('test_hdf.json'))
assert_equal('skipped', hdf_json['profiles'][0]['controls'][12]['results'][0]['status'])
assert_nil(hdf_json['profiles'][0]['controls'][12]['results'][1])
refute_nil(hdf_json['profiles'][0]['controls'][12]['attestation'])
end
def test_with_a_multiple_skip_expired_attestation
hdf_json = JSON.parse(File.read('test_hdf.json'))
assert_equal('skipped', hdf_json['profiles'][0]['controls'][13]['results'][0]['status'])
assert_equal('skipped', hdf_json['profiles'][0]['controls'][13]['results'][1]['status'])
assert_nil(hdf_json['profiles'][0]['controls'][13]['results'][2])
refute_nil(hdf_json['profiles'][0]['controls'][12]['attestation'])
end
def test_with_a_mixed_statuses_expired_attestation
hdf_json = JSON.parse(File.read('test_hdf.json'))
assert_equal('skipped', hdf_json['profiles'][0]['controls'][14]['results'][0]['status'])
assert_equal('passed', hdf_json['profiles'][0]['controls'][14]['results'][1]['status'])
assert_equal('failed', hdf_json['profiles'][0]['controls'][14]['results'][2]['status'])
assert_nil(hdf_json['profiles'][0]['controls'][14]['results'][3])
refute_nil(hdf_json['profiles'][0]['controls'][14]['attestation'])
end
def test_with_a_no_statuses_expired_attestation
Expand Down

0 comments on commit 616cf32

Please sign in to comment.