foreman_openscap 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +80 -12
  3. data/app/assets/javascript/foreman_openscap/scap_hosts_show.js +4 -0
  4. data/app/controllers/api/v2/compliance/arf_reports_controller.rb +46 -3
  5. data/app/controllers/api/v2/compliance/policies_controller.rb +51 -24
  6. data/app/controllers/api/v2/compliance/scap_contents_controller.rb +74 -0
  7. data/app/controllers/scaptimony_hosts_controller.rb +5 -0
  8. data/app/controllers/scaptimony_policies_controller.rb +16 -2
  9. data/app/helpers/concerns/foreman_openscap/hosts_helper_extensions.rb +32 -1
  10. data/app/models/concerns/foreman_openscap/arf_report_extensions.rb +1 -0
  11. data/app/models/concerns/foreman_openscap/host_extensions.rb +1 -1
  12. data/app/models/concerns/foreman_openscap/policy_extensions.rb +5 -1
  13. data/app/overrides/hosts/overview/host_compliance_status.rb +4 -0
  14. data/app/services/scaptimony/host_report_dashboard/data.rb +38 -0
  15. data/app/views/api/v2/compliance/arf_reports/base.json.rabl +4 -0
  16. data/app/views/api/v2/compliance/arf_reports/index.json.rabl +2 -0
  17. data/app/views/api/v2/compliance/arf_reports/main.json.rabl +5 -0
  18. data/app/views/api/v2/compliance/arf_reports/show.json.rabl +3 -0
  19. data/app/views/api/v2/compliance/policies/base.json.rabl +3 -0
  20. data/app/views/api/v2/compliance/policies/index.json.rabl +3 -0
  21. data/app/views/api/v2/compliance/policies/main.json.rabl +5 -0
  22. data/app/views/api/v2/compliance/policies/show.json.rabl +3 -0
  23. data/app/views/api/v2/compliance/scap_contents/base.json.rabl +3 -0
  24. data/app/views/api/v2/compliance/scap_contents/index.json.rabl +3 -0
  25. data/app/views/api/v2/compliance/scap_contents/main.json.rabl +5 -0
  26. data/app/views/api/v2/compliance/scap_contents/show.json.rabl +1 -0
  27. data/app/views/dashboard/_foreman_openscap_host_reports_widget.html.erb +1 -1
  28. data/app/views/scaptimony_arf_reports/_list.html.erb +1 -1
  29. data/app/views/scaptimony_hosts/_host_status.html.erb +17 -0
  30. data/app/views/scaptimony_hosts/show.html.erb +23 -0
  31. data/app/views/scaptimony_policies/disassociate_multiple_hosts.html.erb +7 -0
  32. data/config/routes.rb +6 -2
  33. data/lib/foreman_openscap/engine.rb +2 -0
  34. data/lib/foreman_openscap/version.rb +1 -1
  35. data/test/factories/arf_report_factory.rb +10 -0
  36. data/test/factories/asset_factory.rb +6 -0
  37. data/test/factories/policy_factory.rb +1 -2
  38. data/test/factories/scap_content_related.rb +0 -1
  39. data/test/files/scap_contents/ssg-fedora-ds.xml +1 -28
  40. data/test/functional/api/v2/arf_reports_controller_test.rb +24 -0
  41. data/test/functional/api/v2/policies_controller_test.rb +58 -0
  42. data/test/functional/api/v2/scap_contents_controller_test.rb +49 -0
  43. metadata +32 -7
  44. data/Rakefile +0 -40
  45. data/test/factories/foreman_openscap_factories.rb +0 -5
  46. data/test/functional/api/v2/compliance/policies_controller_test.rb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 09505297b4cd605e6283f0a175058d113c1e0e08
4
- data.tar.gz: 9a91588dc7ca37021eb6a07fb98a04f8bcff22d9
3
+ metadata.gz: 48ae466c6c227a222397d8a8151177798cf1a035
4
+ data.tar.gz: 6abafa02b5291e3b1aa4c36a682e4ea931ccd646
5
5
  SHA512:
6
- metadata.gz: 6555cda675dc06e1f7dab0071877c7536d8448bfed8ad74802c902461e8bfc19a0038249e1996690ef3e3f3e1fc1e0b7c276f6bd24fe8bfb147d8f042818d643
7
- data.tar.gz: 83a232520d77ae6bfb0a3fb8f4713f77b6cc52e884d5984e2fa2a69c949954c8d498c6ae26330bd97cdaca33debbc3a7528100f2a243393919ba922cee63422f
6
+ metadata.gz: d3c84160ddb908cd9f928878bed4f11c14e9691fe827f072795003e1bc97687db1c2ce33826b57a3ef64997c10bd7d4e44aa5b9d505da02bf9b0145e53511e85
7
+ data.tar.gz: e9fcbe1028267dbc7ca0d548e41d4390309e540465609eefe739a3fce064566119d72a8fc498e6174697057be2642520839f1f15227ca1e1ac09fcf7fafc0af5
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Foreman-OpenSCAP
2
2
 
3
+ [![Code Climate](https://codeclimate.com/github/OpenSCAP/foreman_openscap/badges/gpa.svg)](https://codeclimate.com/github/OpenSCAP/foreman_openscap)
4
+
3
5
  This plug-in enables automated vulnerability assessment and compliance audit
4
6
  of Foreman based infrastructure.
5
7
 
@@ -20,6 +22,83 @@ of Foreman based infrastructure.
20
22
  + Vulnerability Assessment (processing OVAL CVE streams)
21
23
  + E-mail notifications
22
24
 
25
+ ## Usage
26
+
27
+ ### Basic Concepts
28
+
29
+ There are three basic concepts (entities) in OpenSCAP plug-in: SCAP Contents, Compliance
30
+ Policies and ARF Reports.
31
+
32
+ *SCAP Content* represents SCAP DataStream XML file as defined by SCAP 1.2 standard. Datastream
33
+ file contains implementation of compliance, configuration or security baselines. Users are
34
+ advised to acquire examplary baseline by installing scap-security-guide package. DataStream
35
+ file usualy contains multiple XCCDF Profiles. Each for different security target. The content
36
+ of Datastream file can be inspected by `oscap` tool from openscap-scanner package.
37
+
38
+ ```
39
+ # yum install -y scap-security-guide openscap-scanner
40
+ # oscap info /usr/share/xml/scap/ssg/content/ssg-rhel6-ds.xml
41
+ # oscap info /usr/share/xml/scap/ssg/content/ssg-rhel7-ds.xml
42
+ ```
43
+
44
+ *Compliance Policy* is highlevel concept of a baseline applied to the infrastructure. Compliance
45
+ Policy is defined by user on web interface. User may assign following information to the Policy:
46
+ + SCAP Content
47
+ + XCCDF Profile from particular SCAP Content
48
+ + Host Groups that should comply with the policy
49
+ + Schedule - the period in which the audit shall occur
50
+
51
+ *ARF Report* is XML output of single scan occurance per single host. Asset Reporting File format
52
+ is defined by SCAP 1.2 standard. Foreman plug-in stores the ARF Reports in database for later
53
+ inspections.
54
+
55
+ ### User Interface
56
+
57
+ The most of the Foreman-OpenSCAP controls are located in the *Compliance* section under the *Host*
58
+ menu. The section contains three items as described in previous section: SCAP Contents, Compliance
59
+ Policies, ARF Reports.
60
+
61
+ ### Prerequisites before the first use
62
+
63
+ Make sure that
64
+ 1. smart_proxy_openscap and puppet-foreman_scap_client packages are installed on your proxies
65
+ 2. proxies have Foreman uri defined
66
+ ```
67
+ # echo ':foreman_url: https://foreman17.local.lan' >> /etc/foreman-proxy/settings.yml
68
+ ```
69
+ 3. foreman_scap_client puppet class is imported to your Foreman
70
+ 1. Go to Configure -> Puppet classes page
71
+ 2. Click Import button
72
+ 3. Select foreman_scap_client
73
+
74
+ ### Setting-up first compliance policy
75
+
76
+ 1. Log-in to Web Interface
77
+ 2. Create new SCAP Content
78
+ 1. Go to *Hosts -> Compliance -> SCAP contents* page
79
+ 2. Upload DataSteam file
80
+ 3. Create new Policy
81
+ 1. Go to Hosts -> Compliance -> Policies page
82
+ 2. Assign SCAP Content to Policy
83
+ 3. Select Profile from your SCAP Content
84
+ 4. Define periodic scan schedule
85
+ 5. Assign Hostgroups to the policy (hosts you want to audit should be assigned with one of the
86
+ hostgroups)
87
+ 4. Select particular hosts for compliance audit
88
+ 1. Go to *Hosts -> All hosts* page
89
+ 2. Select hosts
90
+ 3. Use *Select Action -> Assign Compliance Policy* button
91
+ 5. Make sure the DataStream file is present on the clients' file system.
92
+
93
+ At the moment, Foreman infrastructure is not able to serve a file to the clients. Hence, users
94
+ are required to distribute their DataStrem file to each client. The expected location is
95
+ defined at *Compliance Policy -> Edit* dialogue.
96
+ 6. Inspect the compliance results
97
+ 1. Go to *Hosts -> Compliance -> Reports* page
98
+ 2. Wait for ARF Reports to show-up
99
+ 3. Go to *Hosts -> Compliance -> Policies* page
100
+ 4. Click the policy link to view dashboard and trend
101
+
23
102
  ## Installation from RPMS
24
103
 
25
104
  - Install Foreman from [upstream](http://theforeman.org/)
@@ -62,20 +141,9 @@ of Foreman based infrastructure.
62
141
  # service foreman restart
63
142
  ```
64
143
 
65
- ## Usage
66
-
67
- Deploy [puppet-openscap](https://github.com/OpenSCAP/puppet-openscap) Puppet module
68
- on your client systems. Apply openscap::xccdf::foreman_audit puppet class using Foreman
69
- on your clients. The client will schedule OpenSCAP audit as requested by the Puppet
70
- class. The audit report will be then transfered from the client machine to the proxy
71
- (foreman-proxy_openscap). Then audit reports are forwarded from proxy to SCAPtimony
72
- in batches and achieved at your Foreman server.
73
-
74
- More coming, see future features above.
75
-
76
144
  ## Copyright
77
145
 
78
- Copyright (c) 2014 Red Hat, Inc.
146
+ Copyright (c) 2014--2015 Red Hat, Inc.
79
147
 
80
148
  This program is free software: you can redistribute it and/or modify
81
149
  it under the terms of the GNU General Public License as published by
@@ -0,0 +1,4 @@
1
+ $(function() {
2
+ // Not sure about this ugly hack.
3
+ $('.col-md-4 .stats-well').height($('.col-md-8 .stats-well').height() + 28);
4
+ });
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2014 Red Hat Inc.
2
+ # Copyright (c) 2014--2015 Red Hat Inc.
3
3
  #
4
4
  # This software is licensed to you under the GNU General Public License,
5
5
  # version 3 (GPLv3). There is NO WARRANTY for this software, express or
@@ -19,9 +19,45 @@ module Api
19
19
  include Api::Version2
20
20
  include Foreman::Controller::SmartProxyAuth
21
21
 
22
- add_puppetmaster_filters :create
22
+ add_smart_proxy_filters :create, :features => 'Openscap'
23
23
 
24
- api :POST, "/arf/:cname/:policy_id/:date", N_("Upload an ARF report")
24
+ before_filter :find_resource, :only => %w{show destroy}
25
+
26
+ def resource_name
27
+ 'Scaptimony::ArfReport'
28
+ end
29
+
30
+ def get_resource
31
+ instance_variable_get :"@arf_report" or raise 'no resource loaded'
32
+ end
33
+
34
+ resource_description do
35
+ resource_id 'scaptimony_arf_reports'
36
+ api_version 'v2'
37
+ api_base_url "/api/v2"
38
+ end
39
+
40
+ api :GET, '/compliance/arf_reports', N_('List Arf reports')
41
+ param_group :search_and_pagination, ::Api::V2::BaseController
42
+
43
+ def index
44
+ @arf_reports = resource_scope_for_index(:permission => :edit_compliance).includes(:arf_report_breakdown, :asset)
45
+ end
46
+
47
+ api :GET, '/compliance/arf_reports/:id', N_('Show an Arf report')
48
+ param :id, :identifier, :required => true
49
+
50
+ def show
51
+ end
52
+
53
+ api :DELETE, '/compliance/arf_reports/:id', N_('Deletes an Arf Report')
54
+ param :id, :identifier, :required => true
55
+
56
+ def destroy
57
+ process_response @arf_report.destroy
58
+ end
59
+
60
+ api :POST, "/compliance/arf/:cname/:policy_id/:date", N_("Upload an ARF report")
25
61
  param :cname, :identifier, :required => true
26
62
  param :policy_id, :identifier, :required => true
27
63
  param :date, :identifier, :required => true
@@ -43,9 +79,16 @@ module Api
43
79
  # no matter what content-encoding says. Let's pass content-type arf-bzip2
44
80
  # and move forward.
45
81
  super unless
82
+ params[:action] == 'create' and
46
83
  request.content_type.end_with? 'arf-bzip2' and
47
84
  request.env['HTTP_CONTENT_ENCODING'] == 'x-bzip2'
48
85
  end
86
+
87
+ private
88
+ def find_resource
89
+ not_found and return if params[:id].blank?
90
+ instance_variable_set("@arf_report", resource_scope.find(params[:id]))
91
+ end
49
92
  end
50
93
  end
51
94
  end
@@ -1,14 +1,7 @@
1
1
  module Api::V2
2
2
  module Compliance
3
3
  class PoliciesController < ::Api::V2::BaseController
4
- include Api::Version2
5
- include Foreman::Controller::SmartProxyAuth
6
-
7
- add_puppetmaster_filters :content
8
-
9
- before_filter :find_resource, :only => %w{content}
10
-
11
- attr_reader :detected_proxy
4
+ before_filter :find_resource, :except => %w{index create}
12
5
 
13
6
  def resource_name
14
7
  'Scaptimony::Policy'
@@ -18,35 +11,69 @@ module Api::V2
18
11
  instance_variable_get :"@policy" or raise 'no resource loaded'
19
12
  end
20
13
 
14
+ def policy_url(policy = nil)
15
+ api_policy_url(@policy)
16
+ end
17
+
21
18
  resource_description do
22
19
  resource_id 'scaptimony_policies'
23
20
  api_version 'v2'
24
21
  api_base_url "/api/v2"
25
22
  end
26
23
 
27
- api :GET, '/compliance/policies/:id/content', N_("Show a policy's SCAP content")
24
+ api :GET, '/compliance/policies', N_('List SCAP contents')
25
+ param_group :search_and_pagination, ::Api::V2::BaseController
26
+
27
+ def index
28
+ @policies = resource_scope_for_index(:permission => :edit_compliance)
29
+ end
30
+
31
+ api :GET, '/compliance/policies/:id', N_('Show an SCAP content')
28
32
  param :id, :identifier, :required => true
29
33
 
30
- def content
31
- @scap_content = @policy.scap_content
32
- send_data @scap_content.scap_file,
33
- :type => 'application/xml',
34
- :filename => @scap_content.original_filename
34
+ def show
35
+ end
36
+
37
+ def_param_group :policy do
38
+ param :policy, Hash, :required => true, :action_aware => true do
39
+ param :name, String, :required => true, :desc => N_('Policy name')
40
+ param :description, String, :desc => N_('Policy description')
41
+ param :scap_content_id, Integer, :required => true, :desc => N_('Policy scap content id')
42
+ param :scap_content_profile_id, Integer, :required => true, :desc => N_('Policy scap content profile id')
43
+ param :period, String, :required => true, :desc => N_('Policy schedule period')
44
+ param :weekday, String, :required => true, :desc => N_('Policy schedule weekday')
45
+ param :hostgroup_ids, Array, :desc => N_('Apply policy to hostgroups')
46
+ param_group :taxonomies, ::Api::V2::BaseController
47
+ end
48
+ end
49
+
50
+ api :POST, '/compliance/policies', N_('Create a policy')
51
+ param_group :policy, :as => :create
52
+
53
+ def create
54
+ @policy = Scaptimony::Policy.new(params[:policy])
55
+ process_response @policy.save
56
+ end
57
+
58
+ api :PUT, '/compliance/policies/:id', N_('Update a policy')
59
+ param :id, :identifier, :required => true
60
+ param_group :policy
61
+
62
+ def update
63
+ process_response @policy.update_attributes(params[:policy])
64
+ end
65
+
66
+ api :DELETE, '/compliance/policies/:id', N_('Deletes a policy')
67
+ param :id, :identifier, :required => true
68
+
69
+ def destroy
70
+ process_response @policy.destroy
35
71
  end
36
72
 
37
73
  private
38
74
  def find_resource
39
75
  not_found and return if params[:id].blank?
40
- instance_variable_set("@policy", Scaptimony::Policy.find(params[:id]))
41
- end
42
-
43
- def action_permission
44
- case params[:action]
45
- when 'content'
46
- :view
47
- else
48
- super
49
- end
76
+ instance_variable_set("@policy", resource_scope.find(params[:id]))
50
77
  end
51
78
  end
52
79
  end
@@ -0,0 +1,74 @@
1
+ module Api::V2
2
+ module Compliance
3
+ class ScapContentsController < ::Api::V2::BaseController
4
+ before_filter :find_resource, :except => %w{index create}
5
+
6
+ def resource_name
7
+ 'Scaptimony::ScapContent'
8
+ end
9
+
10
+ def get_resource
11
+ instance_variable_get :"@scap_content" or raise 'no resource loaded'
12
+ end
13
+
14
+ resource_description do
15
+ resource_id 'scaptimony_scap_contents'
16
+ api_version 'v2'
17
+ api_base_url "/api/v2"
18
+ end
19
+
20
+ api :GET, '/compliance/scap_contents', N_('List SCAP contents')
21
+ param_group :search_and_pagination, ::Api::V2::BaseController
22
+
23
+ def index
24
+ @scap_contents = resource_scope_for_index(:permission => :edit_compliance)
25
+ end
26
+
27
+ api :GET, '/compliance/scap_contents/:id', N_('Show an SCAP content')
28
+ param :id, :identifier, :required => true
29
+
30
+ def show
31
+ send_data @scap_content.scap_file,
32
+ :type => 'application/xml',
33
+ :filename => @scap_content.original_filename
34
+ end
35
+
36
+ def_param_group :scap_content do
37
+ param :scap_content, Hash, :required => true, :action_aware => true do
38
+ param :title, String, :required => true, :desc => N_('Scap content name')
39
+ param :scap_file, String, :required => true
40
+ param_group :taxonomies, ::Api::V2::BaseController
41
+ end
42
+ end
43
+
44
+ api :POST, '/compliance/scap_contents', N_('Create SCAP content')
45
+ param_group :scap_content, :as => :create
46
+
47
+ def create
48
+ @scap_content = Scaptimony::ScapContent.new(params[:scap_content])
49
+ process_response @scap_content.save
50
+ end
51
+
52
+ api :PUT, '/compliance/scap_contents/:id', N_('Update an SCAP content')
53
+ param :id, :identifier, :required => true
54
+ param_group :scap_content
55
+
56
+ def update
57
+ process_response @scap_content.update_attributes(params[:scap_content])
58
+ end
59
+
60
+ api :DELETE, '/compliance/scap_contents/:id', N_('Deletes an SCAP content')
61
+ param :id, :identifier, :required => true
62
+
63
+ def destroy
64
+ process_response @scap_content.destroy
65
+ end
66
+
67
+ private
68
+ def find_resource
69
+ not_found and return if params[:id].blank?
70
+ instance_variable_set("@scap_content", resource_scope.find(params[:id]))
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,5 @@
1
+ class ScaptimonyHostsController < ApplicationController
2
+ def show
3
+ @host = Host.find(params[:id])
4
+ end
5
+ end
@@ -1,7 +1,7 @@
1
1
  class ScaptimonyPoliciesController < ApplicationController
2
2
  include Foreman::Controller::AutoCompleteSearch
3
3
  before_filter :find_by_id, :only => [:show, :edit, :update, :parse, :destroy]
4
- before_filter :find_multiple, :only => [:select_multiple_hosts, :update_multiple_hosts]
4
+ before_filter :find_multiple, :only => [:select_multiple_hosts, :update_multiple_hosts, :disassociate_multiple_hosts, :remove_policy_from_multiple_hosts]
5
5
 
6
6
  def model_of_controller
7
7
  ::Scaptimony::Policy
@@ -73,7 +73,7 @@ class ScaptimonyPoliciesController < ApplicationController
73
73
  def update_multiple_hosts
74
74
  if (id = params['policy']['id'])
75
75
  policy = ::Scaptimony::Policy.find(id)
76
- policy.assign_hosts @hosts
76
+ policy.assign_hosts(@hosts)
77
77
  notice _("Updated hosts: Assigned with compliance policy: #{policy.name}")
78
78
  # We prefer to go back as this does not lose the current search
79
79
  redirect_to hosts_path
@@ -83,6 +83,20 @@ class ScaptimonyPoliciesController < ApplicationController
83
83
  end
84
84
  end
85
85
 
86
+ def disassociate_multiple_hosts; end
87
+
88
+ def remove_policy_from_multiple_hosts
89
+ if (id = params.fetch(:policy, {})[:id])
90
+ policy = ::Scaptimony::Policy.find(id)
91
+ policy.unassign_hosts(@hosts)
92
+ notice _("Updated hosts: Unassigned from compliance policy '%s'") % policy.name
93
+ redirect_to hosts_path
94
+ else
95
+ error _('No valid policy id provided')
96
+ redirect_to hosts_path
97
+ end
98
+ end
99
+
86
100
  def welcome
87
101
  @searchbar = true
88
102
  if (model_of_controller.first.nil? rescue false)
@@ -6,8 +6,39 @@ module ForemanOpenscap
6
6
  alias_method_chain :multiple_actions, :scap
7
7
  end
8
8
 
9
+ Colors = {
10
+ :passed => '#89A54E',
11
+ :failed => '#AA4643',
12
+ :othered => '#DB843D',
13
+ }
14
+
9
15
  def multiple_actions_with_scap
10
- multiple_actions_without_scap << [_('Assign Compliance Policy'), select_multiple_hosts_scaptimony_policies_path]
16
+ multiple_actions_without_scap + [[_('Assign Compliance Policy'), select_multiple_hosts_scaptimony_policies_path],
17
+ [_('Unassign Compliance Policy'), disassociate_multiple_hosts_scaptimony_policies_path]]
18
+
19
+ end
20
+
21
+ def host_policy_breakdown_chart(report, options = {})
22
+ data = []
23
+ [[:passed, _('Passed')],
24
+ [:failed, _('Failed')],
25
+ [:othered, _('Other')],
26
+ ].each { |i|
27
+ data << {:label => i[1], :data => report[i[0]], :color => Colors[i[0]]}
28
+ }
29
+ flot_pie_chart 'overview', _('Compliance reports breakdown'), data, options
30
+ end
31
+
32
+ def host_arf_reports_chart(policy_id)
33
+ passed, failed, othered, = [], [], []
34
+ @host.arf_reports.of_policy(policy_id).each do |report|
35
+ passed << [report.created_at.to_i*1000, report.passed]
36
+ failed << [report.created_at.to_i*1000, report.failed]
37
+ othered << [report.created_at.to_i*1000, report.othered]
38
+ end
39
+ [{:label => _("Passed"), :data => passed, :color => Colors[:passed]},
40
+ {:label => _("Failed"), :data => failed, :color => Colors[:failed]},
41
+ {:label => _("Othered"), :data => othered, :color => Colors[:othered]}]
11
42
  end
12
43
  end
13
44
  end
@@ -21,6 +21,7 @@ module ForemanOpenscap
21
21
 
22
22
  scope :hosts, lambda { includes(:policy, :arf_report_breakdown) }
23
23
  scope :latest, lambda { includes(:host, :policy, :arf_report_breakdown).limit(5).order("scaptimony_arf_reports.created_at DESC") }
24
+ scope :of_policy, lambda {|policy_id| {:conditions => {:policy_id => policy_id}}}
24
25
 
25
26
  scoped_search :in => :host, :on => :name, :complete_value => :true, :rename => "host"
26
27
 
@@ -26,7 +26,7 @@ module ForemanOpenscap
26
26
  end
27
27
 
28
28
  def combined_policies
29
- combined = self.hostgroup ? self.policies + self.hostgroup.policies : self.policies
29
+ combined = self.policies + self.hostgroup.policies
30
30
  combined.uniq
31
31
  end
32
32
 
@@ -129,12 +129,16 @@ module ForemanOpenscap
129
129
  assign_assets hosts.map &:get_asset
130
130
  end
131
131
 
132
+ def unassign_hosts(hosts)
133
+ host_asset_ids = Scaptimony::Asset.where(:assetable_type => 'Host::Base', :assetable_id => hosts.map(&:id)).pluck(:id)
134
+ self.asset_ids = self.asset_ids - host_asset_ids
135
+ end
136
+
132
137
  def to_enc
133
138
  {
134
139
  'id' => self.id,
135
140
  'profile_id' => self.scap_content_profile.try(:profile_id) || '',
136
141
  'content_path' => "/var/lib/openscap/content/#{self.scap_content.digest}.xml",
137
- 'download_path' => "/compliance/policies/#{self.id}/content" # default to proxy path
138
142
  }.merge(period_enc)
139
143
  end
140
144
 
@@ -0,0 +1,4 @@
1
+ Deface::Override.new(:virtual_path => "hosts/_overview",
2
+ :name => "add_compliance_check",
3
+ :insert_after => "#properties_table",
4
+ :partial => "scaptimony_hosts/host_status")
@@ -0,0 +1,38 @@
1
+ module Scaptimony::HostReportDashboard
2
+ class Data
3
+ attr_reader :report
4
+
5
+ def initialize(policy_id, asset_id)
6
+ @latest_report = Scaptimony::ArfReport.where(:asset_id => asset_id, :policy_id => policy_id).order('created_at DESC').limit(1).first
7
+ @report = {}
8
+ fetch_data
9
+ end
10
+
11
+ private
12
+ attr_writer :report
13
+ attr_accessor :latest_report
14
+
15
+ def fetch_data
16
+ report.update(
17
+ {
18
+ :passed => report_passed,
19
+ :failed => report_failed,
20
+ :othered => report_othered
21
+ }
22
+ )
23
+ end
24
+
25
+ def report_passed
26
+ @latest_report.passed
27
+ end
28
+
29
+ def report_failed
30
+ @latest_report.failed
31
+ end
32
+
33
+ def report_othered
34
+ @latest_report.othered
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,4 @@
1
+ object @arf_report
2
+
3
+ attributes :id, :passed, :failed, :othered
4
+ node(:host) { |arf_report| arf_report.host.name }
@@ -0,0 +1,2 @@
1
+ collection @arf_reports
2
+ extends "api/v2/compliance/arf_reports/main"
@@ -0,0 +1,5 @@
1
+ object @arf_report
2
+
3
+ extends "api/v2/compliance/arf_reports/base"
4
+
5
+ attributes :created_at, :updated_at
@@ -0,0 +1,3 @@
1
+ object @arf_report
2
+
3
+ extends "api/v2/compliance/arf_reports/main"
@@ -0,0 +1,3 @@
1
+ object @policy
2
+
3
+ attributes :id, :name, :period, :weekday, :description, :scap_content_id, :scap_content_profile_id, :day_of_month, :cron_line
@@ -0,0 +1,3 @@
1
+ collection @policies
2
+
3
+ extends "api/v2/compliance/policies/main"
@@ -0,0 +1,5 @@
1
+ object @policy
2
+
3
+ extends "api/v2/compliance/policies/base"
4
+
5
+ attributes :created_at, :updated_at
@@ -0,0 +1,3 @@
1
+ object @policy
2
+
3
+ extends "api/v2/compliance/policies/main"
@@ -0,0 +1,3 @@
1
+ object @scap_content
2
+
3
+ attributes :id, :title, :original_filename, :digest
@@ -0,0 +1,3 @@
1
+ collection @scap_contents
2
+
3
+ extends "api/v2/compliance/scap_contents/main"
@@ -0,0 +1,5 @@
1
+ object @scap_content
2
+
3
+ extends "api/v2/compliance/scap_contents/base"
4
+
5
+ attributes :created_at, :updated_at
@@ -0,0 +1 @@
1
+ object @scap_content
@@ -13,7 +13,7 @@
13
13
  </tr>
14
14
  <% latest_reports.each do |report| %>
15
15
  <tr>
16
- <td><%= link_to h(report.host.nil? ? _('Host does not exist anymore') : report.host.name), scaptimony_arf_report_path(report) %></td>
16
+ <td><%= link_to h(report.host.name), scaptimony_arf_report_path(report) %></td>
17
17
  <td><%= link_to h(report.policy.name), scaptimony_policy_dashboard_scaptimony_policy_path(report.policy) %></td>
18
18
  <td><%= report_event_column(report.passed, "label-success") %></td>
19
19
  <td><%= report_event_column(report.failed, "label-danger") %></td>
@@ -9,7 +9,7 @@
9
9
  </tr>
10
10
  <% for arf_report in @arf_reports %>
11
11
  <tr>
12
- <td><%= arf_report.host.nil? ? _('Host does not exist anymore') : name_column(arf_report.host) %></td>
12
+ <td><%= name_column(arf_report.host) %></td>
13
13
  <td><%= _("%s ago") % time_ago_in_words(arf_report.date) %></td>
14
14
  <td><%= report_arf_column(arf_report.passed, "label-info") %></th>
15
15
  <td><%= report_arf_column(arf_report.failed, "label-danger") %></th>
@@ -0,0 +1,17 @@
1
+ <% if host.arf_reports.any? %>
2
+ <table class="table table-bordered table-striped" id="compliance">
3
+ <tr>
4
+ <th colspan="2"><%= _('Compliance Properties') %></th>
5
+ </tr>
6
+ <tr>
7
+ <td><%= _('Compliance') %></td>
8
+ <td>
9
+ <% if host.arf_reports.search_for('failed > 0').blank? %>
10
+ <%= link_to(report_event_column('O', "label-success"), scaptimony_host_path(host.id)) %>
11
+ <% else %>
12
+ <%= link_to(report_event_column('F', "label-danger"), scaptimony_host_path(host.id)) %>
13
+ <% end %>
14
+ </td>
15
+ </tr>
16
+ </table>
17
+ <% end %>
@@ -0,0 +1,23 @@
1
+ <%= javascript 'dashboard', 'foreman_openscap/scap_hosts_show' %>
2
+
3
+ <% title _("%s compliance reports by policy") % @host.to_label %>
4
+ <% @host.policies.each do |policy| %>
5
+ <h2 class="center-block"><%= _('Policy %s') % policy %></h2>
6
+ <div class="row">
7
+ <div class="col-md-4">
8
+ <div class="stats-well">
9
+ <h4 class="header ca"><%= _('%s latest report') % policy.name %></h4>
10
+ <% report = Scaptimony::HostReportDashboard::Data.new(policy.id, @host.asset.id).report %>
11
+ <%= host_policy_breakdown_chart(report, :class => 'statistics-pie small') %>
12
+ </div>
13
+ </div>
14
+
15
+ <div class="col-md-8">
16
+ <div class="stats-well">
17
+ <h4 class="ca"><%= _("%s reports over time") % policy %></h4>
18
+ <%= flot_chart('resource_graph', '', '', host_arf_reports_chart(policy.id)) %>
19
+ </div>
20
+ </div>
21
+ </div>
22
+ <hr style="border: 1px solid #eeeeee"/>
23
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <%= render 'hosts/selected_hosts', :hosts => @hosts %>
2
+ <%= form_for :policy,
3
+ :url => remove_policy_from_multiple_hosts_scaptimony_policies_path(:host_ids => params[:host_ids]) do |f| %>
4
+ <%= selectable_f f, :id, [[_('Select Compliance Policy'), 'disabled'],
5
+ ] + Scaptimony::Policy.all.map{|e| [e.name, e.id]},{},
6
+ :onchange => 'toggle_multiple_ok_button(this)' %>
7
+ <% end %>
data/config/routes.rb CHANGED
@@ -22,6 +22,8 @@ Rails.application.routes.draw do
22
22
  post 'scap_content_selected'
23
23
  get 'select_multiple_hosts'
24
24
  post 'update_multiple_hosts'
25
+ get 'disassociate_multiple_hosts'
26
+ post 'remove_policy_from_multiple_hosts'
25
27
  end
26
28
  end
27
29
  resources :scap_contents,
@@ -30,16 +32,18 @@ Rails.application.routes.draw do
30
32
  get 'auto_complete_search'
31
33
  end
32
34
  end
35
+ resources :hosts, :only => [:show], :as => :scaptimony_hosts, :controller => :scaptimony_hosts
33
36
  end
34
37
 
35
38
  namespace :api do
36
39
  scope "(:apiv)", :module => :v2, :defaults => {:apiv => 'v2'},
37
40
  :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2) do
38
41
  namespace :compliance do
42
+ resources :scap_contents, :except => [:new, :edit]
43
+ resources :policies, :except => [:new, :edit]
44
+ resources :arf_reports, :only => [:index, :show, :destroy]
39
45
  post 'arf_reports/:cname/:policy_id/:date', \
40
46
  :constraints => { :cname => /[^\/]+/ }, :to => 'arf_reports#create'
41
-
42
- get 'policies/:id/content', :to => 'policies#content'
43
47
  end
44
48
  end
45
49
  end
@@ -19,6 +19,7 @@ module ForemanOpenscap
19
19
  app.config.assets.precompile += %w(
20
20
  'foreman_openscap/policy_edit.js',
21
21
  'foreman_openscap/period_selector.js',
22
+ 'foreman_openscap/scap_hosts_show.js',
22
23
  'foreman_openscap/policy.css'
23
24
  )
24
25
  end
@@ -27,6 +28,7 @@ module ForemanOpenscap
27
28
  SETTINGS[:foreman_openscap] =
28
29
  {:assets => {:precompile => ['foreman_openscap/policy_edit.js',
29
30
  'foreman_openscap/period_selector.js',
31
+ 'foreman_openscap/scap_hosts_show.js',
30
32
  'foreman_openscap/policy.css']}}
31
33
  end
32
34
 
@@ -1,3 +1,3 @@
1
1
  module ForemanOpenscap
2
- VERSION = "0.3.4"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -0,0 +1,10 @@
1
+ FactoryGirl.define do
2
+ factory :arf_report, :class => Scaptimony::ArfReport do |f|
3
+ f.asset
4
+ f.policy
5
+ f.sequence :digest do |n|
6
+ "#{n}#{n}#{n}aabbcc#{n}3322dd"
7
+ end
8
+ date '1973-01-13'
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :asset, :class => Scaptimony::Asset do |f|
3
+ f.assetable_id FactoryGirl.create(:host).id
4
+ f.assetable_type 'Host::Base'
5
+ end
6
+ end
@@ -8,5 +8,4 @@ FactoryGirl.define do
8
8
  day_of_month '1'
9
9
  cron_line '* * * * 30'
10
10
  end
11
- end
12
-
11
+ end
@@ -13,4 +13,3 @@ FactoryGirl.define do
13
13
  f.title 'test Profile for testing'
14
14
  end
15
15
  end
16
-
@@ -5617,31 +5617,4 @@ To verify insecure file locking has been disabled, run the following command:
5617
5617
  <external_variable comment="maximum password age" datatype="int" id="oval:ssg:var:282" version="1"/>
5618
5618
  <external_variable comment="timeout value" datatype="int" id="oval:ssg:var:283" version="1"/>
5619
5619
  </variables>
5620
- </oval_definitions></ds:component></ds:data-stream-collection>
5621
-
5622
-
5623
-
5624
-
5625
-
5626
-
5627
-
5628
-
5629
-
5630
-
5631
-
5632
-
5633
-
5634
-
5635
-
5636
-
5637
-
5638
-
5639
-
5640
-
5641
-
5642
-
5643
-
5644
-
5645
-
5646
-
5647
-
5620
+ </oval_definitions></ds:component></ds:data-stream-collection>
@@ -0,0 +1,24 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class Api::V2::ArfReportsControllerTest < ActionController::TestCase
4
+ setup do
5
+ # override validation of policy (puppetclass, lookup_key overrides)
6
+ Scaptimony::Policy.any_instance.stubs(:valid?).returns(true)
7
+ end
8
+ test "should get index" do
9
+ FactoryGirl.create(:arf_report)
10
+ get :index, {}, set_session_user
11
+ response = ActiveSupport::JSON.decode(@response.body)
12
+ assert_not response['results'].empty?
13
+ assert_response :success
14
+ end
15
+
16
+ test "should get show" do
17
+ get :show, { :id => FactoryGirl.create(:arf_report).to_param }, set_session_user
18
+ response = ActiveSupport::JSON.decode(@response.body)
19
+ refute response['passed'].blank?
20
+ refute response['failed'].blank?
21
+ refute response['othered'].blank?
22
+ assert_response :success
23
+ end
24
+ end
@@ -0,0 +1,58 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class Api::V2::PoliciesControllerTest < ActionController::TestCase
4
+ setup do
5
+ Scaptimony::Policy.any_instance.stubs(:ensure_needed_puppetclasses).returns(true)
6
+ end
7
+
8
+ test "should get index" do
9
+ FactoryGirl.create(:policy)
10
+ get :index, {}, set_session_user
11
+ response = ActiveSupport::JSON.decode(@response.body)
12
+ assert response['results'].length > 0
13
+ assert_response :success
14
+ end
15
+
16
+ test "should show a policy" do
17
+ policy = FactoryGirl.create(:policy)
18
+ get :show, { :id => policy.to_param }, set_session_user
19
+ response = ActiveSupport::JSON.decode(@response.body)
20
+ assert response['name'], policy.name
21
+ assert_response :success
22
+ end
23
+
24
+ test "should update a policy" do
25
+ policy = FactoryGirl.create(:policy)
26
+ put :update, {:id => policy.id, :policy => {:period => 'monthly'}}
27
+ updated_policy = ActiveSupport::JSON.decode(@response.body)
28
+ assert(updated_policy['period'], 'monthly')
29
+ assert_response :ok
30
+ end
31
+
32
+ test "should not update invalid" do
33
+ policy = FactoryGirl.create(:policy)
34
+ put :update, {:id => policy.id, :policy => {:name => 'say my name'}}
35
+ assert_response :unprocessable_entity
36
+ end
37
+
38
+ test "should create a policy" do
39
+ scap_content_profile = FactoryGirl.create(:scap_content_profile)
40
+ attributes = {:policy => {:name => 'my_policy', :scap_content_profile_id => scap_content_profile.id, :scap_content_id => scap_content_profile.scap_content_id}}
41
+ post :create, attributes, set_session_user
42
+ response = ActiveSupport::JSON.decode(@response.body)
43
+ assert response['scap_content_profile_id'], scap_content_profile.to_param
44
+ assert_response :created
45
+ end
46
+
47
+ test "should not create invalid policy" do
48
+ post :create, {}, set_session_user
49
+ assert_response :unprocessable_entity
50
+ end
51
+
52
+ test "should destroy" do
53
+ policy = FactoryGirl.create(:policy)
54
+ delete :destroy, { :id => policy.id }, set_session_user
55
+ assert_response :ok
56
+ refute Scaptimony::Policy.exists?(policy.id)
57
+ end
58
+ end
@@ -0,0 +1,49 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class Api::V2::ScapContentsControllerTest < ActionController::TestCase
4
+
5
+ test "should get index" do
6
+ FactoryGirl.create(:scap_content)
7
+ get :index, {}, set_session_user
8
+ response = ActiveSupport::JSON.decode(@response.body)
9
+ assert response['results'].any?
10
+ assert_response :success
11
+ end
12
+
13
+ test "should return xml of scap content" do
14
+ scap_content = FactoryGirl.create(:scap_content)
15
+ get :show, { :id => scap_content.id }, set_session_user
16
+ assert(@response.header['Content-Type'], 'application/xml')
17
+ assert_response :success
18
+ end
19
+
20
+ test "should create invalid scap content" do
21
+ post :create, {}, set_session_user
22
+ assert_response :unprocessable_entity
23
+ end
24
+
25
+ test "should create scap content" do
26
+ # Skipped as API does not support uploading files
27
+ skip
28
+ end
29
+
30
+ test "should update scap content" do
31
+ scap_content = FactoryGirl.create(:scap_content)
32
+ put :update, { :id => scap_content.id, :scap_content => {:title => 'RHEL7 SCAP'}}, set_session_user
33
+ assert_response :success
34
+ assert scap_content.title, 'RHEL7 SCAP'
35
+ end
36
+
37
+ test "should not update invalid scap content" do
38
+ scap_content = FactoryGirl.create(:scap_content)
39
+ put :update, { :id => scap_content.id, :scap_content => {:scap_file => '<xml>blah</xml>'}}, set_session_user
40
+ assert_response :unprocessable_entity
41
+ end
42
+
43
+ test "should destory scap content" do
44
+ scap_content = FactoryGirl.create(:scap_content)
45
+ delete :destroy, { :id => scap_content.id }, set_session_user
46
+ assert_response :ok
47
+ refute Scaptimony::ScapContent.exists?(scap_content.id)
48
+ end
49
+ 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.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Šimon Lukašík"
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-07 00:00:00.000000000 Z
11
+ date: 2015-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -47,14 +47,16 @@ extra_rdoc_files: []
47
47
  files:
48
48
  - LICENSE
49
49
  - README.md
50
- - Rakefile
51
50
  - app/assets/javascript/foreman_openscap/period_selector.js
52
51
  - app/assets/javascript/foreman_openscap/policy_edit.js
52
+ - app/assets/javascript/foreman_openscap/scap_hosts_show.js
53
53
  - app/assets/stylesheets/foreman_openscap/policy.css.scss
54
54
  - app/controllers/api/v2/compliance/arf_reports_controller.rb
55
55
  - app/controllers/api/v2/compliance/policies_controller.rb
56
+ - app/controllers/api/v2/compliance/scap_contents_controller.rb
56
57
  - app/controllers/scaptimony_arf_reports_controller.rb
57
58
  - app/controllers/scaptimony_dashboard_controller.rb
59
+ - app/controllers/scaptimony_hosts_controller.rb
58
60
  - app/controllers/scaptimony_policies_controller.rb
59
61
  - app/controllers/scaptimony_policy_dashboard_controller.rb
60
62
  - app/controllers/scaptimony_scap_contents_controller.rb
@@ -70,20 +72,37 @@ files:
70
72
  - app/models/concerns/foreman_openscap/policy_extensions.rb
71
73
  - app/models/concerns/foreman_openscap/scap_content_extensions.rb
72
74
  - app/overrides/hosts/index/host_arf_report.rb
75
+ - app/overrides/hosts/overview/host_compliance_status.rb
76
+ - app/services/scaptimony/host_report_dashboard/data.rb
73
77
  - app/services/scaptimony/policy_dashboard/data.rb
74
78
  - app/services/scaptimony/policy_dashboard/loader.rb
75
79
  - app/services/scaptimony/policy_dashboard/manager.rb
76
80
  - app/services/scaptimony/report_dashboard/data.rb
81
+ - app/views/api/v2/compliance/arf_reports/base.json.rabl
82
+ - app/views/api/v2/compliance/arf_reports/index.json.rabl
83
+ - app/views/api/v2/compliance/arf_reports/main.json.rabl
84
+ - app/views/api/v2/compliance/arf_reports/show.json.rabl
85
+ - app/views/api/v2/compliance/policies/base.json.rabl
86
+ - app/views/api/v2/compliance/policies/index.json.rabl
87
+ - app/views/api/v2/compliance/policies/main.json.rabl
88
+ - app/views/api/v2/compliance/policies/show.json.rabl
89
+ - app/views/api/v2/compliance/scap_contents/base.json.rabl
90
+ - app/views/api/v2/compliance/scap_contents/index.json.rabl
91
+ - app/views/api/v2/compliance/scap_contents/main.json.rabl
92
+ - app/views/api/v2/compliance/scap_contents/show.json.rabl
77
93
  - app/views/dashboard/_foreman_openscap_host_reports_widget.html.erb
78
94
  - app/views/dashboard/_foreman_openscap_reports_breakdown_widget.html.erb
79
95
  - app/views/scaptimony_arf_reports/_host_report.html.erb
80
96
  - app/views/scaptimony_arf_reports/_list.html.erb
81
97
  - app/views/scaptimony_arf_reports/index.html.erb
82
98
  - app/views/scaptimony_arf_reports/show.html.erb
99
+ - app/views/scaptimony_hosts/_host_status.html.erb
100
+ - app/views/scaptimony_hosts/show.html.erb
83
101
  - app/views/scaptimony_policies/_form.html.erb
84
102
  - app/views/scaptimony_policies/_list.html.erb
85
103
  - app/views/scaptimony_policies/_scap_content_results.html.erb
86
104
  - app/views/scaptimony_policies/create.html.erb
105
+ - app/views/scaptimony_policies/disassociate_multiple_hosts.html.erb
87
106
  - app/views/scaptimony_policies/edit.html.erb
88
107
  - app/views/scaptimony_policies/index.html.erb
89
108
  - app/views/scaptimony_policies/new.html.erb
@@ -114,11 +133,14 @@ files:
114
133
  - lib/foreman_openscap/helper.rb
115
134
  - lib/foreman_openscap/version.rb
116
135
  - lib/tasks/foreman_openscap_tasks.rake
117
- - test/factories/foreman_openscap_factories.rb
136
+ - test/factories/arf_report_factory.rb
137
+ - test/factories/asset_factory.rb
118
138
  - test/factories/policy_factory.rb
119
139
  - test/factories/scap_content_related.rb
120
140
  - test/files/scap_contents/ssg-fedora-ds.xml
121
- - test/functional/api/v2/compliance/policies_controller_test.rb
141
+ - test/functional/api/v2/arf_reports_controller_test.rb
142
+ - test/functional/api/v2/policies_controller_test.rb
143
+ - test/functional/api/v2/scap_contents_controller_test.rb
122
144
  - test/test_plugin_helper.rb
123
145
  - test/unit/openscap_host_test.rb
124
146
  homepage: https://github.com/OpenSCAP/foreman_openscap
@@ -149,8 +171,11 @@ test_files:
149
171
  - test/unit/openscap_host_test.rb
150
172
  - test/test_plugin_helper.rb
151
173
  - test/files/scap_contents/ssg-fedora-ds.xml
152
- - test/functional/api/v2/compliance/policies_controller_test.rb
174
+ - test/functional/api/v2/arf_reports_controller_test.rb
175
+ - test/functional/api/v2/scap_contents_controller_test.rb
176
+ - test/functional/api/v2/policies_controller_test.rb
177
+ - test/factories/asset_factory.rb
153
178
  - test/factories/policy_factory.rb
154
179
  - test/factories/scap_content_related.rb
155
- - test/factories/foreman_openscap_factories.rb
180
+ - test/factories/arf_report_factory.rb
156
181
  has_rdoc:
data/Rakefile DELETED
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env rake
2
- begin
3
- require 'bundler/setup'
4
- rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
- end
7
- begin
8
- require 'rdoc/task'
9
- rescue LoadError
10
- require 'rdoc/rdoc'
11
- require 'rake/rdoctask'
12
- RDoc::Task = Rake::RDocTask
13
- end
14
-
15
- RDoc::Task.new(:rdoc) do |rdoc|
16
- rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = 'ForemanOpenscap'
18
- rdoc.options << '--line-numbers'
19
- rdoc.rdoc_files.include('README.rdoc')
20
- rdoc.rdoc_files.include('lib/**/*.rb')
21
- end
22
-
23
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
- load 'rails/tasks/engine.rake'
25
-
26
-
27
-
28
- Bundler::GemHelper.install_tasks
29
-
30
- require 'rake/testtask'
31
-
32
- Rake::TestTask.new(:test) do |t|
33
- t.libs << 'lib'
34
- t.libs << 'test'
35
- t.pattern = 'test/**/*_test.rb'
36
- t.verbose = false
37
- end
38
-
39
-
40
- task :default => :test
@@ -1,5 +0,0 @@
1
- # FactoryGirl.define do
2
- # factory :host do
3
- # name 'foreman_openscap'
4
- # end
5
- # end
@@ -1,14 +0,0 @@
1
- require 'test_plugin_helper'
2
-
3
- class Api::V2::Compliance::PoliciesControllerTest < ActionController::TestCase
4
- setup do
5
- Scaptimony::Policy.any_instance.stubs(:ensure_needed_puppetclasses).returns(true)
6
- end
7
-
8
- test "should return xml of scap content" do
9
- policy = FactoryGirl.create(:policy)
10
- get :content, { :id => policy.id }, set_session_user
11
- assert(@response.header['Content-Type'], 'application/xml')
12
- assert_response :success
13
- end
14
- end