puppetlabs_spec_helper 7.4.0 → 8.0.0

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: a36cef853b9fb2b00ccda0994669722f01209bca6341ed3bfe07acae8475e08c
4
- data.tar.gz: 155d86fa1f146094e975dbe60f3f4696b5eab2df34f9d4b4c7dfade4d5708e43
3
+ metadata.gz: f6e4f387a2e5ca2ffdaf54834dba59bddbc793d099a32844e406d6bcf1906345
4
+ data.tar.gz: a5d37de14da8a64547e4dd3a40a649b0eac66d7c73d7d2aff561dafc569c3299
5
5
  SHA512:
6
- metadata.gz: 3c330c348badae2b51fd81aebc3a9f9143a1e8c82ffc0273a9cb7e95ce71c9702f5d8cde33d0af014fedcf27dd62b38fb1c0edd9063b0f3998da9f3786a32b1a
7
- data.tar.gz: 6852485e9517b2984072af1171f252619d07455756fb694e999c78f23272c17e9cb17bb598f8aa8c0799fec8d6d2998679b11aa820c98e365dc67ea72a3e8f30
6
+ metadata.gz: 0c5d1c7bc0f185b696570c75bccab95349681e09bc213e91f5ffeb855d462a4e98c30cc3049ccb44cb083936438ccc386bcee6096a92f2ff8e8eb48c1fc8478e
7
+ data.tar.gz: 7da07d5ea2f8c277944bb803765fe2a39695c38ee3342bf0da34fdefce301e20edce6d9a201337db7cbbb14536ac2f9894cb50925f439a6214f9aa1a35669b97
data/README.md CHANGED
@@ -216,6 +216,17 @@ When specifying the repo source of the fixture you have a few options as to whic
216
216
  * `ref` and `branch` can be used together to get a specific revision on a specific branch
217
217
  * Top level `defaults` option could be used to set global options
218
218
 
219
+ Using Forge Authorization
220
+ -----------------
221
+
222
+ In order to perform forge operations which require authorization, such as installing premium modules, you can export your forge api key as an environment variable in your terminal.
223
+
224
+ ```bash
225
+ FORGE_API_KEY='your_api_key'
226
+ ```
227
+
228
+ puppetlabs_spec_helper will then automatically append this key to all `puppet module install` requests when running `rake spec_prep`.
229
+
219
230
  Fixtures Examples
220
231
  -----------------
221
232
  Basic fixtures that will symlink `spec/fixtures/modules/my_modules` to the
@@ -121,35 +121,6 @@ task :parallel_spec_standalone do |_t, args|
121
121
  end
122
122
  end
123
123
 
124
- desc 'Build puppet module package'
125
- task :build do
126
- Rake::Task['build:pdk'].invoke
127
- end
128
-
129
- namespace :build do
130
- desc 'Build Puppet module with PDK'
131
- task :pdk do
132
- require 'pdk/util'
133
- require 'pdk/module/build'
134
-
135
- path = PDK::Module::Build.invoke(force: true, 'target-dir': File.join(Dir.pwd, 'pkg'))
136
- puts "Module built: #{path}"
137
- rescue LoadError
138
- _ = `pdk --version`
139
- unless $CHILD_STATUS.success?
140
- warn 'Unable to build module. Please install PDK or add the `pdk` gem to your Gemfile.'
141
- abort
142
- end
143
-
144
- system('pdk build --force')
145
- end
146
- end
147
-
148
- desc 'Clean a built module package'
149
- task :clean do
150
- FileUtils.rm_rf('pkg/')
151
- end
152
-
153
124
  require 'puppet-lint/tasks/puppet-lint'
154
125
  # Must clear as it will not override the existing puppet-lint rake task since we require to import for
155
126
  # the PuppetLint::RakeTask
@@ -170,7 +141,6 @@ puppet_lint_disable_checks = %w[
170
141
  80chars
171
142
  140chars
172
143
  class_inherits_from_params_class
173
- class_parameter_defaults
174
144
  disable_autoloader_layout
175
145
  documentation
176
146
  single_quote_string_with_variables
@@ -379,6 +379,9 @@ module PuppetlabsSpecHelper
379
379
  flags = " #{opts['flags']}" if opts['flags']
380
380
  end
381
381
 
382
+ forge_token = ENV.fetch('FORGE_API_KEY', nil)
383
+ flags += " --forge_authorization \"Bearer #{forge_token}\"" if forge_token
384
+
382
385
  return false if File.directory?(target) && (ref.empty? || opts['ref'] == module_version(target))
383
386
 
384
387
  # The PMT cannot handle multi threaded runs due to cache directory collisons
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PuppetlabsSpecHelper
4
- VERSION = '7.4.0'
4
+ VERSION = '8.0.0'
5
5
  end
@@ -165,6 +165,29 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
165
165
  end
166
166
  end
167
167
 
168
+ context 'when forge_api_key env variable is set' do
169
+ before do
170
+ # required to prevent unwanted output on stub of $CHILD_STATUS
171
+ RSpec::Mocks.configuration.allow_message_expectations_on_nil = true
172
+ end
173
+
174
+ after do
175
+ RSpec::Mocks.configuration.allow_message_expectations_on_nil = false
176
+ end
177
+
178
+ it 'correctly sets --forge_authorization' do
179
+ allow(ENV).to receive(:fetch).with('FORGE_API_KEY', nil).and_return('myforgeapikey')
180
+ # Mock the system call to prevent actual execution
181
+ allow_any_instance_of(Kernel).to receive(:system) do |command| # rubocop:disable RSpec/AnyInstance
182
+ expect(command).to include('--forge_authorization "Bearer myforgeapikey"')
183
+ # Simulate setting $CHILD_STATUS to a successful status
184
+ allow($CHILD_STATUS).to receive(:success?).and_return(true)
185
+ true
186
+ end
187
+ helper.download_module('puppetlabs-stdlib', 'target' => 'spec/fixtures/modules/stdlib')
188
+ end
189
+ end
190
+
168
191
  context 'when file specifies repository fixtures' do
169
192
  before do
170
193
  allow(File).to receive(:exist?).with('.fixtures.yml').and_return true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppetlabs_spec_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.4.0
4
+ version: 8.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet, Inc.
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-09-06 00:00:00.000000000 Z
12
+ date: 2024-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mocha