foreman_openscap 0.8.6 → 0.9.0
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.
- checksums.yaml +4 -4
- data/app/controllers/api/v2/compliance/arf_reports_controller.rb +3 -3
- data/app/controllers/api/v2/compliance/policies_controller.rb +2 -2
- data/app/controllers/api/v2/compliance/scap_contents_controller.rb +1 -1
- data/app/controllers/api/v2/compliance/tailoring_files_controller.rb +2 -2
- data/app/controllers/arf_reports_controller.rb +2 -2
- data/app/controllers/concerns/foreman_openscap/hosts_controller_extensions.rb +4 -7
- data/app/controllers/policies_controller.rb +3 -3
- data/app/controllers/policy_dashboard_controller.rb +1 -1
- data/app/controllers/scap_contents_controller.rb +2 -2
- data/app/controllers/tailoring_files_controller.rb +2 -2
- data/app/helpers/arf_reports_helper.rb +1 -1
- data/app/helpers/concerns/foreman_openscap/hosts_helper_extensions.rb +4 -11
- data/app/helpers/concerns/foreman_openscap/lookup_keys_helper_extensions.rb +2 -8
- data/app/helpers/policies_helper.rb +1 -1
- data/app/lib/proxy_api/openscap.rb +2 -3
- data/app/models/concerns/foreman_openscap/host_extensions.rb +19 -20
- data/app/models/foreman_openscap/arf_report.rb +8 -12
- data/app/views/scap_contents/_form.html.erb +1 -1
- data/app/views/tailoring_files/_form.html.erb +1 -1
- data/db/migrate/20141013172051_create_scaptimony_policies.rb +1 -1
- data/db/migrate/20141014105333_create_scaptimony_assets.rb +1 -1
- data/db/migrate/20141015092642_create_scaptimony_arf_reports.rb +1 -1
- data/db/migrate/20141015115511_add_arf_report_unique_constraint.rb +1 -1
- data/db/migrate/20141104164201_create_scaptimony_scap_contents.rb +1 -1
- data/db/migrate/20141104171545_create_scaptimony_policy_revisions.rb +1 -1
- data/db/migrate/20141105174625_add_description_to_scaptimony_policy_revisions.rb +1 -1
- data/db/migrate/20141105174834_add_columns_to_scaptimony_policies.rb +1 -1
- data/db/migrate/20141107091756_add_columns_to_scaptimony_scap_contents.rb +1 -1
- data/db/migrate/20141111104519_add_constraint_to_scaptimony_scap_contents.rb +1 -1
- data/db/migrate/20141113221054_create_scaptimony_scap_content_profiles.rb +1 -1
- data/db/migrate/20141116170632_remove_xccdf_profile_from_scaptimony_policies.rb +1 -1
- data/db/migrate/20141116171305_add_profile_to_scaptimony_policies.rb +1 -1
- data/db/migrate/20141118142954_add_constraint_to_scaptimony_policies.rb +1 -1
- data/db/migrate/20141119164918_create_scaptimony_xccdf_results.rb +1 -1
- data/db/migrate/20141119175434_create_scaptimony_xccdf_rules.rb +1 -1
- data/db/migrate/20141119182606_create_scaptimony_xccdf_rule_results.rb +1 -1
- data/db/migrate/20141121120326_create_scaptimony_arf_report_breakdowns.rb +1 -1
- data/db/migrate/20141121164042_replace_arf_report_breakdown_view.rb +1 -1
- data/db/migrate/20141206211151_create_scaptimony_assets_policies.rb +1 -1
- data/db/migrate/20141214112917_add_scap_file_to_scap_content.rb +1 -1
- data/db/migrate/20141216154502_rename_scaptimony_asset_policies.rb +1 -1
- data/db/migrate/20150111085317_polymorph_asset.rb +1 -1
- data/db/migrate/20150112152944_create_scaptimony_arf_report_raws.rb +1 -1
- data/db/migrate/20150114210634_rename_scaptimony_arf_report_raw_raw.rb +1 -1
- data/db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb +1 -1
- data/db/migrate/20150116083129_add_day_of_month_and_cron_line_to_scaptimony_policy.rb +1 -1
- data/db/migrate/20150821100137_migrate_from_scaptimony.rb +1 -1
- data/db/migrate/20150827123826_remove_scaptimony_permissions.rb +1 -1
- data/db/migrate/20150925124959_create_policy_arf_reports.rb +1 -1
- data/db/migrate/20150929124853_add_result_to_logs.rb +1 -1
- data/db/migrate/20150929152345_move_arf_reports_to_reports_table.rb +2 -2
- data/db/migrate/20151118165125_add_size_to_scap_content.rb +1 -1
- data/db/migrate/20151119155419_add_arf_fields_to_message.rb +1 -1
- data/db/migrate/20151120090851_add_openscap_proxy_to_host_and_hostgroup.rb +1 -1
- data/db/migrate/20160830113437_remove_deleted_policy.rb +1 -1
- data/db/migrate/20160925213031_change_scap_widget_names.rb +1 -1
- data/db/migrate/20161109155255_create_tailoring_files.rb +1 -1
- data/db/migrate/20161223153249_add_permissions_to_arf_report.rb +1 -1
- data/db/migrate/20170821081205_rename_mail_notification.foreman_openscap.rb +1 -1
- data/db/migrate/20170830221751_add_index_to_logs_result.rb +1 -1
- data/db/migrate/20171011134112_remove_arf_reports_without_policy.rb +1 -11
- data/db/migrate/20171016125613_add_content_title_unique_constraint.foreman_openscap.rb +1 -1
- data/lib/foreman_openscap/engine.rb +5 -5
- data/lib/foreman_openscap/version.rb +1 -1
- data/test/factories/arf_report_factory.rb +1 -1
- data/test/functional/api/v2/compliance/arf_reports_controller_test.rb +21 -21
- data/test/functional/api/v2/compliance/policies_controller_test.rb +12 -12
- data/test/functional/api/v2/compliance/scap_contents_controller_test.rb +6 -6
- data/test/functional/api/v2/compliance/tailoring_files_controller_test.rb +8 -8
- data/test/functional/arf_reports_controller_test.rb +3 -3
- data/test/functional/openscap_proxies_controller_test.rb +1 -1
- data/test/functional/tailoring_files_controller_test.rb +6 -6
- metadata +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'digest/sha2'
|
|
2
2
|
|
|
3
|
-
class AddScaptimonyScapContentDigest < ActiveRecord::Migration
|
|
3
|
+
class AddScaptimonyScapContentDigest < ActiveRecord::Migration[4.2]
|
|
4
4
|
def change
|
|
5
5
|
unless column_exists?(:scaptimony_scap_contents, :digest)
|
|
6
6
|
add_column :scaptimony_scap_contents, :digest, :string, :limit => 128
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class AddDayOfMonthAndCronLineToScaptimonyPolicy < ActiveRecord::Migration
|
|
1
|
+
class AddDayOfMonthAndCronLineToScaptimonyPolicy < ActiveRecord::Migration[4.2]
|
|
2
2
|
def change
|
|
3
3
|
add_column :scaptimony_policies, :day_of_month, :integer
|
|
4
4
|
add_column :scaptimony_policies, :cron_line, :string
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class MigrateFromScaptimony < ActiveRecord::Migration
|
|
1
|
+
class MigrateFromScaptimony < ActiveRecord::Migration[4.2]
|
|
2
2
|
def up
|
|
3
3
|
ActiveRecord::ConnectionAdapters::SchemaStatements.module_eval do
|
|
4
4
|
# rename_tables renames the indexes, and their new names overflow, we cancel out the renaming of the indexes
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
class MoveArfReportsToReportsTable < ActiveRecord::Migration
|
|
1
|
+
class MoveArfReportsToReportsTable < ActiveRecord::Migration[4.2]
|
|
2
2
|
# rubocop:disable Metrics/MethodLength
|
|
3
3
|
# rubocop:disable Metrics/AbcSize
|
|
4
4
|
def up
|
|
5
|
-
execute 'DROP VIEW foreman_openscap_arf_report_breakdowns' if
|
|
5
|
+
execute 'DROP VIEW foreman_openscap_arf_report_breakdowns' if view_exists? 'foreman_openscap_arf_report_breakdowns'
|
|
6
6
|
drop_table :foreman_openscap_xccdf_results
|
|
7
7
|
drop_table :foreman_openscap_xccdf_rules
|
|
8
8
|
drop_table :foreman_openscap_xccdf_rule_results
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class RemoveDeletedPolicy < ActiveRecord::Migration
|
|
1
|
+
class RemoveDeletedPolicy < ActiveRecord::Migration[4.2]
|
|
2
2
|
def up
|
|
3
3
|
ForemanOpenscap::AssetPolicy.all.collect(&:policy_id).uniq.each do |policy_id|
|
|
4
4
|
execute("DELETE FROM foreman_openscap_asset_policies WHERE policy_id = '#{policy_id}';") if ForemanOpenscap::Policy.unscoped.find_by(id: policy_id).nil?
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
class RemoveArfReportsWithoutPolicy < ActiveRecord::Migration
|
|
1
|
+
class RemoveArfReportsWithoutPolicy < ActiveRecord::Migration[4.2]
|
|
2
2
|
def up
|
|
3
|
-
if User.unscoped.find_by(:login => User::ANONYMOUS_ADMIN)
|
|
4
|
-
User.as_anonymous_admin do
|
|
5
|
-
delete_reports
|
|
6
|
-
end
|
|
7
|
-
else
|
|
8
|
-
delete_reports
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def delete_reports
|
|
13
3
|
ids_to_keep = ForemanOpenscap::ArfReport.unscoped.all.joins(:policy_arf_report).pluck(:id)
|
|
14
4
|
ForemanOpenscap::ArfReport.unscoped.where.not(:id => ids_to_keep).find_in_batches do |batch|
|
|
15
5
|
batch.map(&:destroy!)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class AddContentTitleUniqueConstraint < ActiveRecord::Migration
|
|
1
|
+
class AddContentTitleUniqueConstraint < ActiveRecord::Migration[4.2]
|
|
2
2
|
def change
|
|
3
3
|
remove_index :foreman_openscap_scap_contents, :name => 'index_scaptimony_scap_contents_on_title'
|
|
4
4
|
add_index :foreman_openscap_scap_contents, :title, :unique => true
|
|
@@ -42,7 +42,7 @@ module ForemanOpenscap
|
|
|
42
42
|
|
|
43
43
|
initializer 'foreman_openscap.register_plugin', :before => :finisher_hook do |app|
|
|
44
44
|
Foreman::Plugin.register :foreman_openscap do
|
|
45
|
-
requires_foreman '>= 1.
|
|
45
|
+
requires_foreman '>= 1.17'
|
|
46
46
|
|
|
47
47
|
apipie_documented_controllers ["#{ForemanOpenscap::Engine.root}/app/controllers/api/v2/compliance/*.rb"]
|
|
48
48
|
|
|
@@ -199,16 +199,16 @@ module ForemanOpenscap
|
|
|
199
199
|
config.to_prepare do
|
|
200
200
|
Host::Managed.send(:include, ForemanOpenscap::OpenscapProxyExtensions)
|
|
201
201
|
Host::Managed.send(:include, ForemanOpenscap::OpenscapProxyCoreExtensions)
|
|
202
|
-
Host::Managed.send(:
|
|
203
|
-
HostsHelper.send(:
|
|
202
|
+
Host::Managed.send(:prepend, ForemanOpenscap::HostExtensions)
|
|
203
|
+
HostsHelper.send(:prepend, ForemanOpenscap::HostsHelperExtensions)
|
|
204
204
|
Hostgroup.send(:include, ForemanOpenscap::OpenscapProxyExtensions)
|
|
205
205
|
Hostgroup.send(:include, ForemanOpenscap::OpenscapProxyCoreExtensions)
|
|
206
206
|
Hostgroup.send(:include, ForemanOpenscap::HostgroupExtensions)
|
|
207
207
|
ForemanOpenscap::ArfReport.send(:include, ForemanOpenscap::ComplianceStatusScopedSearch)
|
|
208
208
|
SmartProxy.send(:include, ForemanOpenscap::SmartProxyExtensions)
|
|
209
|
-
HostsController.send(:
|
|
209
|
+
HostsController.send(:prepend, ForemanOpenscap::HostsControllerExtensions)
|
|
210
210
|
Log.send(:include, ForemanOpenscap::LogExtensions)
|
|
211
|
-
LookupKeysHelper.send(:
|
|
211
|
+
LookupKeysHelper.send(:prepend, ForemanOpenscap::LookupKeysHelperExtensions)
|
|
212
212
|
end
|
|
213
213
|
|
|
214
214
|
rake_tasks do
|
|
@@ -18,7 +18,7 @@ class Api::V2::Compliance::ArfReportsControllerTest < ActionController::TestCase
|
|
|
18
18
|
|
|
19
19
|
test "should get index" do
|
|
20
20
|
create_arf_report
|
|
21
|
-
get :index,
|
|
21
|
+
get :index, :session => set_session_user
|
|
22
22
|
response = ActiveSupport::JSON.decode(@response.body)
|
|
23
23
|
assert_not response['results'].empty?
|
|
24
24
|
assert_response :success
|
|
@@ -26,7 +26,7 @@ class Api::V2::Compliance::ArfReportsControllerTest < ActionController::TestCase
|
|
|
26
26
|
|
|
27
27
|
test "should get show" do
|
|
28
28
|
report = create_arf_report
|
|
29
|
-
get :show, { :id => report.to_param }, set_session_user
|
|
29
|
+
get :show, :params => { :id => report.to_param }, :session => set_session_user
|
|
30
30
|
response = ActiveSupport::JSON.decode(@response.body)
|
|
31
31
|
refute response['passed'].blank?
|
|
32
32
|
refute response['failed'].blank?
|
|
@@ -38,7 +38,7 @@ class Api::V2::Compliance::ArfReportsControllerTest < ActionController::TestCase
|
|
|
38
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, :params => { :id => report.to_param }, :session => set_session_user
|
|
42
42
|
t = Tempfile.new('tmp_report')
|
|
43
43
|
t.write @response.body
|
|
44
44
|
t.close
|
|
@@ -50,10 +50,10 @@ class Api::V2::Compliance::ArfReportsControllerTest < ActionController::TestCase
|
|
|
50
50
|
date = Time.new(1984, 9, 15)
|
|
51
51
|
ForemanOpenscap::Helper.stubs(:get_asset).returns(@asset)
|
|
52
52
|
post :create,
|
|
53
|
-
@from_json.merge(:cname => @cname,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
set_session_user
|
|
53
|
+
:params => @from_json.merge(:cname => @cname,
|
|
54
|
+
:policy_id => @policy.id,
|
|
55
|
+
:date => date.to_i),
|
|
56
|
+
:session => set_session_user
|
|
57
57
|
report = ForemanOpenscap::ArfReport.unscoped.last
|
|
58
58
|
assert_equal date, report.reported_at
|
|
59
59
|
report_logs = report.logs
|
|
@@ -68,10 +68,10 @@ class Api::V2::Compliance::ArfReportsControllerTest < ActionController::TestCase
|
|
|
68
68
|
date = Time.new(1944, 6, 6)
|
|
69
69
|
ForemanOpenscap::Helper.stubs(:get_asset).returns(asset)
|
|
70
70
|
post :create,
|
|
71
|
-
@from_json.merge(:cname => @cname,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
set_session_user
|
|
71
|
+
:params => @from_json.merge(:cname => @cname,
|
|
72
|
+
:policy_id => @policy.id,
|
|
73
|
+
:date => date.to_i),
|
|
74
|
+
:session => set_session_user
|
|
75
75
|
assert_response :unprocessable_entity
|
|
76
76
|
res = JSON.parse(@response.body)
|
|
77
77
|
assert_equal "Failed to upload Arf Report, no OpenSCAP proxy set for host #{asset.host.name}", res["result"]
|
|
@@ -86,10 +86,10 @@ class Api::V2::Compliance::ArfReportsControllerTest < ActionController::TestCase
|
|
|
86
86
|
|
|
87
87
|
ForemanOpenscap::Helper.stubs(:get_asset).returns(@asset)
|
|
88
88
|
post :create,
|
|
89
|
-
@from_json.merge(:cname => @cname,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
set_session_user
|
|
89
|
+
:params => @from_json.merge(:cname => @cname,
|
|
90
|
+
:policy_id => @policy.id,
|
|
91
|
+
:date => dates[1].to_i),
|
|
92
|
+
:session => set_session_user
|
|
93
93
|
assert_equal Message.where(:digest => ForemanOpenscap::ArfReport.unscoped.last.logs.first.message.digest).count, 1
|
|
94
94
|
end
|
|
95
95
|
|
|
@@ -102,10 +102,10 @@ class Api::V2::Compliance::ArfReportsControllerTest < ActionController::TestCase
|
|
|
102
102
|
ForemanOpenscap::Helper.stubs(:get_asset).returns(@asset)
|
|
103
103
|
changed_from_json = arf_from_json "#{ForemanOpenscap::Engine.root}/test/files/arf_report/arf_report_msg_desc_changed.json"
|
|
104
104
|
post :create,
|
|
105
|
-
changed_from_json.merge(:cname => @cname,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
set_session_user
|
|
105
|
+
:params => changed_from_json.merge(:cname => @cname,
|
|
106
|
+
:policy_id => @policy.id,
|
|
107
|
+
:date => Time.new(2017, 6, 6).to_i),
|
|
108
|
+
:session => set_session_user
|
|
109
109
|
|
|
110
110
|
assert_response :success
|
|
111
111
|
|
|
@@ -127,10 +127,10 @@ class Api::V2::Compliance::ArfReportsControllerTest < ActionController::TestCase
|
|
|
127
127
|
ForemanOpenscap::Helper.stubs(:get_asset).returns(@asset)
|
|
128
128
|
changed_from_json = arf_from_json "#{ForemanOpenscap::Engine.root}/test/files/arf_report/arf_report_msg_value_changed.json"
|
|
129
129
|
post :create,
|
|
130
|
-
changed_from_json.merge(:cname => @cname,
|
|
130
|
+
:params => changed_from_json.merge(:cname => @cname,
|
|
131
131
|
:policy_id => @policy.id,
|
|
132
132
|
:date => Time.new(2017, 8, 6).to_i),
|
|
133
|
-
set_session_user
|
|
133
|
+
:session => set_session_user
|
|
134
134
|
|
|
135
135
|
assert_response :success
|
|
136
136
|
|
|
@@ -13,7 +13,7 @@ class Api::V2::Compliance::PoliciesControllerTest < ActionController::TestCase
|
|
|
13
13
|
|
|
14
14
|
test "should get index" do
|
|
15
15
|
FactoryBot.create(:policy)
|
|
16
|
-
get :index,
|
|
16
|
+
get :index, :session => set_session_user
|
|
17
17
|
response = ActiveSupport::JSON.decode(@response.body)
|
|
18
18
|
assert !response['results'].empty?
|
|
19
19
|
assert_response :success
|
|
@@ -21,7 +21,7 @@ class Api::V2::Compliance::PoliciesControllerTest < ActionController::TestCase
|
|
|
21
21
|
|
|
22
22
|
test "should show a policy" do
|
|
23
23
|
policy = FactoryBot.create(:policy)
|
|
24
|
-
get :show, { :id => policy.to_param }, set_session_user
|
|
24
|
+
get :show, :params => { :id => policy.to_param }, :session => set_session_user
|
|
25
25
|
response = ActiveSupport::JSON.decode(@response.body)
|
|
26
26
|
assert response['name'], policy.name
|
|
27
27
|
assert_response :success
|
|
@@ -29,7 +29,7 @@ class Api::V2::Compliance::PoliciesControllerTest < ActionController::TestCase
|
|
|
29
29
|
|
|
30
30
|
test "should update a policy" do
|
|
31
31
|
policy = FactoryBot.create(:policy)
|
|
32
|
-
put :update, { :id => policy.id, :policy => { :period => 'monthly', :day_of_month => 15 } }
|
|
32
|
+
put :update, :params => { :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
|
|
@@ -37,12 +37,12 @@ class Api::V2::Compliance::PoliciesControllerTest < ActionController::TestCase
|
|
|
37
37
|
|
|
38
38
|
test "should not update invalid" do
|
|
39
39
|
policy = FactoryBot.create(:policy)
|
|
40
|
-
put :update, { :id => policy.id, :policy => { :name => '' } }
|
|
40
|
+
put :update, :params => { :id => policy.id, :policy => { :name => '' } }
|
|
41
41
|
assert_response :unprocessable_entity
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
test "should create a policy" do
|
|
45
|
-
post :create, @attributes, set_session_user
|
|
45
|
+
post :create, :params => @attributes, :session => set_session_user
|
|
46
46
|
response = ActiveSupport::JSON.decode(@response.body)
|
|
47
47
|
assert response['scap_content_profile_id'], @scap_content_profile.to_param
|
|
48
48
|
assert_response :created
|
|
@@ -51,7 +51,7 @@ class Api::V2::Compliance::PoliciesControllerTest < ActionController::TestCase
|
|
|
51
51
|
test "should not create a policy with tailoring file profile and without the actual file" do
|
|
52
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
|
-
post :create, @attributes, set_session_user
|
|
54
|
+
post :create, :params => @attributes, :session => set_session_user
|
|
55
55
|
response = ActiveSupport::JSON.decode(@response.body)
|
|
56
56
|
assert_not_nil response['error']['errors']['tailoring_file_id']
|
|
57
57
|
assert_response :unprocessable_entity
|
|
@@ -60,27 +60,27 @@ class Api::V2::Compliance::PoliciesControllerTest < ActionController::TestCase
|
|
|
60
60
|
test "should not create a policy with tailoring file and without tailoring profile" do
|
|
61
61
|
tailoring_file = FactoryBot.create(:tailoring_file)
|
|
62
62
|
@attributes[:policy][:tailoring_file_id] = tailoring_file.id
|
|
63
|
-
post :create, @attributes, set_session_user
|
|
63
|
+
post :create, :params => @attributes, :session => set_session_user
|
|
64
64
|
response = ActiveSupport::JSON.decode(@response.body)
|
|
65
65
|
assert_not_nil response['error']['errors']['tailoring_file_profile_id']
|
|
66
66
|
assert_response :unprocessable_entity
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
test "should not create invalid policy" do
|
|
70
|
-
post :create,
|
|
70
|
+
post :create, :session => set_session_user
|
|
71
71
|
assert_response :unprocessable_entity
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
test "should destroy" do
|
|
75
75
|
policy = FactoryBot.create(:policy)
|
|
76
|
-
delete :destroy, { :id => policy.id }, set_session_user
|
|
76
|
+
delete :destroy, :params => { :id => policy.id }, :session => 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
82
|
policy = FactoryBot.create(:policy)
|
|
83
|
-
get :content, { :id => policy.id }, set_session_user
|
|
83
|
+
get :content, :params => { :id => policy.id }, :session => set_session_user
|
|
84
84
|
assert(@response.header['Content-Type'], 'application/xml')
|
|
85
85
|
assert_response :success
|
|
86
86
|
end
|
|
@@ -89,14 +89,14 @@ class Api::V2::Compliance::PoliciesControllerTest < ActionController::TestCase
|
|
|
89
89
|
tailoring_profile = FactoryBot.create(:scap_content_profile)
|
|
90
90
|
policy = FactoryBot.create(:policy, :tailoring_file => FactoryBot.create(:tailoring_file, :scap_content_profiles => [tailoring_profile]),
|
|
91
91
|
:tailoring_file_profile => tailoring_profile)
|
|
92
|
-
get :tailoring, { :id => policy.id }, set_session_user
|
|
92
|
+
get :tailoring, :params => { :id => policy.id }, :session => 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
98
|
policy = FactoryBot.create(:policy)
|
|
99
|
-
get :tailoring, { :id => policy.id }, set_session_user
|
|
99
|
+
get :tailoring, :params => { :id => policy.id }, :session => set_session_user
|
|
100
100
|
assert_response :not_found
|
|
101
101
|
response = ActiveSupport::JSON.decode(@response.body)
|
|
102
102
|
assert_equal "No Tailoring file assigned for policy with id #{policy.id}", response['error']['message']
|