From 616cf320499fa6d76bfc0d377b14c8deb71eeccf Mon Sep 17 00:00:00 2001 From: Rony Xavier Date: Fri, 9 Apr 2021 07:12:37 -0400 Subject: [PATCH] Update func test to match updates Signed-off-by: Rony Xavier --- .../inspec_plugin_functional_test.rb | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/test/functional/inspec_plugin_functional_test.rb b/test/functional/inspec_plugin_functional_test.rb index af6fff3..8acb550 100644 --- a/test/functional/inspec_plugin_functional_test.rb +++ b/test/functional/inspec_plugin_functional_test.rb @@ -4,97 +4,103 @@ 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 @@ -102,6 +108,7 @@ def test_with_a_mixed_statuses_expired_attestation 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