puppet 6.4.1-x86-mingw32 → 6.4.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 675fa95e0e5f2e7bed24ccae6e74618ba10381a854126a3a2323e7edea8bd012
4
- data.tar.gz: 90c2a17cdfcfef59dbbecc4dd161e82f63c38a3572d80a7fc8e50527fb91939f
3
+ metadata.gz: dc7d2298f57f946313ebeb8628c04ea247729566680bc3eef295acadcab764f5
4
+ data.tar.gz: 49df37a4a997b921a5e60e23eecdf6d93aa09ebe25ede44bdf93cd983a2d89bc
5
5
  SHA512:
6
- metadata.gz: 02141f19102495abe7aee126ba1026cb036d6313f3dcc42234f80f5253da846018321d822b6c0aee832c6db4fa8d2a4bc17f58af5a227820240103c6615680d4
7
- data.tar.gz: db42130be62f2bc8dd30065f7ddb52215eba50ed629e29b8d9af286ced320b21ac88144602613f8496cd7028ade8410f8668b0f4c6f650292f16c7fc7d0eadd7
6
+ metadata.gz: 73db6c43b0aad61a23468fddbabd04b3c07ffc1402a0f3a6afa62e13071690131207b1bea2c6c630daf6514370b2e1ef7387691c95619fbe229aaa34de95b053
7
+ data.tar.gz: daefcce7ed52aefa84535d1d0aaf1ac3fe7ffc9c02f9363cf8d599750dfe224955bbb552b230812f016c8b492215d518c870c84cfbc5e05d8a3ea750656d547a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- puppet (6.4.1)
4
+ puppet (6.4.2)
5
5
  CFPropertyList (~> 2.2)
6
6
  facter (>= 2.4.0, < 4)
7
7
  fast_gettext (~> 1.1.2)
@@ -32,7 +32,7 @@ GEM
32
32
  fast_gettext (~> 1.1.0)
33
33
  gettext (>= 3.0.2)
34
34
  locale
35
- hashdiff (0.3.8)
35
+ hashdiff (0.3.9)
36
36
  hiera (3.5.0)
37
37
  hiera-eyaml (3.0.0)
38
38
  highline (~> 1.6.19)
@@ -47,11 +47,11 @@ GEM
47
47
  memory_profiler (0.9.13)
48
48
  method_source (0.9.2)
49
49
  minitar (0.8)
50
- msgpack (1.2.9)
50
+ msgpack (1.2.10)
51
51
  multi_json (1.13.1)
52
52
  mustache (1.1.0)
53
53
  optimist (3.0.0)
54
- packaging (0.99.27)
54
+ packaging (0.99.29)
55
55
  artifactory (~> 2)
56
56
  rake (~> 12.3)
57
57
  parallel (1.17.0)
@@ -84,7 +84,7 @@ GEM
84
84
  rspec-expectations (>= 2.99.0.beta1)
85
85
  rspec-core (3.8.0)
86
86
  rspec-support (~> 3.8.0)
87
- rspec-expectations (3.8.2)
87
+ rspec-expectations (3.8.3)
88
88
  diff-lcs (>= 1.2.0, < 2.0)
89
89
  rspec-support (~> 3.8.0)
90
90
  rspec-its (1.3.0)
@@ -395,7 +395,7 @@ class Application
395
395
  end
396
396
 
397
397
  def setup_logs
398
- handle_logdest_arg(Puppet[:logdest])
398
+ handle_logdest_arg(Puppet[:logdest]) if !options[:setdest]
399
399
 
400
400
  unless options[:setdest]
401
401
  if options[:debug] || options[:verbose]
@@ -418,7 +418,7 @@ class Application
418
418
  end
419
419
 
420
420
  def handle_logdest_arg(arg)
421
- return if options[:setdest] || arg.nil?
421
+ return if arg.nil?
422
422
 
423
423
  begin
424
424
  Puppet[:logdest] = arg
@@ -19,23 +19,36 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
19
19
 
20
20
  commands :gemcmd => "gem"
21
21
 
22
+ # CommandDefiner in provider.rb creates convenience execution methods that set failonfail, combine, and optionally, environment.
23
+ # And when a child provider defines its own command via commands() or has_command(), the provider-specific path is always returned by command().
24
+ # But when the convenience execution method is invoked, the last convenience method to be defined is executed.
25
+ # This makes invoking those convenience execution methods unsuitable for inherited providers.
26
+ #
27
+ # In this case, causing the puppet_gem provider to inherit the parent gem provider's convenience gemcmd() methods, with the wrong path.
28
+
29
+ def self.execute_gem_command(command_options)
30
+ cmd = [command(:gemcmd)] << command_options
31
+
32
+ execute(cmd, {:failonfail => true, :combine => true, :custom_environment => {"HOME"=>ENV["HOME"]}})
33
+ end
34
+
22
35
  def self.gemlist(options)
23
- gem_list_command = [command(:gemcmd), "list"]
36
+ command_options = ["list"]
24
37
 
25
38
  if options[:local]
26
- gem_list_command << "--local"
39
+ command_options << "--local"
27
40
  else
28
- gem_list_command << "--remote"
41
+ command_options << "--remote"
29
42
  end
30
43
  if options[:source]
31
- gem_list_command << "--source" << options[:source]
44
+ command_options << "--source" << options[:source]
32
45
  end
33
46
  if name = options[:justme]
34
- gem_list_command << '\A' + name + '\z'
47
+ command_options << '\A' + name + '\z'
35
48
  end
36
49
 
37
50
  begin
38
- list = execute(gem_list_command, {:failonfail => true, :combine => true, :custom_environment => {"HOME"=>ENV["HOME"]}}).lines.
51
+ list = execute_gem_command(command_options).lines.
39
52
  map {|set| gemsplit(set) }.
40
53
  reject {|x| x.nil? }
41
54
  rescue Puppet::ExecutionFailure => detail
@@ -92,14 +105,27 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
92
105
  is.any? { |version| dependency.match?('', version) }
93
106
  end
94
107
 
108
+ def rubygem_version
109
+ command_options = ["--version"]
110
+
111
+ self.class.execute_gem_command(command_options)
112
+ end
113
+
95
114
  def install(useversion = true)
96
- command = [command(:gemcmd), "install"]
97
- command += install_options if resource[:install_options]
115
+ command_options = ["install"]
116
+ command_options += install_options if resource[:install_options]
117
+
98
118
  if Puppet::Util::Platform.windows?
99
119
  version = resource[:ensure]
100
- command << "-v" << %Q["#{version}"] if (! resource[:ensure].is_a? Symbol) and useversion
120
+ command_options << "-v" << %Q["#{version}"] if (! resource[:ensure].is_a? Symbol) and useversion
121
+ else
122
+ command_options << "-v" << resource[:ensure] if (! resource[:ensure].is_a? Symbol) and useversion
123
+ end
124
+
125
+ if Puppet::Util::Package.versioncmp(rubygem_version, '2.0.0') == -1
126
+ command_options << "--no-rdoc" << "--no-ri"
101
127
  else
102
- command << "-v" << resource[:ensure] if (! resource[:ensure].is_a? Symbol) and useversion
128
+ command_options << "--no-document"
103
129
  end
104
130
 
105
131
  if source = resource[:source]
@@ -112,35 +138,35 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
112
138
  case uri.scheme
113
139
  when nil
114
140
  # no URI scheme => interpret the source as a local file
115
- command << source
141
+ command_options << source
116
142
  when /file/i
117
- command << uri.path
143
+ command_options << uri.path
118
144
  when 'puppet'
119
145
  # we don't support puppet:// URLs (yet)
120
146
  raise Puppet::Error.new(_("puppet:// URLs are not supported as gem sources"))
121
147
  else
122
148
  # check whether it's an absolute file path to help Windows out
123
149
  if Puppet::Util.absolute_path?(source)
124
- command << source
150
+ command_options << source
125
151
  else
126
152
  # interpret it as a gem repository
127
- command << "--source" << "#{source}" << resource[:name]
153
+ command_options << "--source" << "#{source}" << resource[:name]
128
154
  end
129
155
  end
130
156
  else
131
- command << "--no-rdoc" << "--no-ri" << resource[:name]
157
+ command_options << resource[:name]
132
158
  end
133
159
 
134
- output = execute(command, {:failonfail => true, :combine => true, :custom_environment => {"HOME"=>ENV["HOME"]}})
135
- # Apparently some stupid gem versions don't exit non-0 on failure
160
+ output = self.class.execute_gem_command(command_options)
161
+ # Apparently some gem versions don't exit non-0 on failure
136
162
  self.fail _("Could not install: %{output}") % { output: output.chomp } if output.include?("ERROR")
137
163
  end
138
164
 
139
165
  def latest
140
166
  # This always gets the latest version available.
141
- gemlist_options = {:justme => resource[:name]}
142
- gemlist_options.merge!({:source => resource[:source]}) unless resource[:source].nil?
143
- hash = self.class.gemlist(gemlist_options)
167
+ options = {:justme => resource[:name]}
168
+ options.merge!({:source => resource[:source]}) unless resource[:source].nil?
169
+ hash = self.class.gemlist(options)
144
170
 
145
171
  hash[:ensure][0]
146
172
  end
@@ -150,14 +176,12 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
150
176
  end
151
177
 
152
178
  def uninstall
153
- command = [command(:gemcmd), "uninstall"]
154
- command << "--executables" << "--all" << resource[:name]
155
-
156
- command += uninstall_options if resource[:uninstall_options]
157
-
158
- output = execute(command, {:failonfail => true, :combine => true, :custom_environment => {"HOME"=>ENV["HOME"]}})
179
+ command_options = ["uninstall"]
180
+ command_options << "--executables" << "--all" << resource[:name]
181
+ command_options += uninstall_options if resource[:uninstall_options]
159
182
 
160
- # Apparently some stupid gem versions don't exit non-0 on failure
183
+ output = self.class.execute_gem_command(command_options)
184
+ # Apparently some gem versions don't exit non-0 on failure
161
185
  self.fail _("Could not uninstall: %{output}") % { output: output.chomp } if output.include?("ERROR")
162
186
  end
163
187
 
@@ -22,6 +22,7 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
22
22
  end
23
23
  end
24
24
 
25
+ defaultfor :operatingsystem => :amazon
25
26
  defaultfor :osfamily => :redhat, :operatingsystemmajrelease => (4..7).to_a
26
27
 
27
28
  def self.prefetch(packages)
@@ -302,7 +302,7 @@ Puppet::Type.type(:user).provide :directoryservice do
302
302
  merge_attribute_with_dscl('Groups', group, 'GroupMembers', @guid)
303
303
  end
304
304
  else
305
- merge_attribute_with_dscl('Users', @resource.name, self.class.ns_to_ds_attribute_map[attribute], value)
305
+ create_attribute_with_dscl('Users', @resource.name, self.class.ns_to_ds_attribute_map[attribute], value)
306
306
  end
307
307
  end
308
308
  end
@@ -429,11 +429,14 @@ Puppet::Type.type(:user).provide :directoryservice do
429
429
  # the case we rescue the error from dscl and alert the user.
430
430
  #
431
431
  # In the event that the user doesn't HAVE a value for the attribute, the
432
- # provider should use the -merge option with dscl to add the attribute value
432
+ # provider should use the -create option with dscl to add the attribute value
433
433
  # for the user record
434
434
  ['home', 'uid', 'gid', 'comment', 'shell'].each do |setter_method|
435
435
  define_method("#{setter_method}=") do |value|
436
436
  if @property_hash[setter_method.intern]
437
+ if self.class.get_os_version == '10.14' && %w(home uid).include?(setter_method)
438
+ raise Puppet::Error, "OS X version 10\.14 does not allow changing #{setter_method} using puppet"
439
+ end
437
440
  begin
438
441
  dscl '.', '-change', "/Users/#{resource.name}", self.class.ns_to_ds_attribute_map[setter_method.intern], @property_hash[setter_method.intern], value
439
442
  rescue Puppet::ExecutionFailure => e
@@ -442,7 +445,7 @@ Puppet::Type.type(:user).provide :directoryservice do
442
445
  end
443
446
  else
444
447
  begin
445
- dscl '.', '-merge', "/Users/#{resource.name}", self.class.ns_to_ds_attribute_map[setter_method.intern], value
448
+ dscl '.', '-create', "/Users/#{resource.name}", self.class.ns_to_ds_attribute_map[setter_method.intern], value
446
449
  rescue Puppet::ExecutionFailure => e
447
450
  raise Puppet::Error, "Cannot set the #{setter_method} value of '#{value}' for user " +
448
451
  "#{@resource.name} due to the following error: #{e.inspect}", e.backtrace
@@ -472,10 +475,19 @@ Puppet::Type.type(:user).provide :directoryservice do
472
475
  '/var/db/shadow/hash'
473
476
  end
474
477
 
478
+ # This method will create a given value using dscl
479
+ def create_attribute_with_dscl(path, username, keyname, value)
480
+ set_attribute_with_dscl('-create', path, username, keyname, value)
481
+ end
482
+
475
483
  # This method will merge in a given value using dscl
476
484
  def merge_attribute_with_dscl(path, username, keyname, value)
485
+ set_attribute_with_dscl('-merge', path, username, keyname, value)
486
+ end
487
+
488
+ def set_attribute_with_dscl(dscl_command, path, username, keyname, value)
477
489
  begin
478
- dscl '.', '-merge', "/#{path}/#{username}", keyname, value
490
+ dscl '.', dscl_command, "/#{path}/#{username}", keyname, value
479
491
  rescue Puppet::ExecutionFailure => detail
480
492
  raise Puppet::Error, "Could not set the dscl #{keyname} key with value: #{value} - #{detail.inspect}", detail.backtrace
481
493
  end
@@ -7,14 +7,6 @@ require 'puppet/ssl/state_machine'
7
7
  require 'puppet/rest/errors'
8
8
  require 'puppet/rest/routes'
9
9
 
10
- begin
11
- # This may fail when being loaded from Puppet Server. However loading the
12
- # client monkey patches the SSL Store and we need to have those monkey
13
- # patches in as soon as possible on the agent.
14
- require 'puppet/rest/client'
15
- rescue LoadError
16
- end
17
-
18
10
  # The class that manages all aspects of our SSL certificates --
19
11
  # private keys, public keys, requests, etc.
20
12
  class Puppet::SSL::Host
@@ -124,10 +116,6 @@ class Puppet::SSL::Host
124
116
  true
125
117
  end
126
118
 
127
- def http_client(ssl_context)
128
- Puppet::Rest::Client.new(ssl_context: ssl_context)
129
- end
130
-
131
119
  def certificate
132
120
  unless @certificate
133
121
  generate_key unless key
@@ -10,6 +10,7 @@ require 'puppet/ssl'
10
10
  class Puppet::SSL::Validator::DefaultValidator #< class Puppet::SSL::Validator
11
11
  attr_reader :peer_certs
12
12
  attr_reader :verify_errors
13
+ attr_reader :last_error
13
14
 
14
15
  FIVE_MINUTES_AS_SECONDS = 5 * 60
15
16
 
@@ -34,6 +35,8 @@ class Puppet::SSL::Validator::DefaultValidator #< class Puppet::SSL::Validator
34
35
  def reset!
35
36
  @peer_certs = []
36
37
  @verify_errors = []
38
+ @hostname = nil
39
+ @last_error = nil
37
40
  end
38
41
 
39
42
  # Performs verification of the SSL connection and collection of the
@@ -79,6 +82,22 @@ class Puppet::SSL::Validator::DefaultValidator #< class Puppet::SSL::Validator
79
82
  error_string = store_context.error_string || "OpenSSL error #{error}"
80
83
 
81
84
  case error
85
+ when OpenSSL::X509::V_OK
86
+ if @hostname
87
+ # chain is from leaf to root, opposite of the order that `call` is invoked
88
+ chain_cert = store_context.chain.first
89
+
90
+ # ruby 2.4 doesn't compare certs based on value, so force to DER byte array
91
+ if current_cert && chain_cert && current_cert.to_der == chain_cert.to_der && !OpenSSL::SSL.verify_certificate_identity(current_cert, @hostname)
92
+ @last_error = Puppet::SSL::CertMismatchError.new(current_cert, @hostname)
93
+ return false
94
+ else
95
+ @verify_errors << "#{error_string} for #{current_cert.subject.to_utf8}"
96
+ end
97
+ else
98
+ @verify_errors << "#{error_string} for #{current_cert.subject.to_utf8}"
99
+ end
100
+
82
101
  when OpenSSL::X509::V_ERR_CRL_NOT_YET_VALID
83
102
  # current_crl can be nil
84
103
  # https://github.com/ruby/ruby/blob/ruby_1_9_3/ext/openssl/ossl_x509store.c#L501-L510
@@ -113,6 +132,8 @@ class Puppet::SSL::Validator::DefaultValidator #< class Puppet::SSL::Validator
113
132
  # @api private
114
133
  #
115
134
  def setup_connection(connection, ssl_host = Puppet.lookup(:ssl_host))
135
+ @hostname = connection.address
136
+
116
137
  if ssl_certificates_are_present?
117
138
  connection.cert_store = ssl_host.ssl_store
118
139
  connection.ca_file = @ca_path
@@ -43,6 +43,8 @@ class Puppet::SSL::VerifierAdapter
43
43
  # @raise [Puppet::Error] server hostname does not match certificate
44
44
  # @raise [OpenSSL::SSL::SSLError] low-level SSL connection failure
45
45
  def handle_connection_error(http, error)
46
+ raise @validator.last_error if @validator.respond_to?(:last_error) && @validator.last_error
47
+
46
48
  Puppet::Util::SSL.handle_connection_error(error, @validator, http.address)
47
49
  end
48
50
  end
@@ -220,6 +220,10 @@ module Puppet
220
220
 
221
221
  See the `periodmatch` attribute for tuning whether to match
222
222
  times by their distance apart or by their specific value.
223
+
224
+ > **Tip**: You can use `period => never,` to prevent a resource from being applied
225
+ in the given `range`. This is useful if you need to create a blackout window to
226
+ perform sensitive operations without interruption.
223
227
  EOT
224
228
 
225
229
  newvalues(:hourly, :daily, :weekly, :monthly, :never)
@@ -6,7 +6,7 @@
6
6
  # Raketasks and such to set the version based on the output of `git describe`
7
7
 
8
8
  module Puppet
9
- PUPPETVERSION = '6.4.1'
9
+ PUPPETVERSION = '6.4.2'
10
10
 
11
11
  ##
12
12
  # version is a public API method intended to always provide a fast and
@@ -876,7 +876,7 @@ The time to wait for data to be read from an HTTP connection\. If nothing is rea
876
876
  The HTTP User\-Agent string to send when making network requests\.
877
877
  .
878
878
  .IP "\(bu" 4
879
- \fIDefault\fR: Puppet/6\.4\.1 Ruby/2\.4\.1\-p111 (x86_64\-linux)
879
+ \fIDefault\fR: Puppet/6\.4\.2 Ruby/2\.4\.1\-p111 (x86_64\-linux)
880
880
  .
881
881
  .IP "" 0
882
882
  .
data/man/man8/puppet.8 CHANGED
@@ -25,4 +25,4 @@ Specialized:
25
25
  catalog Compile, save, view, and convert catalogs\. describe Display help about resource types device Manage remote network devices doc Generate Puppet references epp Interact directly with the EPP template parser/renderer\. facts Retrieve and store facts\. filebucket Store and retrieve files in a filebucket generate Generates Puppet code from Ruby definitions\. node View and manage node definitions\. parser Interact directly with the parser\. script Run a puppet manifests as a script without compiling a catalog ssl Manage SSL keys and certificates for puppet SSL clients
26
26
  .
27
27
  .P
28
- See \'puppet help \fIsubcommand\fR \fIaction\fR\' for help on a specific subcommand action\. See \'puppet help \fIsubcommand\fR\' for help on a specific subcommand\. Puppet v6\.4\.1
28
+ See \'puppet help \fIsubcommand\fR \fIaction\fR\' for help on a specific subcommand action\. See \'puppet help \fIsubcommand\fR\' for help on a specific subcommand\. Puppet v6\.4\.2
@@ -72,8 +72,6 @@ describe Puppet::Network::HttpPool, unless: Puppet::Util::Platform.jruby? do
72
72
  expect {
73
73
  http.get('/')
74
74
  }.to raise_error { |err|
75
- pending("PUP-8213") if RUBY_VERSION.to_f >= 2.4
76
-
77
75
  expect(err).to be_instance_of(Puppet::SSL::CertMismatchError)
78
76
  expect(err.message).to match(/\AServer hostname '#{wrong_hostname}' did not match server certificate; expected one of (.+)/)
79
77
 
@@ -6,7 +6,6 @@ require 'getoptlong'
6
6
  require 'timeout'
7
7
 
8
8
  describe Puppet::Application do
9
-
10
9
  before(:each) do
11
10
  @app = Class.new(Puppet::Application).new
12
11
  @appclass = @app.class
@@ -350,7 +349,6 @@ describe Puppet::Application do
350
349
  end
351
350
 
352
351
  describe "when parsing command-line options" do
353
-
354
352
  before :each do
355
353
  allow(@app.command_line).to receive(:args).and_return([])
356
354
 
@@ -676,13 +674,6 @@ describe Puppet::Application do
676
674
  expect(@app.options[:setdest]).to be_truthy
677
675
  end
678
676
 
679
- it "does not set the log destination if setdest is true" do
680
- expect(Puppet::Util::Log).not_to receive(:newdestination)
681
- @app.options[:setdest] = true
682
-
683
- @app.handle_logdest_arg(test_arg)
684
- end
685
-
686
677
  it "does not set the log destination if arg is nil" do
687
678
  expect(Puppet::Util::Log).not_to receive(:newdestination)
688
679
 
@@ -1,6 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  context Puppet::Type.type(:package).provider(:gem) do
4
+
5
+ let(:provider_gem_cmd) { '/provider/gem' }
6
+
4
7
  context 'installing myresource' do
5
8
  let(:resource) do
6
9
  Puppet::Type.type(:package).new(
@@ -15,49 +18,61 @@ context Puppet::Type.type(:package).provider(:gem) do
15
18
  provider
16
19
  end
17
20
 
21
+ let(:execute_options) { {:failonfail => true, :combine => true, :custom_environment => {"HOME"=>ENV["HOME"]}} }
22
+
18
23
  before :each do
19
24
  resource.provider = provider
25
+ allow(described_class).to receive(:command).with(:gemcmd).and_return(provider_gem_cmd)
20
26
  end
21
27
 
22
28
  context "when installing" do
23
- it "should use the path to the gem" do
24
- allow(described_class).to receive(:command).with(:gemcmd).and_return("/my/gem")
25
- expect(provider).to receive(:execute).with(be_a(Array), be_a(Hash)) { |args| expect(args[0]).to eq("/my/gem") }.and_return("")
29
+ before :each do
30
+ allow(provider).to receive(:rubygem_version).and_return('1.9.9')
31
+ end
32
+
33
+ it "should use the path to the gem command" do
34
+ allow(described_class).to receive(:which).with(provider_gem_cmd).and_return(provider_gem_cmd)
35
+ expect(described_class).to receive(:execute).with(be_a(Array), execute_options) { |args| expect(args[0]).to eq(provider_gem_cmd) }.and_return("")
26
36
  provider.install
27
37
  end
28
38
 
29
39
  it "should specify that the gem is being installed" do
30
- expect(provider).to receive(:execute).with(be_a(Array), be_a(Hash)) { |args| expect(args[1]).to eq("install") }.and_return("")
40
+ expect(described_class).to receive(:execute_gem_command).with(be_a(Array)) { |args| expect(args[0]).to eq("install") }.and_return("")
41
+ provider.install
42
+ end
43
+
44
+ it "should specify that --rdoc should not be included when gem version is < 2.0.0" do
45
+ expect(described_class).to receive(:execute_gem_command).with(be_a(Array)) { |args| expect(args[1]).to eq("--no-rdoc") }.and_return("")
31
46
  provider.install
32
47
  end
33
48
 
34
- it "should specify that documentation should not be included" do
35
- expect(provider).to receive(:execute).with(be_a(Array), be_a(Hash)) { |args| expect(args[2]).to eq("--no-rdoc") }.and_return("")
49
+ it "should specify that --ri should not be included when gem version is < 2.0.0" do
50
+ expect(described_class).to receive(:execute_gem_command).with(be_a(Array)) { |args| expect(args[2]).to eq("--no-ri") }.and_return("")
36
51
  provider.install
37
52
  end
38
53
 
39
- it "should specify that RI should not be included" do
40
- expect(provider).to receive(:execute).with(be_a(Array), be_a(Hash)) { |args| expect(args[3]).to eq("--no-ri") }.and_return("")
54
+ it "should specify that --document should not be included when gem version is >= 2.0.0" do
55
+ allow(provider).to receive(:rubygem_version).and_return('2.0.0')
56
+ expect(described_class).to receive(:execute_gem_command).with(be_a(Array)) { |args| expect(args[1]).to eq("--no-document") }.and_return("")
41
57
  provider.install
42
58
  end
43
59
 
44
60
  it "should specify the package name" do
45
- expect(provider).to receive(:execute).with(be_a(Array), be_a(Hash)) { |args| expect(args[4]).to eq("myresource") }.and_return("")
61
+ expect(described_class).to receive(:execute_gem_command).with(be_a(Array)) { |args| expect(args[3]).to eq("myresource") }.and_return("")
46
62
  provider.install
47
63
  end
48
64
 
49
65
  it "should not append install_options by default" do
50
- expect(provider).to receive(:execute).with(be_a(Array), be_a(Hash)) { |args| expect(args.length).to eq(5) }.and_return("")
66
+ expect(described_class).to receive(:execute_gem_command).with(be_a(Array)) { |args| expect(args.length).to eq(4) }.and_return("")
51
67
  provider.install
52
68
  end
53
69
 
54
70
  it "should allow setting an install_options parameter" do
55
71
  resource[:install_options] = [ '--force', {'--bindir' => '/usr/bin' } ]
56
- expect(provider).to receive(:execute).with(be_a(Array), be_a(Hash)) do |args|
57
- expect(args[2]).to eq('--force')
58
- expect(args[3]).to eq('--bindir=/usr/bin')
59
- end.and_return('')
60
-
72
+ expect(described_class).to receive(:execute_gem_command).with(be_a(Array)) do |args|
73
+ expect(args[1]).to eq('--force')
74
+ expect(args[2]).to eq('--bindir=/usr/bin')
75
+ end.and_return("")
61
76
  provider.install
62
77
  end
63
78
 
@@ -65,7 +80,7 @@ context Puppet::Type.type(:package).provider(:gem) do
65
80
  context "as a normal file" do
66
81
  it "should use the file name instead of the gem name" do
67
82
  resource[:source] = "/my/file"
68
- expect(provider).to receive(:execute).with(be_a(Array), be_a(Hash)) { |args| expect(args[2]).to eq("/my/file") }.and_return("")
83
+ expect(described_class).to receive(:execute_gem_command).with(be_a(Array)) { |args| expect(args[3]).to eq("/my/file") }.and_return("")
69
84
  provider.install
70
85
  end
71
86
  end
@@ -73,7 +88,7 @@ context Puppet::Type.type(:package).provider(:gem) do
73
88
  context "as a file url" do
74
89
  it "should use the file name instead of the gem name" do
75
90
  resource[:source] = "file:///my/file"
76
- expect(provider).to receive(:execute).with(be_a(Array), be_a(Hash)) { |args| expect(args[2]).to eq("/my/file") }.and_return("")
91
+ expect(described_class).to receive(:execute_gem_command).with(be_a(Array)) { |args| expect(args[3]).to eq("/my/file") }.and_return("")
77
92
  provider.install
78
93
  end
79
94
  end
@@ -88,7 +103,7 @@ context Puppet::Type.type(:package).provider(:gem) do
88
103
  context "as a non-file and non-puppet url" do
89
104
  it "should treat the source as a gem repository" do
90
105
  resource[:source] = "http://host/my/file"
91
- expect(provider).to receive(:execute).with(be_a(Array), be_a(Hash)) { |args| expect(args[2..4]).to eq(["--source", "http://host/my/file", "myresource"]) }.and_return("")
106
+ expect(described_class).to receive(:execute_gem_command).with(be_a(Array)) { |args| expect(args[3..5]).to eq(["--source", "http://host/my/file", "myresource"]) }.and_return("")
92
107
  provider.install
93
108
  end
94
109
  end
@@ -96,7 +111,7 @@ context Puppet::Type.type(:package).provider(:gem) do
96
111
  context "as a windows path on windows", :if => Puppet::Util::Platform.windows? do
97
112
  it "should treat the source as a local path" do
98
113
  resource[:source] = "c:/this/is/a/path/to/a/gem.gem"
99
- expect(provider).to receive(:execute).with(be_a(Array), be_a(Hash)) { |args| expect(args[2]).to eq("c:/this/is/a/path/to/a/gem.gem") }.and_return("")
114
+ expect(described_class).to receive(:execute_gem_command).with(be_a(Array)) { |args| expect(args[3]).to eq("c:/this/is/a/path/to/a/gem.gem") }.and_return("")
100
115
  provider.install
101
116
  end
102
117
  end
@@ -139,16 +154,16 @@ context Puppet::Type.type(:package).provider(:gem) do
139
154
 
140
155
  context "#instances" do
141
156
  before do
142
- allow(described_class).to receive(:command).with(:gemcmd).and_return("/my/gem")
157
+ allow(described_class).to receive(:command).with(:gemcmd).and_return(provider_gem_cmd)
143
158
  end
144
159
 
145
160
  it "should return an empty array when no gems installed" do
146
- expect(described_class).to receive(:execute).with(%w{/my/gem list --local}, {:failonfail => true, :combine => true, :custom_environment => {"HOME"=>ENV["HOME"]}}).and_return("\n")
161
+ expect(described_class).to receive(:execute_gem_command).with(%w{list --local}).and_return("\n")
147
162
  expect(described_class.instances).to eq([])
148
163
  end
149
164
 
150
165
  it "should return ensure values as an array of installed versions" do
151
- expect(described_class).to receive(:execute).with(%w{/my/gem list --local}, {:failonfail => true, :combine => true, :custom_environment => {"HOME"=>ENV["HOME"]}}).and_return(<<-HEREDOC.gsub(/ /, ''))
166
+ expect(described_class).to receive(:execute_gem_command).with(%w{list --local}).and_return(<<-HEREDOC.gsub(/ /, ''))
152
167
  systemu (1.2.0)
153
168
  vagrant (0.8.7, 0.6.9)
154
169
  HEREDOC
@@ -160,7 +175,7 @@ context Puppet::Type.type(:package).provider(:gem) do
160
175
  end
161
176
 
162
177
  it "should ignore platform specifications" do
163
- expect(described_class).to receive(:execute).with(%w{/my/gem list --local}, {:failonfail => true, :combine => true, :custom_environment => {"HOME"=>ENV["HOME"]}}).and_return(<<-HEREDOC.gsub(/ /, ''))
178
+ expect(described_class).to receive(:execute_gem_command).with(%w{list --local}).and_return(<<-HEREDOC.gsub(/ /, ''))
164
179
  systemu (1.2.0)
165
180
  nokogiri (1.6.1 ruby java x86-mingw32 x86-mswin32-60, 1.4.4.1 x86-mswin32)
166
181
  HEREDOC
@@ -172,7 +187,7 @@ context Puppet::Type.type(:package).provider(:gem) do
172
187
  end
173
188
 
174
189
  it "should not list 'default: ' text from rubygems''" do
175
- expect(described_class).to receive(:execute).with(%w{/my/gem list --local}, anything).and_return(<<-HEREDOC.gsub(/ /, ''))
190
+ expect(described_class).to receive(:execute_gem_command).with(%w{list --local}).and_return(<<-HEREDOC.gsub(/ /, ''))
176
191
  bundler (1.16.1, default: 1.16.0, 1.15.1)
177
192
  HEREDOC
178
193
 
@@ -182,8 +197,7 @@ context Puppet::Type.type(:package).provider(:gem) do
182
197
  end
183
198
 
184
199
  it "should not fail when an unmatched line is returned" do
185
- expect(described_class).to receive(:execute).with(%w{/my/gem list --local}, {:failonfail => true, :combine => true, :custom_environment => {"HOME"=>ENV["HOME"]}}).
186
- and_return(File.read(my_fixture('line-with-1.8.5-warning')))
200
+ expect(described_class).to receive(:execute_gem_command).with(%w{list --local}).and_return(File.read(my_fixture('line-with-1.8.5-warning')))
187
201
 
188
202
  expect(described_class.instances.map {|p| p.properties}).
189
203
  to eq([{provider: :gem, ensure: ["0.3.2"], name: "columnize"},
@@ -202,7 +216,7 @@ context Puppet::Type.type(:package).provider(:gem) do
202
216
  context "listing gems" do
203
217
  context "searching for a single package" do
204
218
  it "searches for an exact match" do
205
- expect(described_class).to receive(:execute).with(include('\Abundler\z'), {:failonfail => true, :combine => true, :custom_environment => {"HOME"=>ENV["HOME"]}}).and_return(File.read(my_fixture('gem-list-single-package')))
219
+ expect(described_class).to receive(:execute_gem_command).with(include('\Abundler\z')).and_return(File.read(my_fixture('gem-list-single-package')))
206
220
  expected = {:name => 'bundler', :ensure => %w[1.6.2], :provider => :gem}
207
221
  expect(described_class.gemlist({:justme => 'bundler'})).to eq(expected)
208
222
  end
@@ -294,49 +308,51 @@ context Puppet::Type.type(:package).provider(:gem) do
294
308
  provider
295
309
  end
296
310
 
311
+ let(:execute_options) { {:failonfail => true, :combine => true, :custom_environment => {"HOME"=>ENV["HOME"]}} }
312
+
297
313
  before :each do
298
314
  resource.provider = provider
315
+ allow(described_class).to receive(:command).with(:gemcmd).and_return(provider_gem_cmd)
299
316
  end
300
317
 
301
318
  context "when uninstalling" do
302
- it "should use the path to the gem" do
303
- allow(described_class).to receive(:command).with(:gemcmd).and_return("/my/gem")
304
- expect(provider).to receive(:execute).with(be_a(Array), be_a(Hash)) { |args| expect(args[0]).to eq("/my/gem") }.and_return("")
319
+ it "should use the path to the gem command" do
320
+ allow(described_class).to receive(:which).with(provider_gem_cmd).and_return(provider_gem_cmd)
321
+ expect(described_class).to receive(:execute).with(be_a(Array), execute_options) { |args| expect(args[0]).to eq(provider_gem_cmd) }.and_return("")
305
322
  provider.uninstall
306
323
  end
307
324
 
308
325
  it "should specify that the gem is being uninstalled" do
309
- expect(provider).to receive(:execute).with(be_a(Array), be_a(Hash)) { |args| expect(args[1]).to eq("uninstall") }.and_return("")
326
+ expect(described_class).to receive(:execute_gem_command).with(be_a(Array)) { |args| expect(args[0]).to eq("uninstall") }.and_return("")
310
327
  provider.uninstall
311
328
  end
312
329
 
313
330
  it "should specify that the relevant executables should be removed without confirmation" do
314
- expect(provider).to receive(:execute).with(be_a(Array), be_a(Hash)) { |args| expect(args[2]).to eq("--executables") }.and_return("")
331
+ expect(described_class).to receive(:execute_gem_command).with(be_a(Array)) { |args| expect(args[1]).to eq("--executables") }.and_return("")
315
332
  provider.uninstall
316
333
  end
317
334
 
318
335
  it "should specify that all the matching versions should be removed" do
319
- expect(provider).to receive(:execute).with(be_a(Array), be_a(Hash)) { |args| expect(args[3]).to eq("--all") }.and_return("")
336
+ expect(described_class).to receive(:execute_gem_command).with(be_a(Array)) { |args| expect(args[2]).to eq("--all") }.and_return("")
320
337
  provider.uninstall
321
338
  end
322
339
 
323
340
  it "should specify the package name" do
324
- expect(provider).to receive(:execute).with(be_a(Array), be_a(Hash)) { |args| expect(args[4]).to eq("myresource") }.and_return("")
341
+ expect(described_class).to receive(:execute_gem_command).with(be_a(Array)) { |args| expect(args[3]).to eq("myresource") }.and_return("")
325
342
  provider.uninstall
326
343
  end
327
344
 
328
345
  it "should not append uninstall_options by default" do
329
- expect(provider).to receive(:execute).with(be_a(Array), be_a(Hash)) { |args| expect(args.length).to eq(5) }.and_return("")
346
+ expect(described_class).to receive(:execute_gem_command).with(be_a(Array)) { |args| expect(args.length).to eq(4) }.and_return("")
330
347
  provider.uninstall
331
348
  end
332
349
 
333
350
  it "should allow setting an uninstall_options parameter" do
334
351
  resource[:uninstall_options] = [ '--ignore-dependencies', {'--version' => '0.1.1' } ]
335
- expect(provider).to receive(:execute).with(be_a(Array), be_a(Hash)) do |args|
336
- expect(args[5]).to eq('--ignore-dependencies')
337
- expect(args[6]).to eq('--version=0.1.1')
352
+ expect(described_class).to receive(:execute_gem_command).with(be_a(Array)) do |args|
353
+ expect(args[4]).to eq('--ignore-dependencies')
354
+ expect(args[5]).to eq('--version=0.1.1')
338
355
  end.and_return('')
339
-
340
356
  provider.uninstall
341
357
  end
342
358
  end