simp-beaker-helpers 1.12.1 → 1.13.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f08b36ddb74853e6b412100826f8ff3861bc9167a7fefb19846242adc0c8cb9a
4
- data.tar.gz: 410c4055452b3fd33bb9f3fdc3182e7b4eff62a6c952db740957c244b40265c0
3
+ metadata.gz: b9229a2699ed6767059dee0f1b835dece7284420aabc219a0f195f6b9d0d0622
4
+ data.tar.gz: 99f9de96732cd0e07f02fc29c1af20fc6390bf67a55d22046eb93f836b8a377c
5
5
  SHA512:
6
- metadata.gz: 6057883981b6554084ede31a5a718651fceedaee87a4bfc94f5c6e77c3580cbf4e5bb2f5da5ffb9831cbc5d3fe143849de6dab9ec5278e7352e27dd9148f12a6
7
- data.tar.gz: c9cf815d91e0c3e750bdc4046c160ec7fb492181accf2f95230f15b29dd123b0f79eff396b8e694c9e1bc47360bd82e099da9cd72992beebebb24e6f3f6d1616
6
+ metadata.gz: 2289cd0e1bff87e03cad29ee5f36d0f609b2ee2d0ccdff5101a22e5df5ba26a21b44e79d9bb228607d670e51a6c55dfad57d149179844cece4edbfdfc46fcbd7
7
+ data.tar.gz: 84557eec4604ec94fec37c4a47415fdba716ccbc5c2c7d92f5d6f1e87f63774c9a6004006541aa58ed8f441ca3e8a86094c2892d90d3716b1a173e21bde1302f
data/.gitlab-ci.yml CHANGED
@@ -1,120 +1,166 @@
1
1
  ---
2
- #=======================================================================
3
- # Global stuff
2
+ .cache_bundler: &cache_bundler
3
+ cache:
4
+ untracked: true
5
+ # A broad attempt at caching between runs (ala Travis CI)
6
+ key: "${CI_PROJECT_NAMESPACE}__bundler"
7
+ paths:
8
+ - '.vendor'
9
+ - 'vendor'
10
+
11
+ .setup_bundler_env: &setup_bundler_env
12
+ before_script:
13
+ - 'echo Files in cache: $(find .vendor | wc -l) || :'
14
+ - 'export GEM_HOME=.vendor/gem_install'
15
+ - 'export BUNDLE_CACHE_PATH=.vendor/bundler'
16
+ - 'declare GEM_BUNDLER_VER=(-v ''~> ${BUNDLER_VERSION:-1.16.0}'')'
17
+ - declare GEM_INSTALL=(gem install --no-document)
18
+ - declare BUNDLER_INSTALL=(bundle install --no-binstubs --jobs $(nproc) --path=.vendor "${FLAGS[@]}")
19
+ - gem list -ie "${GEM_BUNDLE_VER[@]}" --silent bundler || "${GEM_INSTALL[@]}" --local "${GEM_BUNDLE_VER[@]}" bundler || "${GEM_INSTALL[@]}" "${GEM_BUNDLE_VER[@]}" bundler
20
+ - 'rm -rf pkg/ || :'
21
+ - bundle check || rm -f Gemfile.lock && ("${BUNDLER_INSTALL[@]}" --local || "${BUNDLER_INSTALL[@]}")
22
+
23
+
24
+ .validation_checks: &validation_checks
25
+ script:
26
+ - bundle exec rake syntax
27
+ - bundle exec rake check:dot_underscore
28
+ - bundle exec rake check:test_file
29
+ - bundle exec rake lint
30
+ # - bundle exec rake pkg:check_version
31
+ # - bundle exec rake pkg:compare_latest_tag
32
+
33
+ .spec_tests: &spec_tests
34
+ script:
35
+ - bundle exec rake spec
36
+
37
+ # To avoid running a prohibitive number of tests every commit,
38
+ # don't set this env var in your gitlab instance
39
+ .only_with_SIMP_FULL_MATRIX: &only_with_SIMP_FULL_MATRIX
40
+ only:
41
+ variables:
42
+ - $SIMP_FULL_MATRIX
43
+
4
44
  stages:
5
- - sanity
45
+ - validation
6
46
  - unit
7
- - lint
8
47
  - acceptance
48
+ - deploy
49
+
50
+ # Puppet 4.10 for PE 2017.2 support (EOL:2018-02-21)
51
+ # See: https://puppet.com/misc/puppet-enterprise-lifecycle
52
+ # --------------------------------------
53
+ 2_1-validation:
54
+ stage: validation
55
+ tags:
56
+ - docker
57
+ image: ruby:2.1
58
+ <<: *cache_bundler
59
+ <<: *setup_bundler_env
60
+ <<: *validation_checks
9
61
 
10
- # Default versions are set only as fallbacks for jobs that don't care which
11
- # version they use. Versions should be explicitly set in any job with specific
12
- # version requirements, even if they match these defaults.
13
- image: 'ruby:2.4'
62
+ 2_1-unit:
63
+ stage: unit
64
+ tags:
65
+ - docker
66
+ image: ruby:2.1
67
+ <<: *cache_bundler
68
+ <<: *setup_bundler_env
69
+ <<: *spec_tests
14
70
 
15
- cache:
16
- key: '${CI_COMMIT_REF_SLUG}'
17
- paths:
18
- - 'vendor/ruby'
71
+ # Puppet 4.10 for PE 2017.2 support (EOL:2018-02-21)
72
+ # See: https://puppet.com/misc/puppet-enterprise-lifecycle
73
+ # --------------------------------------
74
+ 2_4-validation:
75
+ stage: validation
76
+ tags:
77
+ - docker
78
+ image: ruby:2.4
79
+ <<: *cache_bundler
80
+ <<: *setup_bundler_env
81
+ <<: *validation_checks
82
+
83
+ 2_4-unit:
84
+ stage: unit
85
+ tags:
86
+ - docker
87
+ image: ruby:2.4
88
+ <<: *cache_bundler
89
+ <<: *setup_bundler_env
90
+ <<: *spec_tests
19
91
 
20
- before_script:
21
- - 'ruby -v'
22
- - 'apt update && apt install -y rpm'
23
- - 'bundle -v || gem install bundler'
24
- - 'bundle config --local path vendor'
25
- - 'rm -f Gemfile.lock'
26
- - 'bundle install -j $(nproc) --no-binstubs'
27
92
 
28
93
  #=======================================================================
29
- # Anchors
94
+ # Acceptance tests
95
+ default:
96
+ stage: acceptance
97
+ tags:
98
+ - beaker
99
+ <<: *cache_bundler
100
+ <<: *setup_bundler_env
101
+ variables:
102
+ PUPPET_VERSION: '~> 4.10.10'
103
+ script:
104
+ - bundle exec rake spec_clean
105
+ - bundle exec rake beaker:suites[default]
30
106
 
31
- .acceptance_base: &acceptance_base
32
- stage: 'acceptance'
33
- tags: ['beaker']
34
- cache:
35
- policy: 'pull'
36
- dependencies: []
37
- artifacts:
38
- when: 'always'
39
- paths:
40
- - 'Gemfile.lock'
41
- retry: 1
107
+ default-puppet5:
108
+ stage: acceptance
109
+ tags:
110
+ - beaker
111
+ <<: *cache_bundler
112
+ <<: *setup_bundler_env
113
+ variables:
114
+ PUPPET_VERSION: '~> 5.3'
115
+ BEAKER_PUPPET_COLLECTION: 'puppet5'
42
116
  script:
43
- - 'bundle exec rake beaker:suites'
44
-
45
- # ----------------------------------------------------------------------
46
- # Version Matrix
47
- #
48
- # It would be too expensive, both in time and compute resources, to test
49
- # against every last version combination, so we restrict it to this subset.
50
- # Version sets are selected based on current support policies for major platform
51
- # software, such as Puppet and Ruby. Namely, we use the version combinations
52
- # bundled in Puppet Enterprise.
53
- #
54
- # For more information see:
55
- # * https://puppet.com/docs/pe/latest/overview/component_versions_in_recent_pe_releases.html
56
- # * https://puppet.com/misc/puppet-enterprise-lifecycle
57
- # * https://puppet.com/docs/pe/latest/overview/getting_support_for_pe.html#standard-releases-and-long-term-support-releases
58
- #
59
- # ----------------------------------------------
60
- # | Release | Puppet | Ruby | End-of-Life Date |
61
- # ----------|--------|------|------------------|
62
- # PE 2017.2 4.10 2.1 2018-02
63
- # PE 2017.3 5.3 2.4 2018-08
64
- # PE 2018.1 5.5 2.4 2020-05
65
- #
66
-
67
- .simp_6_1: &simp_6_1
117
+ - bundle exec rake spec_clean
118
+ - bundle exec rake beaker:suites[default]
119
+
120
+ default-fips:
121
+ stage: acceptance
122
+ tags:
123
+ - beaker
124
+ <<: *cache_bundler
125
+ <<: *setup_bundler_env
68
126
  variables:
69
- PUPPET_VERSION: '~> 4.10.4'
127
+ BEAKER_fips: 'yes'
128
+ script:
129
+ - bundle exec rake spec_clean
130
+ - bundle exec rake beaker:suites[default]
70
131
 
71
- #=======================================================================
72
- # Basic Sanity Checks
73
- #
74
- # Execute simple sanity checks on the environment before proceeding to more
75
- # resource-intensive jobs. Besides running checks, this condenses the initial
76
- # cache generation into a single job for the later stages. The first stage,
77
- # in particular, would otherwise suffer a heavy cache-miss penalty as its
78
- # jobs kick off in parallel.
79
- sanity_checks:
80
- stage: 'sanity'
81
- tags: ['docker']
132
+ fips_from_fixtures:
133
+ stage: acceptance
134
+ tags:
135
+ - beaker
136
+ <<: *cache_bundler
137
+ <<: *setup_bundler_env
138
+ variables:
139
+ PUPPET_VERSION: '~> 5.3'
140
+ BEAKER_PUPPET_COLLECTION: 'puppet5'
82
141
  script:
83
- - 'bundle exec rake check:dot_underscore'
84
- - 'bundle exec rake check:test_file'
142
+ - bundle exec rake spec_clean
143
+ - bundle exec rake beaker:suites[fips_from_fixtures]
85
144
 
86
- tag_check:
87
- stage: 'sanity'
88
- only: ['tags']
89
- tags: ['docker']
90
- script: '[ "$CI_COMMIT_TAG" = "$MODULE_VERSION" ] || echo "ERROR: Tag does not match metadata version" && exit 1'
145
+ puppet_collections:
146
+ stage: acceptance
147
+ tags:
148
+ - beaker
149
+ <<: *cache_bundler
150
+ <<: *setup_bundler_env
151
+ variables:
152
+ PUPPET_VERSION: '~> 5.3'
153
+ BEAKER_PUPPET_COLLECTION: 'puppet5'
154
+ script:
155
+ - bundle exec rake spec_clean
156
+ - bundle exec rake beaker:suites[puppet_collections]
91
157
 
92
- #=======================================================================
93
- # Unit Tests
94
- #
95
- unit:
96
- stage: 'unit'
97
- image: 'ruby:2.4.4'
98
- tags: ['docker']
158
+ windows:
159
+ stage: acceptance
160
+ tags:
161
+ - beaker
162
+ <<: *cache_bundler
163
+ <<: *setup_bundler_env
99
164
  script:
100
- - 'bundle exec rake spec'
101
- cache:
102
- policy: 'pull'
103
- dependencies: []
104
- artifacts:
105
- when: 'always'
106
- paths:
107
- - 'Gemfile.lock'
108
-
109
- # ==============================================================================
110
- # acceptance tests
111
- #
112
- el-simp_6_1-default:
113
- <<: *acceptance_base
114
- <<: *simp_6_1
115
-
116
- el-simp_6_1-default-fips:
117
- <<: *acceptance_base
118
- <<: *simp_6_1
119
- variables:
120
- BEAKER_fips: 'yes'
165
+ - bundle exec rake spec_clean
166
+ - bundle exec rake beaker:suites[windows]
data/.travis.yml CHANGED
@@ -29,7 +29,7 @@ deploy:
29
29
  condition: "($SKIP_PUBLISH != true)"
30
30
  - provider: releases
31
31
  api_key:
32
- secure: "RoQepMSpEzpTLgSYP1apB8AcKNMoumqe/emNg9lIu4T55t7fCPVZFmoTL2/VCjpGpBY3SL6PijSRelY6B1bri+6SFz/hlWhCQ8t1hodrEX23ieFBwWyLI7TFvrCjVejkJwaj7N2nYUQBv8YxScbRp4daFaDhrPJMrfqKZUlBBQ2KEUvqienOn7Tdt4OQ7/ThRXlhBm8OGjZfaKyWDyJykef+yC1scJrl8HA71XRHxho/iojTRPqJJCKW1QNmomVWAwK6ZEvb2WrD27yZN60wEcygdbmzKxlAXrfp13Ho+ir2GjRXJr1VKNPecFTDe21fDFMLZ5VxZgOJ7TWnhz2UAQIPjDTLzEMuJci7DDvRCWMJ17pYurm0OGAeKPWZbtf5PLYouKvnjNsfY8vy+Ip6MqmhiXqqLSO9XN/jgEVFPHj8pOj0DDq6PtTB8dNJj7g60Ak0Uj5iole4/ef1DHv803/t9J6IVqULmYZREqeTg24KkZLfTSEbkhYMGjbCZGaSAGhAFLAAjEDTM19/k50TXnNt5smn31Mqt45PULcrHP4+t6hM+IsX9w05aOlcvfwWiBm9nPlBPeRn59wZ64+T729i5wgkhFcHmYE/2Ql1Hvz5FebyxJQziyw6eRvCVASTtFEkuT+Noy3v4u3G4fQl/S2OeCP4v6Fs0wlImzFE1lA="
32
+ secure: "I41p4aqjkrNDHJhZ5gWC4gzn7BVwEYRm5Q3PAxQRSIUDB/QTVgNqZx8YptkuIvSGpw8kIywyZg3NKdzGUO8aJJ0NlXapL7e9qQIigkYhdaCZjZFG5zIxdOFs4sVoz/6vnQT9JIcGWy7uS5xiNOulGvfEWU78+e+I9yPdT74RApve5VAVT/km5lV5ldRnwwehLnTx+volUlnOD8rwfizoVLqFTrfRfr4cVMF605UYyaiVxHF50hywFRZoAdVcMEhlLQnQXfz/ZsLMJLJm9eCpjQ989N0oX6theSLCcv7QtHcWMXydjWMcpuTfBZSFrwUVbC23uMOKTJVEWq5LMG3m2L6hP3//2gvUzGhOVLvoGuC+erboB7QoXdcoOgXY+dTZPMcPBxpArdDLWVQSLTvPs05QzpaUdRLVMC/kD1d1EudlEicgkNgNDBhBn3089nVmvKndbKLvj+23a5AQVVbs+8C0x+SJvTc9N2N+bmuH7jIJPrEvWK4xwcQa+g2M/EBv05jaEdSErlVa6B6UKCH0Lea9rpy1se9vn5OzpaaMCCJIpcpQqHDjo0PMAQXBSbqjKcBei6lR5fIFl5UO9gWP1v8PGPuCzGTBivQ92XlgV1TWXmdbJHwIuSbJx3Ali7Wp19RR4E4uHC+TPFssvgkh9ZLkORnWWS35wzzU1LkwWx0="
33
33
  on:
34
34
  tags: true
35
35
  rvm: 2.4.4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ### 1.13.0 / 2018-11-09
2
+ * Make the SSG reporting consistent with the InSpec reporting
3
+ * Thanks to Liz Nemsick for the original result processing code
4
+
5
+ ### 1.12.2 / 2018-10-25
6
+ * Skip most of fix_errata_on on windows platforms
7
+
1
8
  ### 1.12.1 / 2018-10-24
2
9
  * Fall back to SSH file copies automatically when rsync does not work due to
3
10
  test cases that affect ssh directly and that will cause new sessions to fail.
data/Gemfile CHANGED
@@ -15,8 +15,9 @@ gem 'rake'
15
15
  group :system_tests do
16
16
  gem 'beaker'
17
17
  gem 'beaker-rspec'
18
+ gem 'beaker-windows'
18
19
  gem 'net-ssh'
19
- gem 'puppet', ENV.fetch('PUPPET_VERSION', '~> 4.0')
20
+ gem 'puppet', ENV.fetch('PUPPET_VERSION', '~> 5.0')
20
21
  gem 'puppetlabs_spec_helper'
21
22
  gem 'rubocop'
22
23
  gem 'rubocop-rspec'
@@ -235,7 +235,13 @@ module Simp::BeakerHelpers
235
235
  puts '== configuring FIPS mode on SUTs'
236
236
  puts ' -- (use BEAKER_fips=no to disable)'
237
237
  parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
238
+
238
239
  block_on(suts, :run_in_parallel => parallel) do |sut|
240
+ if sut[:platform] =~ /windows/
241
+ puts " -- SKIPPING #{sut} because it is windows"
242
+ next
243
+ end
244
+
239
245
  puts " -- enabling FIPS on '#{sut}'"
240
246
 
241
247
  # We need to use FIPS compliant algorithms and keylengths as per the FIPS
@@ -366,73 +372,82 @@ module Simp::BeakerHelpers
366
372
  end
367
373
  end
368
374
 
369
- # Apply known OS fixes we need to run Beaker on each SUT
370
- def fix_errata_on( suts = hosts )
371
- parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
372
- block_on(suts, :run_in_parallel => parallel) do |sut|
373
- # We need to be able to flip between server and client without issue
374
- on sut, 'puppet resource group puppet gid=52'
375
- on sut, 'puppet resource user puppet comment="Puppet" gid="52" uid="52" home="/var/lib/puppet" managehome=true'
376
-
377
- # This may not exist in docker so just skip the whole thing
378
- if sut.file_exist?('/etc/ssh')
379
- # SIMP uses a central ssh key location so we prep that spot in case we
380
- # flip to the SIMP SSH module.
381
- on(sut, 'mkdir -p /etc/ssh/local_keys')
382
- on(sut, 'chown -R root:root /etc/ssh/local_keys')
383
- on(sut, 'chmod 755 /etc/ssh/local_keys')
384
-
385
- user_info = on(sut, 'getent passwd').stdout.lines
386
-
387
- cmd = []
388
- # Hash of user => home_dir
389
- # Exclude silly directories
390
- # * /
391
- # * /dev/*
392
- # * /s?bin
393
- # * /proc
394
- user_info = Hash[
395
- user_info.map do |u|
396
- u.strip!
397
- u = u.split(':')
398
- u[5] =~ %r{^(/|/dev/.*|/s?bin/?.*|/proc/?.*)$} ? [nil] : [u[0], u[5]]
399
- end
400
- ]
375
+ def linux_errata( sut )
376
+ # We need to be able to flip between server and client without issue
377
+ on sut, 'puppet resource group puppet gid=52'
378
+ on sut, 'puppet resource user puppet comment="Puppet" gid="52" uid="52" home="/var/lib/puppet" managehome=true'
379
+
380
+ # This may not exist in docker so just skip the whole thing
381
+ if sut.file_exist?('/etc/ssh')
382
+ # SIMP uses a central ssh key location so we prep that spot in case we
383
+ # flip to the SIMP SSH module.
384
+ on(sut, 'mkdir -p /etc/ssh/local_keys')
385
+ on(sut, 'chown -R root:root /etc/ssh/local_keys')
386
+ on(sut, 'chmod 755 /etc/ssh/local_keys')
387
+
388
+ user_info = on(sut, 'getent passwd').stdout.lines
389
+
390
+ cmd = []
391
+ # Hash of user => home_dir
392
+ # Exclude silly directories
393
+ # * /
394
+ # * /dev/*
395
+ # * /s?bin
396
+ # * /proc
397
+ user_info = Hash[
398
+ user_info.map do |u|
399
+ u.strip!
400
+ u = u.split(':')
401
+ u[5] =~ %r{^(/|/dev/.*|/s?bin/?.*|/proc/?.*)$} ? [nil] : [u[0], u[5]]
402
+ end
403
+ ]
401
404
 
402
- user_info.keys.each do |user|
403
- src_file = "#{user_info[user]}/.ssh/authorzed_keys"
404
- tgt_file = "/etc/ssh/local_keys/#{user}"
405
+ user_info.keys.each do |user|
406
+ src_file = "#{user_info[user]}/.ssh/authorized_keys"
407
+ tgt_file = "/etc/ssh/local_keys/#{user}"
405
408
 
406
- on(sut, %{if [ -f "#{src_file}" ]; then cp -a -f "#{src_file}" "#{tgt_file}" && chmod 644 "#{tgt_file}"; fi}, :silent => true)
407
- end
409
+ on(sut, %{if [ -f "#{src_file}" ]; then cp -a -f "#{src_file}" "#{tgt_file}" && chmod 644 "#{tgt_file}"; fi}, :silent => true)
408
410
  end
411
+ end
412
+
413
+ # SIMP uses structured facts, therefore stringify_facts must be disabled
414
+ unless ENV['BEAKER_stringify_facts'] == 'yes'
415
+ on sut, 'puppet config set stringify_facts false'
416
+ end
409
417
 
410
- # SIMP uses structured facts, therefore stringify_facts must be disabled
411
- unless ENV['BEAKER_stringify_facts'] == 'yes'
412
- on sut, 'puppet config set stringify_facts false'
413
- end
418
+ # Occasionally we run across something similar to BKR-561, so to ensure we
419
+ # at least have the host defaults:
420
+ #
421
+ # :hieradatadir is used as a canary here; it isn't the only missing key
422
+ unless sut.host_hash.key? :hieradatadir
423
+ configure_type_defaults_on(sut)
424
+ end
414
425
 
415
- # Occasionally we run across something similar to BKR-561, so to ensure we
416
- # at least have the host defaults:
417
- #
418
- # :hieradatadir is used as a canary here; it isn't the only missing key
419
- unless sut.host_hash.key? :hieradatadir
420
- configure_type_defaults_on(sut)
421
- end
426
+ if fact_on(sut, 'osfamily') == 'RedHat'
427
+ enable_yum_repos_on(sut)
422
428
 
423
- if fact_on(sut, 'osfamily') == 'RedHat'
424
- enable_yum_repos_on(sut)
429
+ # net-tools required for netstat utility being used by be_listening
430
+ if fact_on(sut, 'operatingsystemmajrelease') == '7'
431
+ pp = <<-EOS
432
+ package { 'net-tools': ensure => installed }
433
+ EOS
434
+ apply_manifest_on(sut, pp, :catch_failures => false)
435
+ end
425
436
 
426
- # net-tools required for netstat utility being used by be_listening
427
- if fact_on(sut, 'operatingsystemmajrelease') == '7'
428
- pp = <<-EOS
429
- package { 'net-tools': ensure => installed }
430
- EOS
431
- apply_manifest_on(sut, pp, :catch_failures => false)
432
- end
437
+ # Clean up YUM prior to starting our test runs.
438
+ on(sut, 'yum clean all')
439
+ end
440
+ end
433
441
 
434
- # Clean up YUM prior to starting our test runs.
435
- on(sut, 'yum clean all')
442
+ # Apply known OS fixes we need to run Beaker on each SUT
443
+ def fix_errata_on( suts = hosts )
444
+ parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
445
+ block_on(suts, :run_in_parallel => parallel) do |sut|
446
+ if sut[:platform] =~ /windows/
447
+ puts " -- SKIPPING #{sut} because it is windows"
448
+ # DO NOTHING
449
+ else
450
+ linux_errata(sut)
436
451
  end
437
452
  end
438
453
 
@@ -442,7 +457,6 @@ module Simp::BeakerHelpers
442
457
  end
443
458
  end
444
459
 
445
-
446
460
  # Generate a fake openssl CA + certs for each host on a given SUT
447
461
  #
448
462
  # The directory structure is the same as what FakeCA drops into keydist/
@@ -597,6 +611,11 @@ done
597
611
  def activate_interfaces(hosts)
598
612
  parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
599
613
  block_on(hosts, :run_in_parallel => parallel) do |host|
614
+ if host[:platform] =~ /windows/
615
+ puts " -- SKIPPING #{host} because it is windows"
616
+ next
617
+ end
618
+
600
619
  interfaces_fact = retry_on(host,'facter interfaces', verbose: true).stdout
601
620
 
602
621
  interfaces = interfaces_fact.strip.split(',')
@@ -144,6 +144,8 @@ module Simp::BeakerHelpers
144
144
  :skipped => [],
145
145
  :overridden => []
146
146
  },
147
+ :score => 0,
148
+ :report => nil,
147
149
  :profiles => {}
148
150
  }
149
151
 
@@ -188,14 +190,17 @@ module Simp::BeakerHelpers
188
190
 
189
191
  if status == /^fail/
190
192
  status = :failed
193
+ color = 'red'
191
194
  else
192
195
  status = :passed
196
+ color = 'green'
193
197
  end
194
198
  else
195
199
  status = :skipped
200
+ color = 'yellow'
196
201
  end
197
202
 
198
- stats[:global][status] << title
203
+ stats[:global][status] << title.to_s.color
199
204
 
200
205
  stats[:profiles][profile_name][:controls][title][:status] = status
201
206
  stats[:profiles][profile_name][:controls][title][:source] = control['source_location']['ref']
@@ -261,6 +266,7 @@ module Simp::BeakerHelpers
261
266
 
262
267
  report << "\n Score: #{score}%"
263
268
 
269
+ stats[:score] = score
264
270
  stats[:report] = report.join("\n")
265
271
 
266
272
  return stats
@@ -61,6 +61,16 @@ module Simp::BeakerHelpers
61
61
  'datastream' => 'ssg-centos7-ds.xml'
62
62
  }
63
63
  }
64
+ },
65
+ 'OracleLinux' => {
66
+ '7' => {
67
+ 'required_packages' => EL_PACKAGES,
68
+ 'ssg' => {
69
+ 'profile_target' => 'ol7',
70
+ 'build_target' => 'ol7',
71
+ 'datastream' => 'ssg-ol7-ds.xml'
72
+ }
73
+ }
64
74
  }
65
75
  }
66
76
 
@@ -116,7 +126,7 @@ module Simp::BeakerHelpers
116
126
  cmd += ' --remediate'
117
127
  end
118
128
 
119
- cmd += %( --profile #{profile} --results #{@result_file}.xml --report #{@result_file}.html #{OS_INFO[@os][@os_rel]['ssg']['datastream']})
129
+ cmd += %( --fetch-remote-resources --profile #{profile} --results #{@result_file}.xml --report #{@result_file}.html #{OS_INFO[@os][@os_rel]['ssg']['datastream']})
120
130
 
121
131
  # We accept all exit codes here because there have occasionally been
122
132
  # failures in the SSG content and we're not testing that.
@@ -131,6 +141,122 @@ module Simp::BeakerHelpers
131
141
  end
132
142
  end
133
143
 
144
+ # Output the report
145
+ #
146
+ # @param report
147
+ # The results Hash
148
+ #
149
+ def write_report(report)
150
+ File.open(File.join(@output_dir, @result_file) + '.report', 'w') do |fh|
151
+ fh.puts(report[:report].uncolor)
152
+ end
153
+ end
154
+
155
+ # Retrieve a subset of test results based on a match to
156
+ # filter
157
+ #
158
+ # FIXME:
159
+ # - This is a hack! Should be searching for rules based on a set
160
+ # set of STIG ids, but don't see those ids in the oscap results xml.
161
+ # Further mapping is required...
162
+ # - Create the same report structure as inspec
163
+ def process_ssg_results(filter=nil)
164
+ self.class.process_ssg_results(File.join(@output_dir, @result_file) + '.xml', filter)
165
+ end
166
+
167
+ # Process the results of an SSG run
168
+ #
169
+ # @return [Hash] A Hash of statistics and a formatted report
170
+ #
171
+ def self.process_ssg_results(result_file, filter=nil)
172
+ require 'highline'
173
+ require 'nokogiri'
174
+
175
+ HighLine.colorize_strings
176
+
177
+ fail("Could not find results XML file '#{result_file}'") unless File.exist?(result_file)
178
+
179
+ puts "Processing #{result_file}"
180
+ doc = Nokogiri::XML(File.open(result_file))
181
+
182
+ # because I'm lazy
183
+ doc.remove_namespaces!
184
+
185
+ if filter
186
+ # XPATH to get the pertinent test results:
187
+ # Any node named 'rule-result' for which the attribute 'idref'
188
+ # contains filter
189
+ result_nodes = doc.xpath("//rule-result[contains(@idref,'#{filter}')]")
190
+ else
191
+ result_nodes = doc.xpath('//rule-result')
192
+ end
193
+
194
+ stats = {
195
+ :failed => [],
196
+ :passed => [],
197
+ :skipped => [],
198
+ :filter => filter.nil? ? 'No Filter' : filter,
199
+ :report => nil,
200
+ :score => 0
201
+ }
202
+
203
+ result_nodes.each do |rule_result|
204
+ # Results are recorded in a child node named 'result'.
205
+ # Within the 'result' node, the actual result string is
206
+ # the content of that node's (only) child node.
207
+
208
+ result = rule_result.element_children.at('result')
209
+ result_id = rule_result.attributes['idref'].value.to_s
210
+ result_value = [
211
+ 'Title: ' + doc.xpath("//Rule[@id='#{result_id}']/title/text()").first.to_s,
212
+ ' ID: ' + result_id
213
+ ].join("\n")
214
+
215
+ if result.child.content == 'fail'
216
+ stats[:failed] << result_value.red
217
+ elsif result.child.content == 'pass'
218
+ stats[:passed] << result_value.green
219
+ else
220
+ stats[:skipped] << result_value.yellow
221
+ end
222
+ end
223
+
224
+ report = []
225
+
226
+ report << '== Skipped =='
227
+ report << stats[:skipped].join("\n")
228
+
229
+ report << '== Passed =='
230
+ report << stats[:passed].join("\n")
231
+
232
+ report << '== Failed =='
233
+ report << stats[:failed].join("\n")
234
+
235
+
236
+ report << 'OSCAP Statistics:'
237
+
238
+ if filter
239
+ report << " * Used Filter: 'idref' ~= '#{stats[:filter]}'"
240
+ end
241
+
242
+ report << " * Passed: #{stats[:passed].count.to_s.green}"
243
+ report << " * Failed: #{stats[:failed].count.to_s.red}"
244
+ report << " * Skipped: #{stats[:skipped].count.to_s.yellow}"
245
+
246
+ score = 0
247
+
248
+ if (stats[:passed].count + stats[:failed].count) > 0
249
+ score = ((stats[:passed].count.to_f/(stats[:passed].count + stats[:failed].count)) * 100.0).round(0)
250
+ end
251
+
252
+ report << "\n Score: #{score}%"
253
+
254
+ stats[:score] = score
255
+ stats[:report] = report.join("\n")
256
+
257
+ return stats
258
+ end
259
+
134
260
  private
135
261
 
136
262
  def get_ssg_datastream
@@ -1,5 +1,5 @@
1
1
  module Simp; end
2
2
 
3
3
  module Simp::BeakerHelpers
4
- VERSION = '1.12.1'
4
+ VERSION = '1.13.0'
5
5
  end
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.add_runtime_dependency 'beaker-vagrant' , '~> 0.5'
26
26
  s.add_runtime_dependency 'beaker-puppet_install_helper', '~> 0.9'
27
27
  s.add_runtime_dependency 'highline' , '~> 1.6'
28
+ s.add_runtime_dependency 'nokogiri' , '~> 1.8'
28
29
 
29
30
  # Because net-telnet dropped support for Ruby < 2.3.0
30
31
  # TODO: Update this when we no longer support Ruby 2.1.9 (should be October 2018)
@@ -1,3 +1,10 @@
1
+ <%
2
+ if ENV['BEAKER_HYPERVISOR']
3
+ hypervisor = ENV['BEAKER_HYPERVISOR']
4
+ else
5
+ hypervisor = 'vagrant'
6
+ end
7
+ -%>
1
8
  HOSTS:
2
9
  server-el7:
3
10
  roles:
@@ -5,18 +12,21 @@ HOSTS:
5
12
  - default
6
13
  - master
7
14
  - el7
8
- platform: el-7-x86_64
9
- box: centos/7
10
- hypervisor: vagrant
15
+ platform: el-7-x86_64
16
+ box: centos/7
17
+ hypervisor: <%= hypervisor %>
11
18
 
12
19
  server-el6:
13
20
  roles:
14
21
  - el6
15
- platform: el-6-x86_64
16
- box: centos/6
17
- hypervisor: vagrant
22
+ platform: el-6-x86_64
23
+ box: centos/6
24
+ hypervisor: <%= hypervisor %>
18
25
 
19
26
  CONFIG:
20
27
  log_level: verbose
21
- type: aio
28
+ type: aio
22
29
  vagrant_memsize: 256
30
+ <% if ENV['BEAKER_PUPPET_COLLECTION'] -%>
31
+ puppet_collection: <%= ENV['BEAKER_PUPPET_COLLECTION'] %>
32
+ <% end -%>
@@ -1,3 +1,10 @@
1
+ <%
2
+ if ENV['BEAKER_HYPERVISOR']
3
+ hypervisor = ENV['BEAKER_HYPERVISOR']
4
+ else
5
+ hypervisor = 'vagrant'
6
+ end
7
+ -%>
1
8
  HOSTS:
2
9
  server-el7:
3
10
  roles:
@@ -5,19 +12,19 @@ HOSTS:
5
12
  - default
6
13
  - master
7
14
  - el7
8
- platform: el-7-x86_64
9
- box: centos/7
10
- hypervisor: vagrant
15
+ platform: el-7-x86_64
16
+ box: centos/7
17
+ hypervisor: <%= hypervisor %>
11
18
 
12
19
  server-el6:
13
20
  roles:
14
21
  - el6
15
- platform: el-6-x86_64
16
- box: centos/6
17
- hypervisor: vagrant
22
+ platform: el-6-x86_64
23
+ box: centos/6
24
+ hypervisor: <%= hypervisor %>
18
25
 
19
26
  CONFIG:
20
27
  log_level: verbose
21
- type: aio
28
+ type: aio
22
29
  puppet_collection: puppet5
23
30
  vagrant_memsize: 256
@@ -0,0 +1,103 @@
1
+ require 'tmpdir'
2
+ require 'yaml'
3
+ require 'openssl'
4
+ require 'beaker-rspec'
5
+ require 'simp/beaker_helpers'
6
+ include Simp::BeakerHelpers
7
+
8
+ require 'beaker/puppet_install_helper'
9
+ require 'beaker-windows'
10
+ include BeakerWindows::Path
11
+ include BeakerWindows::Powershell
12
+ include BeakerWindows::Registry
13
+ include BeakerWindows::WindowsFeature
14
+
15
+ unless ENV['BEAKER_provision'] == 'no'
16
+ hosts.each do |host|
17
+ # Install Puppet
18
+ if host.is_pe?
19
+ install_pe
20
+ else
21
+ install_puppet
22
+ end
23
+ end
24
+ end
25
+
26
+ hosts.each do |host|
27
+ # https://petersouter.co.uk/testing-windows-puppet-with-beaker/
28
+ case host['platform']
29
+ when /windows/
30
+ GEOTRUST_GLOBAL_CA = <<-EOM.freeze
31
+ -----BEGIN CERTIFICATE-----
32
+ MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT
33
+ MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i
34
+ YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQG
35
+ EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UEAxMSR2VvVHJ1c3Qg
36
+ R2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2swYYzD9
37
+ 9BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjoBbdq
38
+ fnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDv
39
+ iS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU
40
+ 1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+
41
+ bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5aszPeE4uwc2hGKceeoW
42
+ MPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTA
43
+ ephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVkDBF9qn1l
44
+ uMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn
45
+ Z57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS
46
+ tQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF
47
+ PseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un
48
+ hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV
49
+ 5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw==
50
+ -----END CERTIFICATE-----
51
+ EOM
52
+ install_cert_on_windows(host, 'geotrustglobal', GEOTRUST_GLOBAL_CA)
53
+ end
54
+ end
55
+
56
+
57
+ RSpec.configure do |c|
58
+ # ensure that environment OS is ready on each host
59
+ fix_errata_on(hosts)
60
+
61
+ # Readable test descriptions
62
+ c.formatter = :documentation
63
+
64
+ # Configure all nodes in nodeset
65
+ c.before :suite do
66
+ begin
67
+ nonwin = hosts.dup
68
+ nonwin.delete_if {|h| h[:platform] =~ /windows/ }
69
+ # Install modules and dependencies from spec/fixtures/modules
70
+ copy_fixture_modules_to( nonwin )
71
+ begin
72
+ server = only_host_with_role(nonwin, 'server')
73
+ rescue ArgumentError => e
74
+ server = only_host_with_role(nonwin, 'default')
75
+ end
76
+ # Generate and install PKI certificates on each SUT
77
+ Dir.mktmpdir do |cert_dir|
78
+ run_fake_pki_ca_on(server, nonwin, cert_dir )
79
+ nonwin.each{ |sut| copy_pki_to( sut, cert_dir, '/etc/pki/simp-testing' )}
80
+ end
81
+
82
+ # add PKI keys
83
+ copy_keydist_to(server)
84
+ rescue StandardError, ScriptError => e
85
+ if ENV['PRY']
86
+ require 'pry'; binding.pry
87
+ else
88
+ raise e
89
+ end
90
+ end
91
+ end
92
+ end
93
+
94
+
95
+ hosts.each do |host|
96
+ describe 'windows hosts coexising with linux hosts' do
97
+ context "on #{host}" do
98
+ it 'should have puppet installed' do
99
+ on(host, 'puppet --version')
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,2 @@
1
+ ---
2
+ 'default_run': true
@@ -0,0 +1,40 @@
1
+ <%
2
+ if ENV['BEAKER_HYPERVISOR']
3
+ hypervisor = ENV['BEAKER_HYPERVISOR']
4
+ else
5
+ hypervisor = 'vagrant'
6
+ end
7
+ -%>
8
+ HOSTS:
9
+ win:
10
+ roles:
11
+ - windows
12
+ - ad
13
+ platform: windows-server-amd64
14
+ box: opentable/win-2012r2-standard-amd64-nocm # VBOX ONLY
15
+ hypervisor: <%= hypervisor %>
16
+ vagrant_memsize: 2048
17
+ vagrant_cpus: 2
18
+ user: vagrant
19
+ communicator: winrm
20
+ is_cygwin: false
21
+ centos7:
22
+ roles:
23
+ - default
24
+ - client
25
+ platform: el-7-x86_64
26
+ box: centos/7
27
+ hypervisor: <%= hypervisor %>
28
+ centos6:
29
+ roles:
30
+ - client
31
+ platform: el-6-x86_64
32
+ box: centos/6
33
+ hypervisor: <%= hypervisor %>
34
+ CONFIG:
35
+ log_level: verbose
36
+ type: aio
37
+ vagrant_memsize: 256
38
+ <% if ENV['BEAKER_PUPPET_ENVIRONMENT'] -%>
39
+ puppet_environment: <%= ENV['BEAKER_PUPPET_ENVIRONMENT'] %>
40
+ <% end -%>
@@ -80,11 +80,11 @@ describe 'Simp::BeakerHelpers' do
80
80
 
81
81
  # this logic won't work properly without code changes that just aren't worth it because
82
82
  # Puppet 4 is MD soon....
83
- it "maps to appropriate Puppet version when '<' operator specified in version" do
84
- pending 'fails because matches 4.x table'
85
- allow(@helper).to receive(:`).with('gem search -ra -e puppet').and_return(gem_search_results)
86
- expect( @helper.latest_puppet_agent_version_for('< 5.5') ).to match /5.4.0/
87
- end
83
+ # it "maps to appropriate Puppet version when '<' operator specified in version" do
84
+ # pending 'fails because matches 4.x table'
85
+ # allow(@helper).to receive(:`).with('gem search -ra -e puppet').and_return(gem_search_results)
86
+ # expect( @helper.latest_puppet_agent_version_for('< 5.5') ).to match /5.4.0/
87
+ # end
88
88
 
89
89
  it "maps to appropriate Puppet version when comma-separated operators specified in version" do
90
90
  allow(@helper).to receive(:`).with('gem search -ra -e puppet').and_return(gem_search_results)
@@ -22,19 +22,4 @@ RSpec.configure do |c|
22
22
 
23
23
  # Readable test descriptions
24
24
  c.formatter = :documentation
25
-
26
- # Configure all nodes in nodeset
27
- c.before :suite do
28
- begin
29
- # Install modules and dependencies from spec/fixtures/modules
30
- copy_fixture_modules_to( hosts )
31
- STDOUT.flush
32
- rescue StandardError, ScriptError => e
33
- if ENV['PRY']
34
- require 'pry'; binding.pry
35
- else
36
- raise e
37
- end
38
- end
39
- end
40
25
  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.12.1
4
+ version: 1.13.0
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: 2018-10-24 00:00:00.000000000 Z
12
+ date: 2018-11-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beaker
@@ -109,6 +109,20 @@ dependencies:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
111
  version: '1.6'
112
+ - !ruby/object:Gem::Dependency
113
+ name: nokogiri
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '1.8'
119
+ type: :runtime
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '1.8'
112
126
  - !ruby/object:Gem::Dependency
113
127
  name: net-telnet
114
128
  requirement: !ruby/object:Gem::Requirement
@@ -137,8 +151,7 @@ dependencies:
137
151
  - - "~>"
138
152
  - !ruby/object:Gem::Version
139
153
  version: 0.57.2
140
- description: |2
141
- Beaker helper methods to help scaffold SIMP acceptance tests
154
+ description: " Beaker helper methods to help scaffold SIMP acceptance tests\n"
142
155
  email: simp@simp-project.org
143
156
  executables: []
144
157
  extensions: []
@@ -180,6 +193,9 @@ files:
180
193
  - spec/acceptance/suites/puppet_collections/00_default_spec.rb
181
194
  - spec/acceptance/suites/puppet_collections/metadata.yml
182
195
  - spec/acceptance/suites/puppet_collections/nodesets/default.yml
196
+ - spec/acceptance/suites/windows/00_default_spec.rb
197
+ - spec/acceptance/suites/windows/metadata.yml
198
+ - spec/acceptance/suites/windows/nodesets/default.yml
183
199
  - spec/lib/simp/beaker_helpers_spec.rb
184
200
  - spec/spec_helper.rb
185
201
  - spec/spec_helper_acceptance.rb