foreman_openscap 0.6.4 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,21 +1,40 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
3
  class ArfReportsControllerTest < ActionController::TestCase
4
-
5
- test "should delete selected reports" do
6
- host = FactoryGirl.create(:compliance_host)
4
+ setup do
7
5
  ForemanOpenscap::Helper.stubs(:find_name_or_uuid_by_host)
8
6
  ::ProxyAPI::Openscap.any_instance.stubs(:destroy_report).returns(true)
9
- ForemanOpenscap::ArfReport.any_instance.stubs(:openscap_proxy).returns(host.openscap_proxy)
7
+ @host = FactoryGirl.create(:compliance_host)
8
+ end
9
+
10
+ test "should delete arf report" do
11
+ ForemanOpenscap::ArfReport.any_instance.stubs(:openscap_proxy).returns(@host.openscap_proxy)
12
+ arf_report = FactoryGirl.create(:arf_report, :host_id => @host.id)
13
+ assert_difference("ForemanOpenscap::ArfReport.count", -1) do
14
+ delete :destroy, { :id => arf_report.id }, set_session_user
15
+ end
16
+ assert_redirected_to arf_reports_path
17
+ end
18
+
19
+ test "should delete multiple reports" do
20
+ ForemanOpenscap::ArfReport.any_instance.stubs(:openscap_proxy).returns(@host.openscap_proxy)
10
21
  arf_reports = []
11
22
  3.times do
12
- arf_reports << FactoryGirl.create(:arf_report, :host_id => host.id)
23
+ arf_reports << FactoryGirl.create(:arf_report, :host_id => @host.id)
13
24
  end
14
25
  last_arf = arf_reports[-1]
15
- assert_difference("ForemanOpenscap::ArfReport.count", -2) do
26
+ assert_difference("ForemanOpenscap::ArfReport.unscoped.count", -2) do
16
27
  post :submit_delete_multiple, { :arf_report_ids => arf_reports[0..-2].map(&:id) }, set_session_user
17
28
  end
18
29
  assert_redirected_to arf_reports_path
19
- assert_equal last_arf, ForemanOpenscap::ArfReport.first
30
+ assert_equal last_arf, ForemanOpenscap::ArfReport.unscoped.first
31
+ end
32
+
33
+ test "should download arf report as html" do
34
+ arf_report = FactoryGirl.create(:arf_report, :host_id => @host.id)
35
+ report_html = File.read("#{ForemanOpenscap::Engine.root}/test/files/arf_report/arf_report.html")
36
+ ForemanOpenscap::ArfReport.any_instance.stubs(:to_html).returns(report_html)
37
+ get :download_html, { :id => arf_report.id }, set_session_user
38
+ assert_equal report_html, @response.body
20
39
  end
21
40
  end
@@ -0,0 +1,25 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class HostExtensionsTest < ActiveSupport::TestCase
4
+ setup do
5
+ ForemanOpenscap::Policy.any_instance.stubs(:ensure_needed_puppetclasses).returns(true)
6
+ @scap_content = FactoryGirl.create(:scap_content)
7
+ @scap_content_profile = FactoryGirl.create(:scap_content_profile, :scap_content => @scap_content)
8
+ @policy = FactoryGirl.create(:policy, :scap_content => @scap_content, :scap_content_profile => @scap_content_profile)
9
+ @host = FactoryGirl.create(:compliance_host, :policies => [@policy])
10
+ end
11
+
12
+ test "should have download_path in enc without digest" do
13
+ ForemanOpenscap::OpenscapProxyAssignedVersionCheck.any_instance.stubs(:openscap_proxy_versions).
14
+ returns('test-proxy' => '0.5.4')
15
+ enc_out = JSON.parse @host.policies_enc
16
+ assert_equal 5, enc_out.first['download_path'].split('/').length
17
+ end
18
+
19
+ test "should have download_path in enc with digest" do
20
+ ForemanOpenscap::OpenscapProxyAssignedVersionCheck.any_instance.stubs(:openscap_proxy_versions).
21
+ returns({})
22
+ enc_out = JSON.parse @host.policies_enc
23
+ assert_equal 6, enc_out.first['download_path'].split('/').length
24
+ end
25
+ end
@@ -7,6 +7,7 @@ class PolicyTest < ActiveSupport::TestCase
7
7
  ForemanOpenscap::ScapContent.any_instance.stubs(:fetch_profiles).returns({ 'test_profile_key' => 'test_profile_title' })
8
8
  @scap_content = FactoryGirl.create(:scap_content)
9
9
  @scap_profile = FactoryGirl.create(:scap_content_profile)
10
+ @tailoring_profile = FactoryGirl.create(:scap_content_profile, :profile_id => 'xccdf_org.test.tailoring_test_profile')
10
11
  end
11
12
 
12
13
  test "should assign hostgroups by their ids" do
@@ -166,4 +167,27 @@ class PolicyTest < ActiveSupport::TestCase
166
167
  p.tailoring_file_profile = tailoring_profile
167
168
  assert p.save
168
169
  end
170
+
171
+ test "should have digest in enc download path for scap content" do
172
+ p = ForemanOpenscap::Policy.new(:name => "custom_policy",
173
+ :scap_content_id => @scap_content.id,
174
+ :scap_content_profile_id => @scap_profile.id,
175
+ :period => 'monthly',
176
+ :day_of_month => '5')
177
+ assert_equal 6, p.to_enc['download_path'].split('/').length
178
+ assert_equal @scap_content.digest, p.to_enc['download_path'].split('/').last
179
+ end
180
+
181
+ test "should have digest in enc download path for tailoring file" do
182
+ tailoring_file = FactoryGirl.create(:tailoring_file)
183
+ p = ForemanOpenscap::Policy.new(:name => "custom_policy",
184
+ :scap_content_id => @scap_content.id,
185
+ :scap_content_profile_id => @scap_profile.id,
186
+ :tailoring_file => tailoring_file,
187
+ :tailoring_file_profile => @tailoring_profile,
188
+ :period => 'monthly',
189
+ :day_of_month => '5')
190
+ assert_equal 6, p.to_enc['tailoring_download_path'].split('/').length
191
+ assert_equal tailoring_file.digest, p.to_enc['tailoring_download_path'].split('/').last
192
+ end
169
193
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_openscap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Šimon Lukašík"
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-02-21 00:00:00.000000000 Z
14
+ date: 2017-03-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: deface
@@ -56,6 +56,7 @@ files:
56
56
  - app/controllers/concerns/foreman/controller/parameters/policy_api.rb
57
57
  - app/controllers/concerns/foreman/controller/parameters/scap_content.rb
58
58
  - app/controllers/concerns/foreman/controller/parameters/tailoring_file.rb
59
+ - app/controllers/concerns/foreman_openscap/arf_reports_controller_common_extensions.rb
59
60
  - app/controllers/concerns/foreman_openscap/hostgroups_controller_extensions.rb
60
61
  - app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb
61
62
  - app/controllers/openscap_proxies_controller.rb
@@ -99,6 +100,7 @@ files:
99
100
  - app/overrides/hosts/overview/host_compliance_status.rb
100
101
  - app/services/foreman_openscap/arf_report_status_calculator.rb
101
102
  - app/services/foreman_openscap/host_report_dashboard/data.rb
103
+ - app/services/foreman_openscap/openscap_proxy_assigned_version_check.rb
102
104
  - app/services/foreman_openscap/openscap_proxy_version_check.rb
103
105
  - app/services/foreman_openscap/policy_dashboard/data.rb
104
106
  - app/services/foreman_openscap/report_dashboard/data.rb
@@ -140,6 +142,7 @@ files:
140
142
  - app/views/foreman_openscap/policy_mailer/_list.erb
141
143
  - app/views/foreman_openscap/policy_mailer/_policy.erb
142
144
  - app/views/foreman_openscap/policy_mailer/policy_summary.erb
145
+ - app/views/job_templates/run_openscap_scans.erb
143
146
  - app/views/policies/_form.html.erb
144
147
  - app/views/policies/_list.html.erb
145
148
  - app/views/policies/_scap_content_results.html.erb
@@ -217,6 +220,7 @@ files:
217
220
  - db/migrate/20160925213031_change_scap_widget_names.rb
218
221
  - db/migrate/20161109155255_create_tailoring_files.rb
219
222
  - db/migrate/20161223153249_add_permissions_to_arf_report.rb
223
+ - db/seeds.d/75-job_templates.rb
220
224
  - db/seeds.d/openscap_feature.rb
221
225
  - db/seeds.d/openscap_policy_notification.rb
222
226
  - lib/foreman_openscap.rb
@@ -263,6 +267,7 @@ files:
263
267
  - test/factories/policy_factory.rb
264
268
  - test/factories/scap_content_related.rb
265
269
  - test/files/arf_report/arf_report.bz2
270
+ - test/files/arf_report/arf_report.html
266
271
  - test/files/scap_contents/ssg-fedora-ds.xml
267
272
  - test/files/tailoring_files/ssg-firefox-ds-tailoring-2.xml
268
273
  - test/files/tailoring_files/ssg-firefox-ds-tailoring.xml
@@ -278,6 +283,7 @@ files:
278
283
  - test/unit/arf_report_status_calculator_test.rb
279
284
  - test/unit/arf_report_test.rb
280
285
  - test/unit/compliance_status_test.rb
286
+ - test/unit/concerns/host_extensions_test.rb
281
287
  - test/unit/concerns/openscap_proxy_extenstions_test.rb
282
288
  - test/unit/openscap_host_test.rb
283
289
  - test/unit/policy_mailer_test.rb
@@ -314,6 +320,7 @@ test_files:
314
320
  - test/lib/foreman_openscap/bulk_upload_test.rb
315
321
  - test/unit/scap_content_test.rb
316
322
  - test/unit/concerns/openscap_proxy_extenstions_test.rb
323
+ - test/unit/concerns/host_extensions_test.rb
317
324
  - test/unit/openscap_host_test.rb
318
325
  - test/unit/tailoring_file_test.rb
319
326
  - test/unit/policy_test.rb
@@ -342,3 +349,4 @@ test_files:
342
349
  - test/files/tailoring_files/ssg-firefox-ds-tailoring-2.xml
343
350
  - test/files/tailoring_files/ssg-firefox-ds-tailoring.xml
344
351
  - test/files/arf_report/arf_report.bz2
352
+ - test/files/arf_report/arf_report.html