voxpupuli-acceptance 3.3.0 → 3.5.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: 5c4b7c689abbd0e3e7f9917b6c3d9e8170960d21ea09824943b39cbdfafe6b2c
4
- data.tar.gz: 3fa4edc58eb170887640969a32cd973f8419b6aac449c8c9be2aaca3b4d6728e
3
+ metadata.gz: b94004396716a88abf812b4b9eb36e8ec6cf29ef9faaf7b3abcc5494c164aec5
4
+ data.tar.gz: fbb13171a4eade95e39fabc99609d6ee286269b713834d6f161928fd38525055
5
5
  SHA512:
6
- metadata.gz: 6b4f8d4504bd29c9bc520cbfbebc8447aad495df74832b3404128c9fecfe383c4c9ae4883f8203a62737520ed4019092d9a6465f181dc9a17abed3fbd251db74
7
- data.tar.gz: 2ab89e0a80b700057807e32f3ec4a54d5dc92776fc9c376d2fb2fceccea5f9d516be9ec15997f9a29350137175bf3e7047c3dc46153d71db1958f7393a9bb955
6
+ metadata.gz: fb81c5a2090cede4108248a8958b5d1d4d03b9eb5941914c98d0a7f109e708a07a0a584bd2a8e0abc92b36a820d54702d4543f3b776cb7b7cd91ba37bb5cd45e
7
+ data.tar.gz: 515e5307d2ad807862a07a5f7d0c97f4628c74cf524ea7fa2ffe1ed1309079cd4ddedfbfcff3052c36409bad5b8cf9496dc81471f4942e06c0d9ea4e363480a6
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  shared_examples 'an idempotent resource' do |host|
2
4
  host ||= default
3
5
 
@@ -15,6 +17,7 @@ shared_examples 'the example' do |name, host|
15
17
  let(:manifest) do
16
18
  path = File.join(Dir.pwd, 'examples', name)
17
19
  raise Exception, "Example '#{path}' does not exist" unless File.exist?(path)
20
+
18
21
  File.read(path)
19
22
  end
20
23
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Voxpupuli
2
4
  module Acceptance
3
5
  class Facts
@@ -23,7 +25,8 @@ module Voxpupuli
23
25
 
24
26
  if beaker_facts.any?
25
27
  require 'json'
26
- on(hosts, "mkdir -p #{File.dirname(FACT_FILE)} && cat <<VOXPUPULI_BEAKER_ENV_VARS > #{FACT_FILE}\n#{beaker_facts.to_json}\nVOXPUPULI_BEAKER_ENV_VARS")
28
+ on(hosts,
29
+ "mkdir -p #{File.dirname(FACT_FILE)} && cat <<VOXPUPULI_BEAKER_ENV_VARS > #{FACT_FILE}\n#{beaker_facts.to_json}\nVOXPUPULI_BEAKER_ENV_VARS")
27
30
  else
28
31
  on(hosts, "rm -f #{FACT_FILE}")
29
32
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'tmpdir'
2
4
  require 'puppet/modulebuilder'
3
5
 
@@ -52,7 +54,7 @@ module Voxpupuli
52
54
  if logger
53
55
  logger.warn(warning)
54
56
  else
55
- STDERR.puts(warning)
57
+ warn(warning)
56
58
  end
57
59
  end
58
60
 
@@ -101,9 +103,9 @@ module Voxpupuli
101
103
  #
102
104
  # @param [Host, String, Symbol] host
103
105
  # The beaker host to run on
104
- def temp_dir_on(host, &block)
105
- result = on host, "mktemp -d"
106
- raise "Could not create directory" unless result.success?
106
+ def temp_dir_on(host)
107
+ result = on host, 'mktemp -d'
108
+ raise 'Could not create directory' unless result.success?
107
109
 
108
110
  dir = result.stdout.strip
109
111
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  # Fixtures can be needed because of spec_prep
3
5
  # spec_prep task is provided by puppetlabs_spec_helper
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ # written by https://github.com/ekohl
4
+ # https://github.com/mizzy/serverspec/pull/611 was rejected so adding it here.
5
+
6
+ require 'serverspec'
7
+
8
+ module Voxpupuli
9
+ module Acceptance
10
+ module ServerspecExtensions
11
+ class CurlCommand < Serverspec::Type::Command
12
+ def response_code
13
+ m = /Response-Code: (?<code>\d+)/.match(stderr)
14
+ return 0 unless m
15
+
16
+ m[:code].to_i
17
+ end
18
+
19
+ def body
20
+ command_result.stdout
21
+ end
22
+
23
+ def body_as_json
24
+ MultiJson.load(body)
25
+ end
26
+
27
+ private
28
+
29
+ def curl_command
30
+ # curl supports %{stderr} to --write-out since 7.63.0
31
+ # so the following doesn't work on EL8, which has curl 7.61.1
32
+ command = "curl --silent --write-out '%{stderr}Response-Code: %{response_code}\\n' '#{@name}'" # rubocop:disable Style/FormatStringToken
33
+
34
+ @options.each do |option, value|
35
+ case option
36
+ when :cacert, :cert, :key
37
+ command += " --#{option} '#{value}'"
38
+ when :headers
39
+ value.each do |header, header_value|
40
+ command += if header_value
41
+ " --header '#{header}: #{header_value}'"
42
+ else
43
+ " --header '#{header};'"
44
+ end
45
+ end
46
+ else
47
+ raise "Unknown option #{option} (value: #{value})"
48
+ end
49
+ end
50
+
51
+ command
52
+ end
53
+
54
+ def command_result
55
+ @command_result ||= @runner.run_command(curl_command)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'serverspec'
4
+ require_relative 'serverspec_extensions/curl_command'
5
+
6
+ module Serverspec
7
+ module Helper
8
+ module Type
9
+ def curl_command(*args)
10
+ Voxpupuli::Acceptance::ServerspecExtensions::CurlCommand.new(*args)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'examples'
4
+ require_relative 'serverspec_extensions'
2
5
 
3
6
  def configure_beaker(modules: :metadata, &block)
4
7
  collection = ENV['BEAKER_PUPPET_COLLECTION'] || 'puppet'
@@ -18,7 +21,9 @@ def configure_beaker(modules: :metadata, &block)
18
21
  unless %w[none preinstalled].include?(collection)
19
22
  BeakerPuppetHelpers::InstallUtils.install_puppet_release_repo_on(host, collection)
20
23
  end
21
- package_name = ENV.fetch('BEAKER_PUPPET_PACKAGE_NAME', BeakerPuppetHelpers::InstallUtils.puppet_package_name(host, prefer_aio: collection != 'none'))
24
+ package_name = ENV.fetch('BEAKER_PUPPET_PACKAGE_NAME') do
25
+ BeakerPuppetHelpers::InstallUtils.collection2packagename(host, collection, prefer_aio: collection != 'none')
26
+ end
22
27
  host.install_package(package_name)
23
28
 
24
29
  # by default, puppet-agent creates /etc/profile.d/puppet-agent.sh which adds /opt/puppetlabs/bin to PATH
@@ -70,9 +75,7 @@ def configure_beaker(modules: :metadata, &block)
70
75
  end
71
76
 
72
77
  RSpec.configure do |c|
73
- if ENV['GITHUB_ACTIONS'] == 'true'
74
- c.formatter = 'RSpec::Github::Formatter'
75
- end
78
+ c.formatter = 'RSpec::Github::Formatter' if ENV['GITHUB_ACTIONS'] == 'true'
76
79
 
77
80
  # Fact handling
78
81
  c.add_setting :suite_configure_facts_from_env, default: true
@@ -82,7 +85,7 @@ RSpec.configure do |c|
82
85
  c.add_setting :suite_hiera_data_dir, default: File.join('spec', 'acceptance', 'hieradata')
83
86
  c.add_setting :suite_hiera_hierachy, default: [
84
87
  {
85
- name: "Per-node data",
88
+ name: 'Per-node data',
86
89
  path: 'fqdn/%{facts.networking.fqdn}.yaml',
87
90
  },
88
91
  {
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voxpupuli-acceptance
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-19 00:00:00.000000000 Z
10
+ date: 2025-03-19 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bcrypt_pbkdf
@@ -86,14 +85,14 @@ dependencies:
86
85
  requirements:
87
86
  - - "~>"
88
87
  - !ruby/object:Gem::Version
89
- version: '1.3'
88
+ version: '2.1'
90
89
  type: :runtime
91
90
  prerelease: false
92
91
  version_requirements: !ruby/object:Gem::Requirement
93
92
  requirements:
94
93
  - - "~>"
95
94
  - !ruby/object:Gem::Version
96
- version: '1.3'
95
+ version: '2.1'
97
96
  - !ruby/object:Gem::Dependency
98
97
  name: beaker-rspec
99
98
  requirement: !ruby/object:Gem::Requirement
@@ -242,10 +241,24 @@ dependencies:
242
241
  - - "<"
243
242
  - !ruby/object:Gem::Version
244
243
  version: '9'
244
+ - !ruby/object:Gem::Dependency
245
+ name: voxpupuli-rubocop
246
+ requirement: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: 3.0.0
251
+ type: :development
252
+ prerelease: false
253
+ version_requirements: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: 3.0.0
245
258
  description: A package that depends on all the gems Vox Pupuli modules need and methods
246
259
  to simplify acceptance spec helpers
247
260
  email:
248
- - pmc@voxpupuli.org
261
+ - voxpupuli@groups.io
249
262
  executables: []
250
263
  extensions: []
251
264
  extra_rdoc_files: []
@@ -255,12 +268,13 @@ files:
255
268
  - lib/voxpupuli/acceptance/facts.rb
256
269
  - lib/voxpupuli/acceptance/fixtures.rb
257
270
  - lib/voxpupuli/acceptance/rake.rb
271
+ - lib/voxpupuli/acceptance/serverspec_extensions.rb
272
+ - lib/voxpupuli/acceptance/serverspec_extensions/curl_command.rb
258
273
  - lib/voxpupuli/acceptance/spec_helper_acceptance.rb
259
274
  homepage: https://github.com/voxpupuli/voxpupuli-acceptance
260
275
  licenses:
261
276
  - Apache-2.0
262
277
  metadata: {}
263
- post_install_message:
264
278
  rdoc_options: []
265
279
  require_paths:
266
280
  - lib
@@ -278,8 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
278
292
  - !ruby/object:Gem::Version
279
293
  version: '0'
280
294
  requirements: []
281
- rubygems_version: 3.5.22
282
- signing_key:
295
+ rubygems_version: 3.6.2
283
296
  specification_version: 4
284
297
  summary: Helpers for acceptance testing Vox Pupuli modules
285
298
  test_files: []