simp-beaker-helpers 1.15.1 → 1.15.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94c82000c46c2d7aea58c330826814c2836ce2cf275c115e4423372b7b5365b0
4
- data.tar.gz: e99f777227c80738917ae29133b3937a838b7299d26e111032061cc3e4dda9f3
3
+ metadata.gz: 30ef05fd3ec301d3aa104b886c6e3ed8946dc6cecd0cabf3177191425eca6e1e
4
+ data.tar.gz: 717e4661e75865f9be5d623b7609aec88a1791fa4ab5bf772d63773b77da30ab
5
5
  SHA512:
6
- metadata.gz: a90a968d0050489f711ada9be6aa1db3dd3a25c65b2825107c511ace7c4a66d7d30326ee7163d225555a92dcdf21fb3e4e41985a0b926b27dec5e278a30f1c31
7
- data.tar.gz: 0b44843331c79bd05305e5bf59ae0a600ae1e999c163c35a544c22118fba0631e9b933d77234e1e40761d7f67fa573787330d6e230728ff00febdcef11b9548d
6
+ metadata.gz: f971e19851625ec8d4c4db64b7458a50b144ffc103e20b0649b6b4e3c3497a46076b42abf5253bb2d82d5d41c43b82acbe84699e234c489605a7cbd2f6299444
7
+ data.tar.gz: 8e33acde2f3be6e75b52e5884eb48afce050a5d585bb34d73a1b6d782cbf2212e169a5d54c810fce36876e8d5259b49488d53829190c30af6f5e3ae44186afad
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ### 1.15.2 / 2019-09-13
2
+ * Fix an issue where the inspec reports were not processed properly
3
+
1
4
  ### 1.15.1 / 2019-08-26
2
5
  * Ensure that any user on the SUT can use the RedHat entitlements
3
6
 
data/README.md CHANGED
@@ -44,6 +44,7 @@ Methods to assist beaker acceptance tests for SIMP.
44
44
  * [PUPPET_VERSION](#puppet_version)
45
45
  * [BEAKER_RHSM_USER](#beaker_rhsm_user)
46
46
  * [BEAKER_RHSM_PASS](#beaker_rhsm_pass)
47
+ * [BEAKER_inspec_version](#beaker_inspec_version)
47
48
  * [Examples](#examples)
48
49
  * [Prep OS, Generate and copy PKI certs to each SUT](#prep-os-generate-and-copy-pki-certs-to-each-sut)
49
50
  * [Specify the version of Puppet to run in the SUTs](#specify-the-version-of-puppet-to-run-in-the-suts)
@@ -400,6 +401,13 @@ Will not be output to the screen.
400
401
  Note: When using Subscription Manager, make sure your nodeset has the setting validation: false. Otherwise Beaker:Rspec
401
402
  might try to install packages before subscription manager is configured.
402
403
 
404
+ #### BEAKER_inspec_version
405
+
406
+ The version of InSpec to use when running inspec tests. Currently hard-coded to
407
+ `4.16.14` due to a bug introduced in `4.16.15`.
408
+
409
+ Let to 'latest' to use the latest available in the upstream repos.
410
+
403
411
  ## Examples
404
412
 
405
413
  ### Prep OS, Generate and copy PKI certs to each SUT
@@ -19,9 +19,17 @@ module Simp::BeakerHelpers
19
19
  # The name of the profile against which to run
20
20
  #
21
21
  def initialize(sut, profile)
22
+ @inspec_version = ENV['BEAKER_inspec_version'] || '4.16.14'
23
+
22
24
  @sut = sut
23
25
 
24
- @sut.install_package('inspec')
26
+ @sut.install_package('git')
27
+
28
+ if @inspec_version == 'latest'
29
+ @sut.install_package('inspec')
30
+ else
31
+ @sut.install_package("inspec-#{@inspec_version}")
32
+ end
25
33
 
26
34
  os = fact_on(@sut, 'operatingsystem')
27
35
  os_rel = fact_on(@sut, 'operatingsystemmajrelease')
@@ -179,6 +187,9 @@ module Simp::BeakerHelpers
179
187
  end
180
188
 
181
189
  if !profiles || profiles.empty?
190
+ require 'pry'
191
+ binding.pry
192
+
182
193
  fail("Error: Could not find 'profiles' in the passed results")
183
194
  end
184
195
 
@@ -196,31 +207,59 @@ module Simp::BeakerHelpers
196
207
 
197
208
  next unless title
198
209
 
199
- stats[:profiles][profile_name][:controls][title] = {}
210
+ base_title = title.scan(/.{1,60}\W|.{1,60}/).map(&:strip).join("\n ")
200
211
 
201
- formatted_title = title.scan(/.{1,72}\W|.{1,72}/).map(&:strip).join("\n ")
212
+ if control['results'] && (control['results'].size > 1)
213
+ control['results'].each do |result|
214
+ control_title = " => { #{result['code_desc']} }"
202
215
 
203
- stats[:profiles][profile_name][:controls][title][:formatted_title] = formatted_title
216
+ full_title = title + control_title
217
+ formatted_title = base_title + control_title
204
218
 
205
- if control['results'] && !control['results'].empty?
206
- status = control['results'].first['status']
219
+ stats[:profiles][profile_name][:controls][full_title] = {}
207
220
 
208
- if status == /^fail/
209
- status = :failed
210
- color = 'red'
211
- else
221
+ stats[:profiles][profile_name][:controls][full_title][:formatted_title] = formatted_title
222
+
223
+ if result['status'] =~ /^fail/
224
+ status = :failed
225
+ color = 'red'
226
+ else
227
+ status = :passed
228
+ color = 'green'
229
+ end
230
+
231
+ stats[:global][status] << formatted_title.color
232
+
233
+ stats[:profiles][profile_name][:controls][full_title][:status] = status
234
+ stats[:profiles][profile_name][:controls][full_title][:source] = control['source_location']['ref']
235
+ end
236
+ else
237
+ formatted_title = base_title
238
+
239
+ stats[:profiles][profile_name][:controls][title] = {}
240
+
241
+ stats[:profiles][profile_name][:controls][title][:formatted_title] = formatted_title
242
+
243
+ if control['results'] && !control['results'].empty?
212
244
  status = :passed
213
245
  color = 'green'
246
+
247
+ control['results'].each do |result|
248
+ if results['status'] =~ /^fail/
249
+ status = :failed
250
+ color = 'red'
251
+ end
252
+ end
253
+
254
+ else
255
+ status = :skipped
214
256
  end
215
- else
216
- status = :skipped
217
- color = 'yellow'
218
- end
219
257
 
220
- stats[:global][status] << title.to_s.color
258
+ stats[:global][status] << formatted_title.color
221
259
 
222
- stats[:profiles][profile_name][:controls][title][:status] = status
223
- stats[:profiles][profile_name][:controls][title][:source] = control['source_location']['ref']
260
+ stats[:profiles][profile_name][:controls][title][:status] = status
261
+ stats[:profiles][profile_name][:controls][title][:source] = control['source_location']['ref']
262
+ end
224
263
  end
225
264
  end
226
265
 
@@ -1,5 +1,5 @@
1
1
  module Simp; end
2
2
 
3
3
  module Simp::BeakerHelpers
4
- VERSION = '1.15.1'
4
+ VERSION = '1.15.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simp-beaker-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.1
4
+ version: 1.15.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Tessmer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-08-27 00:00:00.000000000 Z
12
+ date: 2019-09-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beaker