foreman_openscap 0.10.3 → 0.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/api/v2/compliance/arf_reports_controller.rb +2 -2
- data/app/controllers/api/v2/compliance/policies_controller.rb +2 -2
- data/app/controllers/api/v2/compliance/scap_contents_controller.rb +2 -2
- data/app/controllers/api/v2/compliance/tailoring_files_controller.rb +2 -2
- data/app/models/concerns/foreman_openscap/host_extensions.rb +1 -1
- data/lib/foreman_openscap/version.rb +1 -1
- data/test/factories/arf_report_factory.rb +0 -1
- data/test/unit/arf_report_test.rb +35 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b441309459cd62b0c525d1b51dd856b28bf3b2e
|
4
|
+
data.tar.gz: 2b98addfa0d16368c3f9d9be4af017047ba56036
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddae8417386fa6877ce9b2873b94f1750dde15217cf29cc2fbb3d2e5e2ae7f07ee4905da0702a45c00d26b6ad8c20c5b0aa43d89b11becf04344feabba1d7af5
|
7
|
+
data.tar.gz: 6b843df78415ac1c53ee199e06abba468f0d3e0c121c890b0565aec35c38a788d9fde4092fcdd59a4410b97eb6f8c3039b2cc8228787e34866f7d5829e95b630
|
@@ -14,8 +14,8 @@ module Api
|
|
14
14
|
before_action :find_resources_before_create, :only => %w[create]
|
15
15
|
skip_after_action :log_response_body, :only => %w[download download_html]
|
16
16
|
|
17
|
-
def resource_name
|
18
|
-
|
17
|
+
def resource_name(resource = '::ForemanOpenscap::ArfReport')
|
18
|
+
super resource
|
19
19
|
end
|
20
20
|
|
21
21
|
def get_resource(message = 'no resource loaded')
|
@@ -10,8 +10,8 @@ module Api::V2
|
|
10
10
|
|
11
11
|
skip_after_action :log_response_body, :only => [:content]
|
12
12
|
|
13
|
-
def resource_name
|
14
|
-
|
13
|
+
def resource_name(resource = '::ForemanOpenscap::Policy')
|
14
|
+
super resource
|
15
15
|
end
|
16
16
|
|
17
17
|
def get_resource(message = 'no resource loaded')
|
@@ -4,8 +4,8 @@ module Api::V2
|
|
4
4
|
include Foreman::Controller::Parameters::ScapContent
|
5
5
|
before_action :find_resource, :except => %w[index create]
|
6
6
|
|
7
|
-
def resource_name
|
8
|
-
|
7
|
+
def resource_name(resource = '::ForemanOpenscap::ScapContent')
|
8
|
+
super resource
|
9
9
|
end
|
10
10
|
|
11
11
|
def get_resource(message = 'no resource loaded')
|
@@ -5,8 +5,8 @@ module Api::V2
|
|
5
5
|
before_action :find_resource, :except => %w[index create]
|
6
6
|
before_action :openscap_proxy_check, :only => %w[create]
|
7
7
|
|
8
|
-
def resource_name
|
9
|
-
|
8
|
+
def resource_name(resource = '::ForemanOpenscap::TailoringFile')
|
9
|
+
super resource
|
10
10
|
end
|
11
11
|
|
12
12
|
def get_resource(message = 'no resource loaded')
|
@@ -11,50 +11,57 @@ module ForemanOpenscap
|
|
11
11
|
@host = FactoryBot.create(:compliance_host)
|
12
12
|
@failed_source = FactoryBot.create(:source)
|
13
13
|
@passed_source = FactoryBot.create(:source)
|
14
|
-
|
15
|
-
@
|
16
|
-
@
|
14
|
+
|
15
|
+
@passed_log_params = { :result => "pass", :source => @passed_source }
|
16
|
+
@failed_log_params = { :result => "fail", :source => @failed_source }
|
17
17
|
@status = { :passed => 5, :failed => 1, :othered => 7 }.with_indifferent_access
|
18
18
|
end
|
19
19
|
|
20
20
|
test 'equal? should return true when there is no change in report results' do
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
report_1 = FactoryBot.create(:arf_report, :policy => @policy, :host_id => @host.id)
|
22
|
+
report_2 = FactoryBot.create(:arf_report, :policy => @policy, :host_id => @host.id)
|
23
|
+
create_logs_for_report(report_1, [@passed_log_params, @failed_log_params])
|
24
|
+
create_logs_for_report(report_2, [@passed_log_params, @failed_log_params])
|
24
25
|
|
25
26
|
assert(report_1.equal?(report_2))
|
26
27
|
end
|
27
28
|
|
28
29
|
test 'equal? should return false when there is change in report results' do
|
29
30
|
new_source = FactoryBot.create(:source)
|
30
|
-
|
31
|
-
report_1 = FactoryBot.create(:arf_report, :policy => @policy, :host_id => @host.id
|
32
|
-
report_2 = FactoryBot.create(:arf_report, :policy => @policy, :host_id => @host.id
|
31
|
+
|
32
|
+
report_1 = FactoryBot.create(:arf_report, :policy => @policy, :host_id => @host.id)
|
33
|
+
report_2 = FactoryBot.create(:arf_report, :policy => @policy, :host_id => @host.id)
|
34
|
+
create_logs_for_report(report_1, [@passed_log_params, @failed_log_params])
|
35
|
+
create_logs_for_report(report_2, [@passed_log_params, @passed_log_params])
|
33
36
|
|
34
37
|
refute(report_1.equal?(report_2))
|
35
38
|
end
|
36
39
|
|
37
40
|
test 'equal? should return false when reports have different sets of rules' do
|
38
|
-
report_1 = FactoryBot.create(:arf_report, :policy => @policy, :host_id => @host.id
|
39
|
-
report_2 = FactoryBot.create(:arf_report, :policy => @policy, :host_id => @host.id
|
41
|
+
report_1 = FactoryBot.create(:arf_report, :policy => @policy, :host_id => @host.id)
|
42
|
+
report_2 = FactoryBot.create(:arf_report, :policy => @policy, :host_id => @host.id)
|
43
|
+
create_logs_for_report(report_1, [@passed_log_params, @failed_log_params])
|
44
|
+
create_logs_for_report(report_2, [@passed_log_params])
|
40
45
|
|
41
46
|
refute(report_1.equal?(report_2))
|
42
47
|
end
|
43
48
|
|
44
49
|
test 'equal? should return false when reports have different hosts' do
|
45
50
|
host = FactoryBot.create(:compliance_host)
|
46
|
-
|
47
|
-
|
48
|
-
|
51
|
+
report_1 = FactoryBot.create(:arf_report, :policy => @policy, :host_id => @host.id)
|
52
|
+
report_2 = FactoryBot.create(:arf_report, :policy => @policy, :host_id => host.id)
|
53
|
+
create_logs_for_report(report_1, [@passed_log_params, @failed_log_params])
|
54
|
+
create_logs_for_report(report_2, [@passed_log_params, @failed_log_params])
|
49
55
|
|
50
56
|
refute(report_1.equal?(report_2))
|
51
57
|
end
|
52
58
|
|
53
59
|
test 'equal? should return false when reports have different policies' do
|
54
60
|
policy = FactoryBot.create(:policy)
|
55
|
-
|
56
|
-
|
57
|
-
|
61
|
+
report_1 = FactoryBot.create(:arf_report, :policy => @policy, :host_id => @host.id)
|
62
|
+
report_2 = FactoryBot.create(:arf_report, :policy => policy, :host_id => @host.id)
|
63
|
+
create_logs_for_report(report_1, [@passed_log_params, @failed_log_params])
|
64
|
+
create_logs_for_report(report_2, [@passed_log_params, @failed_log_params])
|
58
65
|
|
59
66
|
refute(report_1.equal?(report_2))
|
60
67
|
end
|
@@ -151,9 +158,19 @@ module ForemanOpenscap
|
|
151
158
|
openscap_proxy_api.stubs(:destroy_report).returns(true)
|
152
159
|
ForemanOpenscap::Helper.stubs(:find_name_or_uuid_by_host).returns("abcde")
|
153
160
|
ForemanOpenscap::ArfReport.any_instance.stubs(:openscap_proxy_api).returns(openscap_proxy_api)
|
154
|
-
report = FactoryBot.create(:arf_report, :policy => @policy, :host_id => @host.id
|
161
|
+
report = FactoryBot.create(:arf_report, :policy => @policy, :host_id => @host.id)
|
162
|
+
create_logs_for_report(report, [@passed_log_params, @failed_log_params])
|
163
|
+
|
155
164
|
report.destroy
|
156
165
|
refute ForemanOpenscap::ArfReport.all.include? report
|
157
166
|
end
|
167
|
+
|
168
|
+
private
|
169
|
+
|
170
|
+
def create_logs_for_report(report, log_params)
|
171
|
+
log_params.each do |param_group|
|
172
|
+
FactoryBot.create(:compliance_log, param_group.merge(:report_id => report.id))
|
173
|
+
end
|
174
|
+
end
|
158
175
|
end
|
159
176
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_openscap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- slukasik@redhat.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|