foreman_openscap 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v2/compliance/arf_reports_controller.rb +15 -6
  3. data/app/controllers/api/v2/compliance/policies_controller.rb +4 -2
  4. data/app/controllers/api/v2/compliance/scap_contents_controller.rb +3 -2
  5. data/app/controllers/api/v2/compliance/tailoring_files_controller.rb +3 -2
  6. data/app/controllers/arf_reports_controller.rb +4 -4
  7. data/app/controllers/policies_controller.rb +6 -5
  8. data/app/controllers/scap_contents_controller.rb +3 -3
  9. data/app/helpers/arf_report_dashboard_helper.rb +1 -1
  10. data/app/helpers/arf_reports_helper.rb +8 -8
  11. data/app/helpers/compliance_dashboard_helper.rb +0 -2
  12. data/app/helpers/compliance_hosts_helper.rb +7 -8
  13. data/app/helpers/policies_helper.rb +18 -18
  14. data/app/helpers/policy_dashboard_helper.rb +3 -3
  15. data/app/lib/proxy_api/available_proxy.rb +2 -2
  16. data/app/lib/proxy_api/openscap.rb +1 -1
  17. data/app/mailers/foreman_openscap/policy_mailer.rb +0 -2
  18. data/app/models/concerns/foreman_openscap/compliance_status_scoped_search.rb +7 -7
  19. data/app/models/concerns/foreman_openscap/data_stream_content.rb +1 -1
  20. data/app/models/concerns/foreman_openscap/host_extensions.rb +16 -6
  21. data/app/models/concerns/foreman_openscap/openscap_proxy_extensions.rb +1 -1
  22. data/app/models/foreman_openscap/arf_report.rb +5 -5
  23. data/app/models/foreman_openscap/policy.rb +6 -6
  24. data/app/models/foreman_openscap/scap_content.rb +2 -2
  25. data/app/models/foreman_openscap/tailoring_file.rb +1 -1
  26. data/app/services/foreman_openscap/arf_report_status_calculator.rb +0 -1
  27. data/app/services/foreman_openscap/host_report_dashboard/data.rb +2 -3
  28. data/app/services/foreman_openscap/openscap_proxy_version_check.rb +0 -1
  29. data/app/services/foreman_openscap/policy_dashboard/data.rb +7 -6
  30. data/app/services/foreman_openscap/report_dashboard/data.rb +1 -0
  31. data/app/views/api/v2/compliance/common/_loc.json.rabl +1 -1
  32. data/app/views/api/v2/compliance/common/_org.json.rabl +1 -1
  33. data/app/views/api/v2/compliance/policies/base.json.rabl +1 -1
  34. data/app/views/arf_reports/_list.html.erb +1 -1
  35. data/app/views/arf_reports/delete_multiple.html.erb +1 -1
  36. data/app/views/arf_reports/welcome.html.erb +12 -0
  37. data/app/views/compliance_hosts/show.html.erb +3 -1
  38. data/app/views/policy_dashboard/_policy_reports.html.erb +1 -1
  39. data/app/views/scap_contents/_list.html.erb +1 -1
  40. data/app/views/smart_proxies/_openscap_spool.html.erb +1 -1
  41. data/app/views/tailoring_files/_list.html.erb +1 -1
  42. data/config/routes.rb +9 -11
  43. data/db/migrate/20141015115511_add_arf_report_unique_constraint.rb +1 -1
  44. data/db/migrate/20141113221054_create_scaptimony_scap_content_profiles.rb +2 -3
  45. data/db/migrate/20141206211151_create_scaptimony_assets_policies.rb +1 -1
  46. data/db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb +1 -1
  47. data/db/migrate/20150821100137_migrate_from_scaptimony.rb +1 -1
  48. data/db/migrate/20150929152345_move_arf_reports_to_reports_table.rb +0 -1
  49. data/db/migrate/20161223153249_add_permissions_to_arf_report.rb +2 -2
  50. data/db/migrate/20171016125613_add_content_title_unique_constraint.foreman_openscap.rb +6 -0
  51. data/lib/foreman_openscap/bulk_upload.rb +1 -1
  52. data/lib/foreman_openscap/engine.rb +54 -56
  53. data/lib/foreman_openscap/version.rb +1 -1
  54. data/lib/tasks/foreman_openscap_tasks.rake +11 -2
  55. data/locale/de/foreman_openscap.po +52 -13
  56. data/locale/en_GB/foreman_openscap.po +52 -13
  57. data/locale/es/foreman_openscap.po +52 -13
  58. data/locale/foreman_openscap.pot +140 -90
  59. data/locale/fr/foreman_openscap.po +52 -13
  60. data/locale/gl/foreman_openscap.po +52 -13
  61. data/locale/it/foreman_openscap.po +52 -13
  62. data/locale/ja/foreman_openscap.po +52 -13
  63. data/locale/ko/foreman_openscap.po +52 -13
  64. data/locale/pt_BR/foreman_openscap.po +52 -13
  65. data/locale/ru/foreman_openscap.po +52 -13
  66. data/locale/sv_SE/foreman_openscap.po +52 -13
  67. data/locale/zh_CN/foreman_openscap.po +52 -13
  68. data/locale/zh_TW/foreman_openscap.po +52 -13
  69. data/test/factories/arf_report_factory.rb +1 -1
  70. data/test/factories/asset_factory.rb +2 -2
  71. data/test/factories/compliance_host_factory.rb +2 -2
  72. data/test/factories/compliance_log_factory.rb +1 -1
  73. data/test/factories/policy_arf_report_factory.rb +1 -1
  74. data/test/factories/policy_factory.rb +3 -3
  75. data/test/factories/scap_content_related.rb +2 -2
  76. data/test/functional/api/v2/compliance/arf_reports_controller_test.rb +28 -9
  77. data/test/functional/api/v2/compliance/policies_controller_test.rb +16 -16
  78. data/test/functional/api/v2/compliance/scap_contents_controller_test.rb +8 -9
  79. data/test/functional/api/v2/compliance/tailoring_files_controller_test.rb +10 -11
  80. data/test/functional/arf_reports_controller_test.rb +4 -4
  81. data/test/functional/openscap_proxies_controller_test.rb +5 -3
  82. data/test/functional/tailoring_files_controller_test.rb +1 -1
  83. data/test/test_plugin_helper.rb +7 -7
  84. data/test/unit/arf_report_status_calculator_test.rb +0 -1
  85. data/test/unit/arf_report_test.rb +50 -50
  86. data/test/unit/compliance_status_test.rb +13 -13
  87. data/test/unit/concerns/host_extensions_test.rb +38 -22
  88. data/test/unit/concerns/openscap_proxy_extenstions_test.rb +5 -6
  89. data/test/unit/message_cleaner_test.rb +7 -7
  90. data/test/unit/openscap_host_test.rb +13 -13
  91. data/test/unit/policy_mailer_test.rb +12 -12
  92. data/test/unit/policy_test.rb +30 -30
  93. data/test/unit/scap_content_test.rb +4 -4
  94. data/test/unit/services/report_dashboard/data_test.rb +6 -6
  95. data/test/unit/services/tailoring_files_proxy_check_test.rb +1 -1
  96. metadata +4 -2
@@ -17,10 +17,13 @@ msgstr ""
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
18
  "\n"
19
19
 
20
- msgid "%s - The following compliance reports are about to be changed"
20
+ msgid " for policy %s"
21
21
  msgstr ""
22
22
 
23
- msgid "%s ago"
23
+ msgid " through %s"
24
+ msgstr ""
25
+
26
+ msgid "%s - The following compliance reports are about to be changed"
24
27
  msgstr ""
25
28
 
26
29
  msgid "%s compliance report by policy"
@@ -49,6 +52,9 @@ msgstr ""
49
52
  msgid "Apply policy to host groups"
50
53
  msgstr ""
51
54
 
55
+ msgid "Apply policy to hosts"
56
+ msgstr ""
57
+
52
58
  msgid "Assign Compliance Policy"
53
59
  msgstr ""
54
60
 
@@ -58,7 +64,10 @@ msgstr ""
58
64
  msgid "Cancel"
59
65
  msgstr ""
60
66
 
61
- msgid "Cannot generate HTML guide for %{scap_content}/%{profile}"
67
+ msgid "Cannot generate HTML guide, no valid OpenSCAP proxy server found."
68
+ msgstr ""
69
+
70
+ msgid "Cannot generate HTML guide, scap content is missing."
62
71
  msgstr ""
63
72
 
64
73
  msgid "Changed"
@@ -100,6 +109,9 @@ msgstr ""
100
109
  msgid "Compliance Status"
101
110
  msgstr ""
102
111
 
112
+ msgid "Compliance policy summary"
113
+ msgstr ""
114
+
103
115
  msgid "Compliance policy: %s"
104
116
  msgstr ""
105
117
 
@@ -151,6 +163,9 @@ msgstr ""
151
163
  msgid "Delete an ARF Report"
152
164
  msgstr ""
153
165
 
166
+ msgid "Delete compliance policy %s with all of its reports?"
167
+ msgstr ""
168
+
154
169
  msgid "Delete compliance policy %s with all the reports?"
155
170
  msgstr ""
156
171
 
@@ -163,6 +178,9 @@ msgstr ""
163
178
  msgid "Delete tailoring file %s?"
164
179
  msgstr ""
165
180
 
181
+ msgid "Deleted policy"
182
+ msgstr ""
183
+
166
184
  msgid "Deletes a Tailoring file"
167
185
  msgstr ""
168
186
 
@@ -172,6 +190,9 @@ msgstr ""
172
190
  msgid "Description"
173
191
  msgstr ""
174
192
 
193
+ msgid "Documentation"
194
+ msgstr ""
195
+
175
196
  msgid "Download"
176
197
  msgstr ""
177
198
 
@@ -226,6 +247,9 @@ msgstr ""
226
247
  msgid "Failed to downloaded ARF report in HTML: %s"
227
248
  msgstr ""
228
249
 
250
+ msgid "Failed to upload Arf Report, no OpenSCAP proxy set for host %s"
251
+ msgstr ""
252
+
229
253
  #. TRANSLATORS: initial character of Failed
230
254
  msgid "Failed|F"
231
255
  msgstr ""
@@ -275,6 +299,9 @@ msgstr ""
275
299
  msgid "Hosts Breakdown"
276
300
  msgstr ""
277
301
 
302
+ msgid "ID of OpenSCAP Proxy"
303
+ msgstr ""
304
+
278
305
  msgid "In Foreman, a compliance policy checklist is defined via %s."
279
306
  msgstr ""
280
307
 
@@ -363,7 +390,10 @@ msgstr ""
363
390
  msgid "No ARF reports for this policy"
364
391
  msgstr ""
365
392
 
366
- msgid "No OpenSCAP proxy found for %{class} with %{id}"
393
+ msgid "No OpenSCAP proxy found for %{class} with id %{id}"
394
+ msgstr ""
395
+
396
+ msgid "No Tailoring file assigned for policy with id %s"
367
397
  msgstr ""
368
398
 
369
399
  msgid "No available proxy to validate. Returned with error: %s"
@@ -384,6 +414,9 @@ msgstr ""
384
414
  msgid "No hosts were found."
385
415
  msgstr ""
386
416
 
417
+ msgid "No proxy found!"
418
+ msgstr ""
419
+
387
420
  msgid "No proxy with OpenSCAP feature is running."
388
421
  msgstr ""
389
422
 
@@ -396,9 +429,6 @@ msgstr ""
396
429
  msgid "No reports available"
397
430
  msgstr ""
398
431
 
399
- msgid "No valid OpenSCAP proxy server found."
400
- msgstr ""
401
-
402
432
  msgid "No valid policy ID provided"
403
433
  msgstr ""
404
434
 
@@ -429,10 +459,13 @@ msgstr ""
429
459
  msgid "Once SCAP content is present, you can create a policy, assign select host groups and schedule to run."
430
460
  msgstr ""
431
461
 
432
- msgid "Openscap Proxy"
462
+ msgid "OpenSCAP Proxy"
433
463
  msgstr ""
434
464
 
435
- msgid "Openscap policy summary"
465
+ msgid "OpenSCAP Proxy to use for fetching SCAP content and uploading ARF reports"
466
+ msgstr ""
467
+
468
+ msgid "Openscap Proxy"
436
469
  msgstr ""
437
470
 
438
471
  msgid "Organizations"
@@ -467,6 +500,9 @@ msgstr ""
467
500
  msgid "Policies with hosts:"
468
501
  msgstr ""
469
502
 
503
+ msgid "Policy"
504
+ msgstr ""
505
+
470
506
  msgid "Policy %s"
471
507
  msgstr ""
472
508
 
@@ -690,9 +726,6 @@ msgstr ""
690
726
  msgid "Unknown Compliance status"
691
727
  msgstr ""
692
728
 
693
- msgid "Unsupported report status format"
694
- msgstr ""
695
-
696
729
  msgid "Update a Policy"
697
730
  msgstr ""
698
731
 
@@ -753,12 +786,18 @@ msgstr ""
753
786
  msgid "You can specify custom cron line, e.g. \"0 3 * * *\", separate each of 5 values by space"
754
787
  msgstr ""
755
788
 
789
+ msgid "You don't seem to have any ARF report. ARF report is a summary of a single scan occurrence on a particular host for a given Compliance Policy."
790
+ msgstr ""
791
+
756
792
  msgid "does not come from selected tailoring file"
757
793
  msgstr ""
758
794
 
759
795
  msgid "does not consist of 5 parts separated by space"
760
796
  msgstr ""
761
797
 
798
+ msgid "does not have the selected SCAP content profile"
799
+ msgstr ""
800
+
762
801
  msgid "invalid type %s"
763
802
  msgstr ""
764
803
 
@@ -783,5 +822,5 @@ msgstr ""
783
822
  msgid "must have Openscap feature"
784
823
  msgstr ""
785
824
 
786
- msgid "these Complianace reports"
825
+ msgid "these Compliance reports"
787
826
  msgstr ""
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :arf_report, :class => ::ForemanOpenscap::ArfReport do
3
3
  host_id 1
4
4
  policy nil
@@ -1,6 +1,6 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :asset, :class => ::ForemanOpenscap::Asset do |f|
3
- f.assetable_id { FactoryGirl.create(:host).id }
3
+ f.assetable_id { FactoryBot.create(:host).id }
4
4
  f.assetable_type 'Host::Base'
5
5
  end
6
6
 
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :openscap_feature, :class => Feature do
3
3
  name 'Openscap'
4
4
  end
@@ -13,7 +13,7 @@ FactoryGirl.define do
13
13
  sequence(:name) { |n| "host#{n}" }
14
14
  sequence(:hostname) { |n| "hostname#{n}" }
15
15
  root_pass 'xybxa6JUkz63w'
16
- openscap_proxy { SmartProxy.unscoped.with_features('Openscap').first || FactoryGirl.create(:openscap_proxy) }
16
+ openscap_proxy { SmartProxy.unscoped.with_features('Openscap').first || FactoryBot.create(:openscap_proxy) }
17
17
  policies []
18
18
  end
19
19
  end
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :compliance_log, :class => :log do
3
3
  result "fail"
4
4
  association :report
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :policy_arf_report, :class => ForemanOpenscap::PolicyArfReport do
3
3
  policy_id nil
4
4
  arf_report_id nil
@@ -1,10 +1,10 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :policy, :class => ::ForemanOpenscap::Policy do
3
3
  sequence(:name) { |n| "policy#{n}" }
4
4
  period 'weekly'
5
5
  weekday 'monday'
6
- scap_content { FactoryGirl.create(:scap_content) }
7
- scap_content_profile { FactoryGirl.create(:scap_content_profile, :scap_content => scap_content) }
6
+ scap_content { FactoryBot.create(:scap_content) }
7
+ scap_content_profile { FactoryBot.create(:scap_content_profile, :scap_content => scap_content) }
8
8
  tailoring_file nil
9
9
  tailoring_file_profile nil
10
10
  day_of_month nil
@@ -1,8 +1,8 @@
1
1
  include ActionDispatch::TestProcess
2
2
 
3
- FactoryGirl.define do
3
+ FactoryBot.define do
4
4
  factory :scap_content, :class => ::ForemanOpenscap::ScapContent do |f|
5
- f.title 'fedora'
5
+ f.sequence(:title) { |n| "scap_content_title_#{n}" }
6
6
  f.original_filename 'fedora ds'
7
7
  f.scap_file { File.new("#{ForemanOpenscap::Engine.root}/test/files/scap_contents/ssg-fedora-ds.xml", 'rb').read }
8
8
  end
@@ -8,18 +8,16 @@ class Api::V2::Compliance::ArfReportsControllerTest < ActionController::TestCase
8
8
  Message.delete_all
9
9
  # override validation of policy (puppetclass, lookup_key overrides)
10
10
  ForemanOpenscap::Policy.any_instance.stubs(:valid?).returns(true)
11
- @host = FactoryGirl.create(:compliance_host)
12
- @report = FactoryGirl.create(:arf_report,
13
- :host_id => @host.id,
14
- :openscap_proxy => FactoryGirl.create(:smart_proxy, :url => "http://smart-proxy.org:8000"))
15
- @policy = FactoryGirl.create(:policy)
16
- @asset = FactoryGirl.create(:asset)
11
+ @host = FactoryBot.create(:compliance_host)
12
+ @policy = FactoryBot.create(:policy)
13
+ @asset = FactoryBot.create(:asset, :assetable_id => @host.id)
17
14
 
18
15
  @from_json = arf_from_json "#{ForemanOpenscap::Engine.root}/test/files/arf_report/arf_report.json"
19
16
  @cname = '9521a5c5-8f44-495f-b087-20e86b30bf67'
20
17
  end
21
18
 
22
19
  test "should get index" do
20
+ create_arf_report
23
21
  get :index, {}, set_session_user
24
22
  response = ActiveSupport::JSON.decode(@response.body)
25
23
  assert_not response['results'].empty?
@@ -27,7 +25,8 @@ class Api::V2::Compliance::ArfReportsControllerTest < ActionController::TestCase
27
25
  end
28
26
 
29
27
  test "should get show" do
30
- get :show, { :id => @report.to_param }, set_session_user
28
+ report = create_arf_report
29
+ get :show, { :id => report.to_param }, set_session_user
31
30
  response = ActiveSupport::JSON.decode(@response.body)
32
31
  refute response['passed'].blank?
33
32
  refute response['failed'].blank?
@@ -36,9 +35,10 @@ class Api::V2::Compliance::ArfReportsControllerTest < ActionController::TestCase
36
35
  end
37
36
 
38
37
  test "should download report" do
38
+ report = create_arf_report
39
39
  bzipped_report = File.read "#{ForemanOpenscap::Engine.root}/test/files/arf_report/arf_report.bz2"
40
40
  ForemanOpenscap::ArfReport.any_instance.stubs(:to_bzip).returns(bzipped_report)
41
- get :download, { :id => @report.to_param }, set_session_user
41
+ get :download, { :id => report.to_param }, set_session_user
42
42
  t = Tempfile.new('tmp_report')
43
43
  t.write @response.body
44
44
  t.close
@@ -63,6 +63,20 @@ class Api::V2::Compliance::ArfReportsControllerTest < ActionController::TestCase
63
63
  assert_equal msg_count, src_count
64
64
  end
65
65
 
66
+ test "should not create report for host without proxy" do
67
+ asset = FactoryBot.create(:asset)
68
+ date = Time.new(1944, 6, 6)
69
+ ForemanOpenscap::Helper.stubs(:get_asset).returns(asset)
70
+ post :create,
71
+ @from_json.merge(:cname => @cname,
72
+ :policy_id => @policy.id,
73
+ :date => date.to_i),
74
+ set_session_user
75
+ assert_response :unprocessable_entity
76
+ res = JSON.parse(@response.body)
77
+ assert_equal "Failed to upload Arf Report, no OpenSCAP proxy set for host #{asset.host.name}", res["result"]
78
+ end
79
+
66
80
  test "should not duplicate messages" do
67
81
  dates = [Time.new(1984, 9, 15), Time.new(1932, 3, 27)]
68
82
  params = @from_json.with_indifferent_access.merge(:cname => @cname,
@@ -70,7 +84,6 @@ class Api::V2::Compliance::ArfReportsControllerTest < ActionController::TestCase
70
84
  :date => dates[0].to_i)
71
85
  assert ForemanOpenscap::ArfReport.create_arf(@asset, params)
72
86
 
73
-
74
87
  ForemanOpenscap::Helper.stubs(:get_asset).returns(@asset)
75
88
  post :create,
76
89
  @from_json.merge(:cname => @cname,
@@ -147,4 +160,10 @@ class Api::V2::Compliance::ArfReportsControllerTest < ActionController::TestCase
147
160
  file_content = File.read path
148
161
  JSON.parse file_content
149
162
  end
163
+
164
+ def create_arf_report
165
+ FactoryBot.create(:arf_report,
166
+ :host_id => @host.id,
167
+ :openscap_proxy => FactoryBot.create(:smart_proxy, :url => "http://smart-proxy.org:8000"))
168
+ end
150
169
  end
@@ -3,16 +3,16 @@ require 'test_plugin_helper'
3
3
  class Api::V2::Compliance::PoliciesControllerTest < ActionController::TestCase
4
4
  setup do
5
5
  ::ForemanOpenscap::Policy.any_instance.stubs(:ensure_needed_puppetclasses).returns(true)
6
- @scap_content_profile = FactoryGirl.create(:scap_content_profile)
6
+ @scap_content_profile = FactoryBot.create(:scap_content_profile)
7
7
  @attributes = { :policy => { :name => 'my_policy',
8
8
  :scap_content_profile_id => @scap_content_profile.id,
9
9
  :scap_content_id => @scap_content_profile.scap_content_id,
10
10
  :period => 'weekly',
11
- :weekday => 'friday' }}
11
+ :weekday => 'friday' } }
12
12
  end
13
13
 
14
14
  test "should get index" do
15
- FactoryGirl.create(:policy)
15
+ FactoryBot.create(:policy)
16
16
  get :index, {}, set_session_user
17
17
  response = ActiveSupport::JSON.decode(@response.body)
18
18
  assert !response['results'].empty?
@@ -20,7 +20,7 @@ class Api::V2::Compliance::PoliciesControllerTest < ActionController::TestCase
20
20
  end
21
21
 
22
22
  test "should show a policy" do
23
- policy = FactoryGirl.create(:policy)
23
+ policy = FactoryBot.create(:policy)
24
24
  get :show, { :id => policy.to_param }, set_session_user
25
25
  response = ActiveSupport::JSON.decode(@response.body)
26
26
  assert response['name'], policy.name
@@ -28,16 +28,16 @@ class Api::V2::Compliance::PoliciesControllerTest < ActionController::TestCase
28
28
  end
29
29
 
30
30
  test "should update a policy" do
31
- policy = FactoryGirl.create(:policy)
32
- put :update, { :id => policy.id, :policy => { :period => 'monthly', :day_of_month => 15 }}
31
+ policy = FactoryBot.create(:policy)
32
+ put :update, { :id => policy.id, :policy => { :period => 'monthly', :day_of_month => 15 } }
33
33
  updated_policy = ActiveSupport::JSON.decode(@response.body)
34
34
  assert(updated_policy['period'], 'monthly')
35
35
  assert_response :ok
36
36
  end
37
37
 
38
38
  test "should not update invalid" do
39
- policy = FactoryGirl.create(:policy)
40
- put :update, {:id => policy.id, :policy => {:name => ''}}
39
+ policy = FactoryBot.create(:policy)
40
+ put :update, { :id => policy.id, :policy => { :name => '' } }
41
41
  assert_response :unprocessable_entity
42
42
  end
43
43
 
@@ -49,7 +49,7 @@ class Api::V2::Compliance::PoliciesControllerTest < ActionController::TestCase
49
49
  end
50
50
 
51
51
  test "should not create a policy with tailoring file profile and without the actual file" do
52
- tailoring_profile = FactoryGirl.create(:scap_content_profile, :profile_id => 'xccdf_org.test.tailoring_profile')
52
+ tailoring_profile = FactoryBot.create(:scap_content_profile, :profile_id => 'xccdf_org.test.tailoring_profile')
53
53
  @attributes[:policy][:tailoring_file_profile_id] = tailoring_profile.id
54
54
  post :create, @attributes, set_session_user
55
55
  response = ActiveSupport::JSON.decode(@response.body)
@@ -58,7 +58,7 @@ class Api::V2::Compliance::PoliciesControllerTest < ActionController::TestCase
58
58
  end
59
59
 
60
60
  test "should not create a policy with tailoring file and without tailoring profile" do
61
- tailoring_file = FactoryGirl.create(:tailoring_file)
61
+ tailoring_file = FactoryBot.create(:tailoring_file)
62
62
  @attributes[:policy][:tailoring_file_id] = tailoring_file.id
63
63
  post :create, @attributes, set_session_user
64
64
  response = ActiveSupport::JSON.decode(@response.body)
@@ -72,30 +72,30 @@ class Api::V2::Compliance::PoliciesControllerTest < ActionController::TestCase
72
72
  end
73
73
 
74
74
  test "should destroy" do
75
- policy = FactoryGirl.create(:policy)
75
+ policy = FactoryBot.create(:policy)
76
76
  delete :destroy, { :id => policy.id }, set_session_user
77
77
  assert_response :ok
78
78
  refute ForemanOpenscap::Policy.exists?(policy.id)
79
79
  end
80
80
 
81
81
  test "should return xml of scap content" do
82
- policy = FactoryGirl.create(:policy)
82
+ policy = FactoryBot.create(:policy)
83
83
  get :content, { :id => policy.id }, set_session_user
84
84
  assert(@response.header['Content-Type'], 'application/xml')
85
85
  assert_response :success
86
86
  end
87
87
 
88
88
  test "should return xml of a tailoring file" do
89
- tailoring_profile = FactoryGirl.create(:scap_content_profile)
90
- policy = FactoryGirl.create(:policy, :tailoring_file => FactoryGirl.create(:tailoring_file, :scap_content_profiles => [tailoring_profile]),
91
- :tailoring_file_profile => tailoring_profile)
89
+ tailoring_profile = FactoryBot.create(:scap_content_profile)
90
+ policy = FactoryBot.create(:policy, :tailoring_file => FactoryBot.create(:tailoring_file, :scap_content_profiles => [tailoring_profile]),
91
+ :tailoring_file_profile => tailoring_profile)
92
92
  get :tailoring, { :id => policy.id }, set_session_user
93
93
  assert(@response.header['Content-Type'], 'application/xml')
94
94
  assert_response :success
95
95
  end
96
96
 
97
97
  test "should return meaningufull error when no tailioring file assigned" do
98
- policy = FactoryGirl.create(:policy)
98
+ policy = FactoryBot.create(:policy)
99
99
  get :tailoring, { :id => policy.id }, set_session_user
100
100
  assert_response :not_found
101
101
  response = ActiveSupport::JSON.decode(@response.body)
@@ -1,9 +1,8 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
3
  class Api::V2::Compliance::ScapContentsControllerTest < ActionController::TestCase
4
-
5
4
  test "should get index" do
6
- FactoryGirl.create(:scap_content)
5
+ FactoryBot.create(:scap_content)
7
6
  get :index, {}, set_session_user
8
7
  response = ActiveSupport::JSON.decode(@response.body)
9
8
  assert response['results'].any?
@@ -11,7 +10,7 @@ class Api::V2::Compliance::ScapContentsControllerTest < ActionController::TestCa
11
10
  end
12
11
 
13
12
  test "should return xml of scap content" do
14
- scap_content = FactoryGirl.create(:scap_content)
13
+ scap_content = FactoryBot.create(:scap_content)
15
14
  get :show, { :id => scap_content.id }, set_session_user
16
15
  assert(@response.header['Content-Type'], 'application/xml')
17
16
  assert_response :success
@@ -27,22 +26,22 @@ class Api::V2::Compliance::ScapContentsControllerTest < ActionController::TestCa
27
26
  end
28
27
 
29
28
  test "should update scap content" do
30
- scap_content = FactoryGirl.create(:scap_content)
31
- put :update, { :id => scap_content.id, :scap_content => {:title => 'RHEL7 SCAP'}}, set_session_user
29
+ scap_content = FactoryBot.create(:scap_content)
30
+ put :update, { :id => scap_content.id, :scap_content => { :title => 'RHEL7 SCAP' } }, set_session_user
32
31
  assert_response :success
33
32
  assert scap_content.title, 'RHEL7 SCAP'
34
33
  end
35
34
 
36
35
  test "should not update invalid scap content" do
37
36
  skip("Solve 'ActiveRecord::RecordInvalid' error")
38
- ProxyAPI::Openscap.any_instance.stubs(:validate_scap_content).returns({'errors' => ['Invalid file']})
39
- scap_content = FactoryGirl.create(:scap_content)
40
- put :update, { :id => scap_content.id, :scap_content => {:scap_file => '<xml>blah</xml>'}}, set_session_user
37
+ ProxyAPI::Openscap.any_instance.stubs(:validate_scap_content).returns({ 'errors' => ['Invalid file'] })
38
+ scap_content = FactoryBot.create(:scap_content)
39
+ put :update, { :id => scap_content.id, :scap_content => { :scap_file => '<xml>blah</xml>' } }, set_session_user
41
40
  assert_response :unprocessable_entity
42
41
  end
43
42
 
44
43
  test "should destory scap content" do
45
- scap_content = FactoryGirl.create(:scap_content)
44
+ scap_content = FactoryBot.create(:scap_content)
46
45
  delete :destroy, { :id => scap_content.id }, set_session_user
47
46
  assert_response :ok
48
47
  refute ForemanOpenscap::ScapContent.exists?(scap_content.id)
@@ -1,9 +1,8 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
3
  class Api::V2::Compliance::TailoringFilesControllerTest < ActionController::TestCase
4
-
5
4
  test "should get index" do
6
- FactoryGirl.create(:tailoring_file)
5
+ FactoryBot.create(:tailoring_file)
7
6
  get :index, {}, set_session_user
8
7
  response = ActiveSupport::JSON.decode(@response.body)
9
8
  assert response['results'].any?
@@ -11,7 +10,7 @@ class Api::V2::Compliance::TailoringFilesControllerTest < ActionController::Test
11
10
  end
12
11
 
13
12
  test "should return xml of tailoring_file" do
14
- tailoring_file = FactoryGirl.create(:tailoring_file)
13
+ tailoring_file = FactoryBot.create(:tailoring_file)
15
14
  get :show, { :id => tailoring_file.id }, set_session_user
16
15
  assert(@response.header['Content-Type'], 'application/xml')
17
16
  assert_response :success
@@ -23,7 +22,7 @@ class Api::V2::Compliance::TailoringFilesControllerTest < ActionController::Test
23
22
  end
24
23
 
25
24
  test "should create tailoring_file" do
26
- tf = FactoryGirl.build(:tailoring_file)
25
+ tf = FactoryBot.build(:tailoring_file)
27
26
  tf_params = { :name => tf.name, :original_filename => tf.original_filename, :scap_file => tf.scap_file }
28
27
  ForemanOpenscap::OpenscapProxyVersionCheck.any_instance.stubs(:openscap_proxy_versions)
29
28
  .returns({})
@@ -32,28 +31,28 @@ class Api::V2::Compliance::TailoringFilesControllerTest < ActionController::Test
32
31
  end
33
32
 
34
33
  test "should update tailoring_file" do
35
- tailoring_file = FactoryGirl.create(:tailoring_file)
36
- put :update, { :id => tailoring_file.id, :tailoring_file => { :name => 'RHEL7 SCAP' }}, set_session_user
34
+ tailoring_file = FactoryBot.create(:tailoring_file)
35
+ put :update, { :id => tailoring_file.id, :tailoring_file => { :name => 'RHEL7 SCAP' } }, set_session_user
37
36
  assert_response :success
38
37
  assert tailoring_file.name, 'RHEL7 SCAP'
39
38
  end
40
39
 
41
40
  test "should not update invalid tailoring_file" do
42
- tailoring_file = FactoryGirl.create(:tailoring_file)
43
- ProxyAPI::Openscap.any_instance.stubs(:validate_scap_file).returns({'errors' => ['Invalid file']})
44
- put :update, { :id => tailoring_file.id, :tailoring_file => { :scap_file => '<xml>blah</xml>' }}, set_session_user
41
+ tailoring_file = FactoryBot.create(:tailoring_file)
42
+ ProxyAPI::Openscap.any_instance.stubs(:validate_scap_file).returns({ 'errors' => ['Invalid file'] })
43
+ put :update, { :id => tailoring_file.id, :tailoring_file => { :scap_file => '<xml>blah</xml>' } }, set_session_user
45
44
  assert_response :unprocessable_entity
46
45
  end
47
46
 
48
47
  test "should destory tailoring_file" do
49
- tailoring_file = FactoryGirl.create(:tailoring_file)
48
+ tailoring_file = FactoryBot.create(:tailoring_file)
50
49
  delete :destroy, { :id => tailoring_file.id }, set_session_user
51
50
  assert_response :ok
52
51
  refute ForemanOpenscap::ScapContent.exists?(tailoring_file.id)
53
52
  end
54
53
 
55
54
  test "should not create tailoring file when there is outdated proxy version" do
56
- tf = FactoryGirl.build(:tailoring_file)
55
+ tf = FactoryBot.build(:tailoring_file)
57
56
  tf_params = { :name => tf.name, :original_filename => tf.original_filename, :scap_file => tf.scap_file }
58
57
  ForemanOpenscap::OpenscapProxyVersionCheck.any_instance.stubs(:openscap_proxy_versions)
59
58
  .returns('test-proxy' => '0.5.4')
@@ -4,12 +4,12 @@ class ArfReportsControllerTest < ActionController::TestCase
4
4
  setup do
5
5
  ForemanOpenscap::Helper.stubs(:find_name_or_uuid_by_host)
6
6
  ::ProxyAPI::Openscap.any_instance.stubs(:destroy_report).returns(true)
7
- @host = FactoryGirl.create(:compliance_host)
7
+ @host = FactoryBot.create(:compliance_host)
8
8
  end
9
9
 
10
10
  test "should delete arf report" do
11
11
  ForemanOpenscap::ArfReport.any_instance.stubs(:openscap_proxy).returns(@host.openscap_proxy)
12
- arf_report = FactoryGirl.create(:arf_report, :host_id => @host.id)
12
+ arf_report = FactoryBot.create(:arf_report, :host_id => @host.id)
13
13
  assert_difference("ForemanOpenscap::ArfReport.count", -1) do
14
14
  delete :destroy, { :id => arf_report.id }, set_session_user
15
15
  end
@@ -20,7 +20,7 @@ class ArfReportsControllerTest < ActionController::TestCase
20
20
  ForemanOpenscap::ArfReport.any_instance.stubs(:openscap_proxy).returns(@host.openscap_proxy)
21
21
  arf_reports = []
22
22
  3.times do
23
- arf_reports << FactoryGirl.create(:arf_report, :host_id => @host.id)
23
+ arf_reports << FactoryBot.create(:arf_report, :host_id => @host.id)
24
24
  end
25
25
  last_arf = arf_reports[-1]
26
26
  assert_difference("ForemanOpenscap::ArfReport.unscoped.count", -2) do
@@ -31,7 +31,7 @@ class ArfReportsControllerTest < ActionController::TestCase
31
31
  end
32
32
 
33
33
  test "should download arf report as html" do
34
- arf_report = FactoryGirl.create(:arf_report, :host_id => @host.id)
34
+ arf_report = FactoryBot.create(:arf_report, :host_id => @host.id)
35
35
  report_html = File.read("#{ForemanOpenscap::Engine.root}/test/files/arf_report/arf_report.html")
36
36
  ForemanOpenscap::ArfReport.any_instance.stubs(:to_html).returns(report_html)
37
37
  get :download_html, { :id => arf_report.id }, set_session_user
@@ -1,14 +1,16 @@
1
1
  require 'test_plugin_helper'
2
+ require 'application_helper'
2
3
 
3
4
  class OpenscapProxiesControllerTest < ActionController::TestCase
4
5
  include ActionView::Helpers::DateHelper
6
+ include ApplicationHelper
5
7
 
6
8
  test "should render spool error" do
7
- spool_error = { "timestamp" => 1_487_144_633.951_368, "level" => "ERROR", "message"=> "Failed to parse Arf Report in test" }
9
+ spool_error = { "timestamp" => 1_487_144_633.951_368, "level" => "ERROR", "message" => "Failed to parse Arf Report in test" }
8
10
  OpenscapProxiesController.any_instance.stubs(:find_spool_error).returns(spool_error)
9
- proxy = FactoryGirl.create(:openscap_proxy)
11
+ proxy = FactoryBot.create(:openscap_proxy)
10
12
  get :openscap_spool, { :id => proxy.id }, set_session_user
11
13
  assert_template :partial => 'smart_proxies/_openscap_spool'
12
- assert @response.body.match(time_ago_in_words(Time.at(spool_error["timestamp"])))
14
+ assert @response.body.match(date_time_relative_value(Time.at(spool_error["timestamp"])))
13
15
  end
14
16
  end
@@ -2,7 +2,7 @@ require 'test_plugin_helper'
2
2
 
3
3
  class TailoringFilesControllerTest < ActionController::TestCase
4
4
  setup do
5
- @tailoring_file = FactoryGirl.create(:tailoring_file)
5
+ @tailoring_file = FactoryBot.create(:tailoring_file)
6
6
  @scap_file = File.new("#{ForemanOpenscap::Engine.root}/test/files/tailoring_files/ssg-firefox-ds-tailoring.xml", 'rb')
7
7
  end
8
8
 
@@ -1,9 +1,9 @@
1
1
  # This calls the main test_helper in Foreman-core
2
2
  require 'test_helper'
3
3
 
4
- # Add plugin to FactoryGirl's paths
5
- FactoryGirl.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
6
- FactoryGirl.reload
4
+ # Add plugin to FactoryBot's paths
5
+ FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
6
+ FactoryBot.reload
7
7
 
8
8
  module ScapClientPuppetclass
9
9
  def skip_scap_callback
@@ -17,15 +17,15 @@ module ScapTestProxy
17
17
  private
18
18
 
19
19
  def add_smart_proxy
20
- FactoryGirl.create(:smart_proxy, :url => 'http://localhost:8443', :features => [FactoryGirl.create(:feature, :name => 'Openscap')])
20
+ FactoryBot.create(:smart_proxy, :url => 'http://localhost:8443', :features => [FactoryBot.create(:feature, :name => 'Openscap')])
21
21
  ProxyAPI::Features.any_instance.stubs(:features).returns(%w[puppet openscap])
22
22
  versions = { "version" => "1.11.0", "modules" => { "openscap" => "0.5.3" } }
23
23
  ProxyAPI::Version.any_instance.stubs(:proxy_versions).returns(versions)
24
- ProxyAPI::Openscap.any_instance.stubs(:validate_scap_file).returns({'errors' => []})
24
+ ProxyAPI::Openscap.any_instance.stubs(:validate_scap_file).returns({ 'errors' => [] })
25
25
  ProxyAPI::Openscap.any_instance.stubs(:fetch_policies_for_scap_content)
26
- .returns({'xccdf_org.ssgproject.content_profile_common' => 'Common Profile for General-Purpose Fedora Systems'})
26
+ .returns({ 'xccdf_org.ssgproject.content_profile_common' => 'Common Profile for General-Purpose Fedora Systems' })
27
27
  ProxyAPI::Openscap.any_instance.stubs(:fetch_profiles_for_tailoring_file)
28
- .returns({'xccdf_org.ssgproject.test_profile_common' => 'Stubbed test profile'})
28
+ .returns({ 'xccdf_org.ssgproject.test_profile_common' => 'Stubbed test profile' })
29
29
  end
30
30
  end
31
31