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

Commit 616cf32

Browse files
author
Rony Xavier
committed
Update func test to match updates
Signed-off-by: Rony Xavier <rxavier@mitre.org>
1 parent 8b3a013 commit 616cf32

File tree

1 file changed

+29
-22
lines changed

1 file changed

+29
-22
lines changed

test/functional/inspec_plugin_functional_test.rb

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,104 +4,111 @@ class InspecPluginFunctionalTest < Minitest::Test
44
def test_with_a_single_pass_non_expired_attestation
55
hdf_json = JSON.parse(File.read('test_hdf.json'))
66
assert_equal('passed', hdf_json['profiles'][0]['controls'][0]['results'][0]['status'])
7-
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'])
7+
assert_equal('passed', hdf_json['profiles'][0]['controls'][0]['results'][1]['status'])
8+
9+
message = hdf_json['profiles'][0]['controls'][0]['results'][1]['message']
10+
assert_match(%r(Attestation:), message)
11+
assert_match(%r(Status: passed), message)
12+
assert_match(%r(Explanation: Non-expired Status passed), message)
13+
assert_match(%r(Updated By: John Doe, ISSO), message)
14+
assert_match(%r(Frequency: annually), message)
815
refute_nil(hdf_json['profiles'][0]['controls'][0]['attestation'])
916
end
1017

11-
1218
def test_with_a_multiple_pass_non_expired_attestation
1319
hdf_json = JSON.parse(File.read('test_hdf.json'))
1420
assert_equal('passed', hdf_json['profiles'][0]['controls'][1]['results'][0]['status'])
1521
assert_equal('passed', hdf_json['profiles'][0]['controls'][1]['results'][1]['status'])
16-
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'])
17-
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'])
22+
assert_equal('passed', hdf_json['profiles'][0]['controls'][1]['results'][2]['status'])
1823
refute_nil(hdf_json['profiles'][0]['controls'][1]['attestation'])
1924
end
2025

2126
def test_with_a_single_fail_non_expired_attestation
2227
hdf_json = JSON.parse(File.read('test_hdf.json'))
23-
assert_equal('passed', hdf_json['profiles'][0]['controls'][2]['results'][0]['status'])
24-
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'])
28+
assert_equal('failed', hdf_json['profiles'][0]['controls'][2]['results'][0]['status'])
29+
assert_equal('passed', hdf_json['profiles'][0]['controls'][2]['results'][1]['status'])
2530
refute_nil(hdf_json['profiles'][0]['controls'][2]['attestation'])
2631
end
2732

2833
def test_with_a_multiple_fail_non_expired_attestation
2934
hdf_json = JSON.parse(File.read('test_hdf.json'))
30-
assert_equal('passed', hdf_json['profiles'][0]['controls'][3]['results'][0]['status'])
31-
assert_equal('passed', hdf_json['profiles'][0]['controls'][3]['results'][1]['status'])
32-
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'])
33-
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'])
35+
assert_equal('failed', hdf_json['profiles'][0]['controls'][3]['results'][0]['status'])
36+
assert_equal('failed', hdf_json['profiles'][0]['controls'][3]['results'][1]['status'])
37+
assert_equal('passed', hdf_json['profiles'][0]['controls'][3]['results'][2]['status'])
3438
refute_nil(hdf_json['profiles'][0]['controls'][3]['attestation'])
3539
end
3640

3741
def test_with_a_single_skip_non_expired_attestation
3842
hdf_json = JSON.parse(File.read('test_hdf.json'))
39-
assert_equal('passed', hdf_json['profiles'][0]['controls'][4]['results'][0]['status'])
40-
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'])
43+
assert_equal('skipped', hdf_json['profiles'][0]['controls'][4]['results'][0]['status'])
44+
assert_equal('passed', hdf_json['profiles'][0]['controls'][4]['results'][1]['status'])
4145
refute_nil(hdf_json['profiles'][0]['controls'][4]['attestation'])
4246
end
4347
def test_with_a_multiple_skip_non_expired_attestation
4448
hdf_json = JSON.parse(File.read('test_hdf.json'))
45-
assert_equal('passed', hdf_json['profiles'][0]['controls'][5]['results'][0]['status'])
46-
assert_equal('passed', hdf_json['profiles'][0]['controls'][5]['results'][1]['status'])
47-
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'])
48-
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'])
49+
assert_equal('skipped', hdf_json['profiles'][0]['controls'][5]['results'][0]['status'])
50+
assert_equal('skipped', hdf_json['profiles'][0]['controls'][5]['results'][1]['status'])
51+
assert_equal('passed', hdf_json['profiles'][0]['controls'][5]['results'][2]['status'])
4952
refute_nil(hdf_json['profiles'][0]['controls'][5]['attestation'])
5053
end
5154
def test_with_a_mixed_statuses_non_expired_attestation
5255
hdf_json = JSON.parse(File.read('test_hdf.json'))
53-
assert_equal('passed', hdf_json['profiles'][0]['controls'][6]['results'][0]['status'])
56+
assert_equal('skipped', hdf_json['profiles'][0]['controls'][6]['results'][0]['status'])
5457
assert_equal('passed', hdf_json['profiles'][0]['controls'][6]['results'][1]['status'])
55-
assert_equal('passed', hdf_json['profiles'][0]['controls'][6]['results'][2]['status'])
56-
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'])
57-
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'])
58-
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'])
58+
assert_equal('failed', hdf_json['profiles'][0]['controls'][6]['results'][2]['status'])
59+
assert_equal('passed', hdf_json['profiles'][0]['controls'][6]['results'][3]['status'])
5960
refute_nil(hdf_json['profiles'][0]['controls'][6]['attestation'])
6061
end
6162
def test_with_a_no_statuses_non_expired_attestation
6263
hdf_json = JSON.parse(File.read('test_hdf.json'))
6364
assert_equal('passed', hdf_json['profiles'][0]['controls'][7]['results'][0]['status'])
64-
assert_match(%r(\n Attestation:\n Status: passed\n Explanation: Non-expired Status passed\n), hdf_json['profiles'][0]['controls'][7]['results'][0]['message'])
6565
refute_nil(hdf_json['profiles'][0]['controls'][7]['attestation'])
6666
end
6767
def test_with_a_single_pass_expired_attestation
6868
hdf_json = JSON.parse(File.read('test_hdf.json'))
6969
assert_equal('passed', hdf_json['profiles'][0]['controls'][8]['results'][0]['status'])
70+
assert_nil(hdf_json['profiles'][0]['controls'][8]['results'][1])
7071
refute_nil(hdf_json['profiles'][0]['controls'][8]['attestation'])
7172
end
7273
def test_with_a_multiple_pass_expired_attestation
7374
hdf_json = JSON.parse(File.read('test_hdf.json'))
7475
assert_equal('passed', hdf_json['profiles'][0]['controls'][9]['results'][0]['status'])
7576
assert_equal('passed', hdf_json['profiles'][0]['controls'][9]['results'][1]['status'])
77+
assert_nil(hdf_json['profiles'][0]['controls'][9]['results'][2])
7678
refute_nil(hdf_json['profiles'][0]['controls'][9]['attestation'])
7779
end
7880
def test_with_a_single_fail_expired_attestation
7981
hdf_json = JSON.parse(File.read('test_hdf.json'))
8082
assert_equal('failed', hdf_json['profiles'][0]['controls'][10]['results'][0]['status'])
83+
assert_nil(hdf_json['profiles'][0]['controls'][10]['results'][1])
8184
refute_nil(hdf_json['profiles'][0]['controls'][10]['attestation'])
8285
end
8386
def test_with_a_multiple_fail_expired_attestation
8487
hdf_json = JSON.parse(File.read('test_hdf.json'))
8588
assert_equal('failed', hdf_json['profiles'][0]['controls'][11]['results'][0]['status'])
8689
assert_equal('failed', hdf_json['profiles'][0]['controls'][11]['results'][1]['status'])
90+
assert_nil(hdf_json['profiles'][0]['controls'][11]['results'][2])
8791
refute_nil(hdf_json['profiles'][0]['controls'][11]['attestation'])
8892
end
8993
def test_with_a_single_skip_expired_attestation
9094
hdf_json = JSON.parse(File.read('test_hdf.json'))
9195
assert_equal('skipped', hdf_json['profiles'][0]['controls'][12]['results'][0]['status'])
96+
assert_nil(hdf_json['profiles'][0]['controls'][12]['results'][1])
9297
refute_nil(hdf_json['profiles'][0]['controls'][12]['attestation'])
9398
end
9499
def test_with_a_multiple_skip_expired_attestation
95100
hdf_json = JSON.parse(File.read('test_hdf.json'))
96101
assert_equal('skipped', hdf_json['profiles'][0]['controls'][13]['results'][0]['status'])
97102
assert_equal('skipped', hdf_json['profiles'][0]['controls'][13]['results'][1]['status'])
103+
assert_nil(hdf_json['profiles'][0]['controls'][13]['results'][2])
98104
refute_nil(hdf_json['profiles'][0]['controls'][12]['attestation'])
99105
end
100106
def test_with_a_mixed_statuses_expired_attestation
101107
hdf_json = JSON.parse(File.read('test_hdf.json'))
102108
assert_equal('skipped', hdf_json['profiles'][0]['controls'][14]['results'][0]['status'])
103109
assert_equal('passed', hdf_json['profiles'][0]['controls'][14]['results'][1]['status'])
104110
assert_equal('failed', hdf_json['profiles'][0]['controls'][14]['results'][2]['status'])
111+
assert_nil(hdf_json['profiles'][0]['controls'][14]['results'][3])
105112
refute_nil(hdf_json['profiles'][0]['controls'][14]['attestation'])
106113
end
107114
def test_with_a_no_statuses_expired_attestation

0 commit comments

Comments
 (0)