|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | 3 | require 'test_helper' |
| 4 | +require 'openscap_parser/rule_reference' |
4 | 5 |
|
5 | 6 | class OpenscapParserTest < Minitest::Test |
6 | 7 | def setup |
7 | 8 | fake_report = file_fixture('xccdf_report.xml').read |
8 | | - @profile = { |
9 | | - 'xccdf_org.ssgproject.content_profile_standard' => |
10 | | - 'Standard System Security Profile for Fedora' |
11 | | - } |
| 9 | + @profile_ref_id = 'xccdf_org.ssgproject.content_profile_standard' |
12 | 10 | @report_parser = ::OpenscapParser::Base.new(fake_report) |
13 | 11 | end |
14 | 12 |
|
15 | 13 | context 'profile' do |
16 | 14 | should 'be able to parse it' do |
17 | | - assert_equal(@profile, @report_parser.profiles) |
| 15 | + assert_equal(@profile_ref_id, @report_parser.profiles.first.id) |
18 | 16 | end |
19 | 17 |
|
20 | 18 | should 'not save more than one profile when there are no test results' do |
21 | 19 | fake_report = file_fixture('rhel-xccdf-report.xml').read |
22 | | - @profile = { |
23 | | - 'xccdf_org.ssgproject.content_profile_rht-ccp' => |
24 | | - 'Red Hat Corporate Profile for Certified Cloud Providers (RH CCP)' |
25 | | - } |
| 20 | + @profile_ref_id = 'xccdf_org.ssgproject.content_profile_rht-ccp' |
26 | 21 | @report_parser = ::OpenscapParser::Base.new(fake_report) |
27 | 22 | assert_equal 1, @report_parser.test_result_profiles.count |
28 | 23 | end |
@@ -55,19 +50,17 @@ def setup |
55 | 50 | end |
56 | 51 |
|
57 | 52 | should 'parse rule references' do |
58 | | - rule = @report_parser.rule_objects.find do |r| |
59 | | - r.title == 'Disable At Service (atd)' |
| 53 | + rule = @report_parser.rules.find do |r| |
| 54 | + r.id == 'xccdf_org.ssgproject.content_rule_service_atd_disabled' |
60 | 55 | end |
61 | 56 |
|
62 | 57 | references = [ |
63 | | - {:href=>"http://iase.disa.mil/stigs/cci/Pages/index.aspx", |
64 | | - :label=>"CCI-000381"}, |
65 | | - {:href=>'http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.'\ |
66 | | - '800-53r4.pdf', |
67 | | - :label=>"CM-7"} |
| 58 | + ["http://iase.disa.mil/stigs/cci/Pages/index.aspx", "CCI-000381"], |
| 59 | + ['http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.'\ |
| 60 | + '800-53r4.pdf', "CM-7"] |
68 | 61 | ] |
69 | 62 |
|
70 | | - assert_equal references, rule.references |
| 63 | + assert_equal references, rule.references.map { |rr| [rr.href, rr.label] } |
71 | 64 | end |
72 | 65 |
|
73 | 66 | should 'parse rule description without newlines' do |
|
0 commit comments