puppet 6.0.8-x86-mingw32 → 6.0.9-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: 622f43fc6dfd39c4e90363425e8cbcb2e279cc1728987cb4a1826c5d918d7c7e
4
- data.tar.gz: c56c547581d9a970566832f73216f036cc1a5cf769f394905f802452bb9c95a2
3
+ metadata.gz: 5a46edad8e6ed57e6dcd5e7226b7e3e63e383e54b28d9c81d03fa728dc7950b3
4
+ data.tar.gz: e2b828e8f8d8158e6b28bdd1114db66a3f2a8aeb6ea0801cc4f8250c0fe60280
5
5
  SHA512:
6
- metadata.gz: 294f6def76ede4f963f8ed4606dd4c0e5252c8da5dc199028a1bad8f062ab8f7ab311db2222f3cfde7cf1a38bfeb6b75320b232b25e4c7d5b3177a9bd7acf533
7
- data.tar.gz: 9a41a8ef368a5bddd1ddf757c34db04fb381bed0091b14f6f50120bb35653433c88ab6463bfefe4947c1e59033f5a3bb9606605efebfbf4730c4c510b6dfb458
6
+ metadata.gz: fbfa878e88e81400eef145fe19fe6ced888d2ce7c8cd049b426d9924707cdc2322df46ac1caf17a50ad8a9c1f4679adfea3c403bdc778542396f423fb4c02c9f
7
+ data.tar.gz: 2e568d3face781a7de7762619e98297e3cb2490cd7d17247c3799f830536c58dd26a990be28d4442f08da25b77433e9f507a7c60560feaddc87b1309c0228675
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- puppet (6.0.8)
4
+ puppet (6.0.9)
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,15 +47,15 @@ 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.24)
54
+ packaging (0.99.29)
55
55
  artifactory (~> 2)
56
56
  rake (~> 12.3)
57
57
  parallel (1.17.0)
58
- parser (2.6.2.0)
58
+ parser (2.6.2.1)
59
59
  ast (~> 2.4.0)
60
60
  powerpack (0.1.2)
61
61
  pry (0.12.2)
@@ -84,10 +84,10 @@ 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
- rspec-its (1.2.0)
90
+ rspec-its (1.3.0)
91
91
  rspec-core (>= 3.0.0)
92
92
  rspec-expectations (>= 3.0.0)
93
93
  rspec-mocks (3.8.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
 
@@ -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
@@ -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.0.8'
9
+ PUPPETVERSION = '6.0.9'
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\.0\.8 Ruby/2\.4\.1\-p111 (x86_64\-linux)
879
+ \fIDefault\fR: Puppet/6\.0\.9 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\.0\.8
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\.0\.9
@@ -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
@@ -15,70 +15,58 @@ describe Puppet::Type.type(:package).provider(:puppet_gem) do
15
15
  end
16
16
 
17
17
  if Puppet::Util::Platform.windows?
18
- let(:puppet_gem) { 'gem' }
18
+ let(:provider_gem_cmd) { 'gem' }
19
19
  else
20
- let(:puppet_gem) { '/opt/puppetlabs/puppet/bin/gem' }
20
+ let(:provider_gem_cmd) { '/opt/puppetlabs/puppet/bin/gem' }
21
21
  end
22
22
 
23
+ let(:execute_options) { {:failonfail => true, :combine => true, :custom_environment => {"HOME"=>ENV["HOME"]}} }
24
+
23
25
  before :each do
24
26
  resource.provider = provider
27
+ allow(described_class).to receive(:command).with(:gemcmd).and_return(provider_gem_cmd)
25
28
  end
26
29
 
27
30
  context "when installing" do
28
- it "should use the path to the gem" do
29
- expect(described_class).to receive(:which).with(puppet_gem).and_return(puppet_gem)
30
- expect(provider).to receive(:execute) do |args|
31
- expect(args[0]).to eq(puppet_gem)
32
- ''
33
- end
31
+ before :each do
32
+ allow(provider).to receive(:rubygem_version).and_return('1.9.9')
33
+ end
34
+
35
+ it "should use the path to the gem command" do
36
+ allow(described_class).to receive(:which).with(provider_gem_cmd).and_return(provider_gem_cmd)
37
+ expect(described_class).to receive(:execute).with(be_a(Array), execute_options) { |args| expect(args[0]).to eq(provider_gem_cmd) }.and_return('')
34
38
  provider.install
35
39
  end
36
40
 
37
41
  it "should not append install_options by default" do
38
- expect(provider).to receive(:execute) do |args|
39
- expect(args.length).to eq(5)
40
- ''
41
- end
42
+ expect(described_class).to receive(:execute_gem_command).with(%w{install --no-rdoc --no-ri myresource}).and_return('')
42
43
  provider.install
43
44
  end
44
45
 
45
46
  it "should allow setting an install_options parameter" do
46
47
  resource[:install_options] = [ '--force', {'--bindir' => '/usr/bin' } ]
47
- expect(provider).to receive(:execute) do |args|
48
- expect(args[2]).to eq('--force')
49
- expect(args[3]).to eq('--bindir=/usr/bin')
50
- ''
51
- end
48
+ expect(described_class).to receive(:execute_gem_command).with(%w{install --force --bindir=/usr/bin --no-rdoc --no-ri myresource}).and_return('')
52
49
  provider.install
53
50
  end
54
51
  end
55
52
 
56
53
  context "when uninstalling" do
57
- it "should use the path to the gem" do
58
- expect(described_class).to receive(:which).with(puppet_gem).and_return(puppet_gem)
59
- expect(provider).to receive(:execute) do |args|
60
- expect(args[0]).to eq(puppet_gem)
61
- ''
62
- end
63
- provider.install
54
+ it "should use the path to the gem command" do
55
+ allow(described_class).to receive(:which).with(provider_gem_cmd).and_return(provider_gem_cmd)
56
+ expect(described_class).to receive(:execute).with(be_a(Array), execute_options) { |args| expect(args[0]).to eq(provider_gem_cmd) }.and_return('')
57
+ provider.uninstall
64
58
  end
65
59
 
66
60
  it "should not append uninstall_options by default" do
67
- expect(provider).to receive(:execute) do |args|
68
- expect(args.length).to eq(5)
69
- ''
70
- end
61
+ expect(described_class).to receive(:execute_gem_command).with(%w{uninstall --executables --all myresource}).and_return('')
71
62
  provider.uninstall
72
63
  end
73
64
 
74
65
  it "should allow setting an uninstall_options parameter" do
75
66
  resource[:uninstall_options] = [ '--force', {'--bindir' => '/usr/bin' } ]
76
- expect(provider).to receive(:execute) do |args|
77
- expect(args[5]).to eq('--force')
78
- expect(args[6]).to eq('--bindir=/usr/bin')
79
- ''
80
- end
67
+ expect(described_class).to receive(:execute_gem_command).with(%w{uninstall --executables --all myresource --force --bindir=/usr/bin}).and_return('')
81
68
  provider.uninstall
82
69
  end
83
70
  end
71
+
84
72
  end
@@ -294,7 +294,7 @@ describe Puppet::Type.type(:user).provider(:directoryservice) do
294
294
  before :each do
295
295
  # Stub out all calls to dscl with default values from above
296
296
  defaults.each do |key, val|
297
- allow(provider).to receive(:merge_attribute_with_dscl).with('Users', username, key, val)
297
+ allow(provider).to receive(:create_attribute_with_dscl).with('Users', username, key, val)
298
298
  end
299
299
 
300
300
  # Mock the rest of the dscl calls. We can't assume that our Linux
@@ -327,11 +327,41 @@ describe Puppet::Type.type(:user).provider(:directoryservice) do
327
327
  it 'should convert group names into integers' do
328
328
  resource[:gid] = 'somegroup'
329
329
  expect(Puppet::Util).to receive(:gid).with('somegroup').and_return(21)
330
- expect(provider).to receive(:merge_attribute_with_dscl).with('Users', username, 'PrimaryGroupID', 21)
330
+ expect(provider).to receive(:create_attribute_with_dscl).with('Users', username, 'PrimaryGroupID', 21)
331
331
  provider.create
332
332
  end
333
333
  end
334
334
 
335
+ describe 'Update existing user' do
336
+ describe 'home=' do
337
+ context 'on OS X 10.14' do
338
+ before do
339
+ provider.instance_variable_set(:@property_hash, { home: 'value' })
340
+ allow(provider.class).to receive(:get_os_version).and_return('10.14')
341
+ end
342
+
343
+ it 'raises error' do
344
+ expect { provider.home = 'new' }.to \
345
+ raise_error(Puppet::Error, "OS X version 10.14 does not allow changing home using puppet")
346
+ end
347
+ end
348
+ end
349
+
350
+ describe 'uid=' do
351
+ context 'on OS X 10.14' do
352
+ before do
353
+ provider.instance_variable_set(:@property_hash, { uid: 'value' })
354
+ allow(provider.class).to receive(:get_os_version).and_return('10.14')
355
+ end
356
+
357
+ it 'raises error' do
358
+ expect { provider.uid = 'new' }.to \
359
+ raise_error(Puppet::Error, "OS X version 10.14 does not allow changing uid using puppet")
360
+ end
361
+ end
362
+ end
363
+ end
364
+
335
365
  describe 'self#instances' do
336
366
  it 'should create an array of provider instances' do
337
367
  expect(provider.class).to receive(:get_all_users).and_return(['foo', 'bar'])
@@ -988,6 +1018,13 @@ describe Puppet::Type.type(:user).provider(:directoryservice) do
988
1018
  end
989
1019
  end
990
1020
 
1021
+ describe '#create_attribute_with_dscl' do
1022
+ it 'should raise an error if a dscl command raises an error' do
1023
+ expect(provider).to receive(:dscl).with('.', '-create', user_path, 'GeneratedUID', 'GUID').and_raise(Puppet::ExecutionFailure, 'boom')
1024
+ expect { provider.create_attribute_with_dscl('Users', username, 'GeneratedUID', 'GUID') }.to raise_error Puppet::Error, /Could not set the dscl GeneratedUID key with value: GUID/
1025
+ end
1026
+ end
1027
+
991
1028
  describe '#get_users_plist' do
992
1029
  let(:test_hash) do
993
1030
  {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.8
4
+ version: 6.0.9
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-08 00:00:00.000000000 Z
11
+ date: 2019-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: facter