chef 12.14.60-universal-mingw32 → 12.14.77-universal-mingw32

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
  SHA1:
3
- metadata.gz: 17615e1b8262520715cc9191ca2a2f124a0df4a3
4
- data.tar.gz: 158ac7b68b7cc098d3759f904193f8ba9e42a3e9
3
+ metadata.gz: dd3133d9f0125db027bf7ad267c33797c07dc88d
4
+ data.tar.gz: 38a5f1305bac555ca1a4fabe60418e9058a7a776
5
5
  SHA512:
6
- metadata.gz: 80b01bd921acc1f719824a3b923780104a2cbc73b3b18357c89c9ba37f2dfea25a7eb9719c08c0b8d96e4f3b86ba60222eb0e6f00692ab2ee3c5ab9e4290ebcf
7
- data.tar.gz: 5e9b0ae9a16ad62111b4f2ec9a8e0ba3e30757fd7e8b21bee53f5ec619e420e078ca44df72a8201a489795b921ca437ca682ce3ecef87fd08927a34cc8a7885d
6
+ metadata.gz: b9d254221f6029b0eaf8a89efabce254cfdbb68b3330955c3d9720db777511fe9d42a1057b50877896a11939d4f29d4d63738d562d0c033c4985c8b8c0d393ef
7
+ data.tar.gz: 424c2475fd8d52ffb5d5def4efa294bae7c9de207f2d6b96dc3bd8b156b69979af0ec988ecdcbd71efc397995de210f47b4c7916a4c61a3babd5260d4da694cd
data/VERSION CHANGED
@@ -1 +1 @@
1
- 12.14.60
1
+ 12.14.77
@@ -10,13 +10,13 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  addressable (2.4.0)
13
- artifactory (2.3.3)
14
- aws-sdk (2.5.8)
15
- aws-sdk-resources (= 2.5.8)
16
- aws-sdk-core (2.5.8)
13
+ artifactory (2.5.0)
14
+ aws-sdk (2.6.1)
15
+ aws-sdk-resources (= 2.6.1)
16
+ aws-sdk-core (2.6.1)
17
17
  jmespath (~> 1.0)
18
- aws-sdk-resources (2.5.8)
19
- aws-sdk-core (= 2.5.8)
18
+ aws-sdk-resources (2.6.1)
19
+ aws-sdk-core (= 2.6.1)
20
20
  berkshelf (4.3.5)
21
21
  addressable (~> 2.3, >= 2.3.4)
22
22
  berkshelf-api-client (~> 2.0, >= 2.0.2)
@@ -53,7 +53,8 @@ GEM
53
53
  celluloid-io (0.16.2)
54
54
  celluloid (>= 0.16.0)
55
55
  nio4r (>= 1.1.0)
56
- chef-config (12.13.37)
56
+ chef-config (12.14.60)
57
+ addressable
57
58
  fuzzyurl
58
59
  mixlib-config (~> 2.0)
59
60
  mixlib-shellout (~> 2.0)
@@ -73,14 +74,15 @@ GEM
73
74
  ffi (>= 1.0.1)
74
75
  gyoku (1.3.1)
75
76
  builder (>= 2.1.2)
76
- hashie (3.4.4)
77
+ hashie (3.4.6)
77
78
  hitimes (1.2.4)
78
79
  httpclient (2.7.2)
79
- inspec (0.32.0)
80
+ inspec (0.34.1)
80
81
  hashie (~> 3.4)
81
82
  json (>= 1.8, < 3.0)
82
83
  method_source (~> 0.8)
83
84
  mixlib-log
85
+ parallel (~> 1.9)
84
86
  pry (~> 0)
85
87
  rainbow (~> 2)
86
88
  rspec (~> 3)
@@ -88,10 +90,10 @@ GEM
88
90
  rubyzip (~> 1.1)
89
91
  sslshake (~> 1)
90
92
  thor (~> 0.19)
91
- train (>= 0.16.0, < 1.0)
93
+ train (>= 0.19.0, < 1.0)
92
94
  jmespath (1.3.1)
93
95
  json (2.0.2)
94
- kitchen-ec2 (1.1.0)
96
+ kitchen-ec2 (1.2.0)
95
97
  aws-sdk (~> 2)
96
98
  excon
97
99
  multi_json
@@ -113,7 +115,7 @@ GEM
113
115
  mixlib-authentication (1.4.1)
114
116
  mixlib-log
115
117
  mixlib-config (2.2.4)
116
- mixlib-install (1.1.0)
118
+ mixlib-install (1.2.0)
117
119
  artifactory
118
120
  mixlib-shellout
119
121
  mixlib-versioning
@@ -132,6 +134,7 @@ GEM
132
134
  nori (2.6.0)
133
135
  octokit (4.3.0)
134
136
  sawyer (~> 0.7.0, >= 0.5.3)
137
+ parallel (1.9.0)
135
138
  pry (0.10.4)
136
139
  coderay (~> 1.1.0)
137
140
  method_source (~> 0.8.1)
@@ -172,7 +175,7 @@ GEM
172
175
  diff-lcs (>= 1.2.0, < 2.0)
173
176
  rspec-support (~> 3.5.0)
174
177
  rspec-support (3.5.0)
175
- rubyntlm (0.6.0)
178
+ rubyntlm (0.6.1)
176
179
  rubyzip (1.2.0)
177
180
  safe_yaml (1.0.4)
178
181
  sawyer (0.7.0)
@@ -184,8 +187,8 @@ GEM
184
187
  molinillo (~> 0.4.2)
185
188
  semverse (~> 1.1)
186
189
  sslshake (1.0.12)
187
- test-kitchen (1.12.0)
188
- mixlib-install (~> 1.0, >= 1.0.4)
190
+ test-kitchen (1.13.0)
191
+ mixlib-install (~> 1.2)
189
192
  mixlib-shellout (>= 1.2, < 3.0)
190
193
  net-scp (~> 1.1)
191
194
  net-ssh (>= 2.9, < 4.0)
@@ -195,7 +198,7 @@ GEM
195
198
  thor (0.19.1)
196
199
  timers (4.0.4)
197
200
  hitimes
198
- train (0.19.0)
201
+ train (0.19.1)
199
202
  docker-api (~> 1.26)
200
203
  json (>= 1.8, < 3.0)
201
204
  mixlib-shellout (~> 2.0)
@@ -208,7 +211,7 @@ GEM
208
211
  hashie (>= 2.0.2, < 4.0.0)
209
212
  windows_chef_zero (2.0.0)
210
213
  test-kitchen (>= 1.2.1)
211
- winrm (2.0.1)
214
+ winrm (2.0.2)
212
215
  builder (>= 2.1.2)
213
216
  erubis (~> 2.7)
214
217
  gssapi (~> 1.2)
@@ -216,7 +219,7 @@ GEM
216
219
  httpclient (~> 2.2, >= 2.2.0.2)
217
220
  logging (>= 1.6.1, < 3.0)
218
221
  nori (~> 2.0)
219
- rubyntlm (~> 0.6.0)
222
+ rubyntlm (~> 0.6.0, >= 0.6.1)
220
223
  winrm-elevated (1.0.0)
221
224
  winrm (~> 2.0)
222
225
  winrm-fs (~> 1.0)
@@ -40,7 +40,8 @@ class Chef
40
40
 
41
41
  tempfile_dirnames.each do |tempfile_dirname|
42
42
  begin
43
- tf = ::Tempfile.open(tempfile_basename, tempfile_dirname)
43
+ # preserving the file extension of the target filename should be considered a public API
44
+ tf = ::Tempfile.open([tempfile_basename, tempfile_extension], tempfile_dirname)
44
45
  break
45
46
  rescue SystemCallError => e
46
47
  message = "Creating temp file under '#{tempfile_dirname}' failed with: '#{e.message}'"
@@ -63,12 +64,21 @@ class Chef
63
64
  # as the arguments to Tempfile.new() consistently.
64
65
  #
65
66
  def tempfile_basename
66
- basename = ::File.basename(@new_resource.name)
67
+ basename = ::File.basename(@new_resource.path, tempfile_extension)
68
+ # the leading "[.]chef-" here should be considered a public API and should not be changed
67
69
  basename.insert 0, "chef-"
68
70
  basename.insert 0, "." unless Chef::Platform.windows? # dotfile if we're not on windows
69
71
  basename
70
72
  end
71
73
 
74
+ # this is similar to File.extname() but greedy about the extension (from the first dot, not the last dot)
75
+ def tempfile_extension
76
+ # complexity here is due to supporting mangling non-UTF8 strings (e.g. latin-1 filenames with characters that are illegal in UTF-8)
77
+ b = File.basename(@new_resource.path)
78
+ i = b.index(".")
79
+ i.nil? ? "" : b[i..-1]
80
+ end
81
+
72
82
  # Returns the possible directories for the tempfile to be created in.
73
83
  def tempfile_dirnames
74
84
  # in why-run mode we need to create a Tempfile to compare against, which we will never
@@ -45,7 +45,7 @@ class Chef
45
45
  # true:: Always return true
46
46
  def action_write
47
47
  Chef::Log.send(@new_resource.level, @new_resource.message)
48
- @new_resource.updated_by_last_action(true)
48
+ @new_resource.updated_by_last_action(true) if Chef::Config[:count_log_resource_updates]
49
49
  end
50
50
 
51
51
  end
@@ -102,6 +102,9 @@ class Chef
102
102
  @new_resource.unscrubbed_values.each do |value|
103
103
  if @name_hash.has_key?(value[:name].downcase)
104
104
  current_value = @name_hash[value[:name].downcase]
105
+ if [:dword, :dword_big_endian, :qword].include? value[:type]
106
+ value[:data] = value[:data].to_i
107
+ end
105
108
  unless current_value[:type] == value[:type] && current_value[:data] == value[:data]
106
109
  converge_by("set value #{value}") do
107
110
  registry.set_value(@new_resource.key, value)
@@ -52,14 +52,14 @@ class Chef
52
52
  opts << "-s" << new_resource.shell if should_set?(:shell)
53
53
  opts << "-u" << new_resource.uid if should_set?(:uid)
54
54
  opts << "-d" << new_resource.home if updating_home?
55
- opts << "-o" if new_resource.non_unique
55
+ opts << "-o" if non_unique
56
56
  opts
57
57
  end
58
58
 
59
59
  def usermod_options
60
60
  opts = []
61
61
  if updating_home?
62
- if new_resource.manage_home
62
+ if manage_home
63
63
  opts << "-m"
64
64
  end
65
65
  end
@@ -69,7 +69,7 @@ class Chef
69
69
  def useradd_options
70
70
  opts = []
71
71
  opts << "-r" if new_resource.system
72
- if new_resource.manage_home
72
+ if manage_home
73
73
  opts << "-m"
74
74
  else
75
75
  opts << "-M"
@@ -79,7 +79,7 @@ class Chef
79
79
 
80
80
  def userdel_options
81
81
  opts = []
82
- opts << "-r" if new_resource.manage_home
82
+ opts << "-r" if manage_home
83
83
  opts << "-f" if new_resource.force
84
84
  opts
85
85
  end
@@ -122,6 +122,16 @@ class Chef
122
122
  # FIXME: should probably go on the current_resource
123
123
  @locked
124
124
  end
125
+
126
+ def non_unique
127
+ # XXX: THIS GOES AWAY IN CHEF-13 AND BECOMES JUST new_resource.non_unique
128
+ new_resource.non_unique || new_resource.supports[:non_unique]
129
+ end
130
+
131
+ def manage_home
132
+ # XXX: THIS GOES AWAY IN CHEF-13 AND BECOMES JUST new_resource.manage_home
133
+ new_resource.manage_home || new_resource.supports[:manage_home]
134
+ end
125
135
  end
126
136
  end
127
137
  end
@@ -28,6 +28,10 @@ class Chef
28
28
  "#{new_resource || "<no resource>"} action #{action ? action.inspect : "<no action>"}"
29
29
  end
30
30
 
31
+ def whyrun_supported?
32
+ true
33
+ end
34
+
31
35
  #
32
36
  # If load_current_value! is defined on the resource, use that.
33
37
  #
@@ -81,7 +81,7 @@ class Chef
81
81
  end
82
82
 
83
83
  def special_docker_files?(file)
84
- %w{/etc/hosts /etc/hostname /etc/resolv.conf}.include?(Pathname(file).cleanpath.to_path)
84
+ %w{/etc/hosts /etc/hostname /etc/resolv.conf}.include?(Pathname(file.scrub).cleanpath.to_path)
85
85
  end
86
86
  end
87
87
  end
@@ -155,6 +155,20 @@ class Chef
155
155
  :kind_of => [ TrueClass, FalseClass ]
156
156
  )
157
157
  end
158
+
159
+ def supports(args = {})
160
+ if args.key?(:manage_home)
161
+ Chef.log_deprecation "supports { manage_home: #{args[:manage_home]} } on the user resource is deprecated and will be removed in Chef 13, set manage_home: #{args[:manage_home]} instead"
162
+ end
163
+ if args.key?(:non_unique)
164
+ Chef.log_deprecation "supports { non_unique: #{args[:non_unique]} } on the user resource is deprecated and will be removed in Chef 13, set non_unique: #{args[:non_unique]} instead"
165
+ end
166
+ super
167
+ end
168
+
169
+ def supports=(args)
170
+ supports(args)
171
+ end
158
172
  end
159
173
  end
160
174
  end
@@ -29,22 +29,12 @@ class Chef
29
29
  def initialize(name, run_context = nil)
30
30
  super
31
31
  @supports = {
32
- manage_home: true,
33
- non_unique: true,
32
+ manage_home: false,
33
+ non_unique: false,
34
34
  }
35
35
  @manage_home = false
36
36
  end
37
37
 
38
- def supports(args = {})
39
- Chef.log_deprecation "setting supports on the linux_user resource is deprecated"
40
- # setting is deliberately disabled
41
- super({})
42
- end
43
-
44
- def supports=(args)
45
- # setting is deliberately disabled
46
- supports({})
47
- end
48
38
  end
49
39
  end
50
40
  end
@@ -29,7 +29,7 @@ class Chef
29
29
  property :cost, String, regex: /^\d+$/
30
30
  property :clean_headers, [TrueClass, FalseClass], default: false # deprecated
31
31
  property :clean_metadata, [TrueClass, FalseClass], default: true
32
- property :description, String, regex: /.*/, default: "Ye Ole Rpm Repo"
32
+ property :description, String, regex: /.*/, default: "Yum Repository"
33
33
  property :enabled, [TrueClass, FalseClass], default: true
34
34
  property :enablegroups, [TrueClass, FalseClass]
35
35
  property :exclude, String, regex: /.*/
@@ -66,11 +66,14 @@ class Chef
66
66
  property :sslclientkey, String, regex: /.*/
67
67
  property :sslverify, [TrueClass, FalseClass]
68
68
  property :timeout, String, regex: /^\d+$/
69
-
70
69
  property :options, Hash
71
70
 
72
71
  default_action :create
73
- allowed_actions :create, :remove, :make_cache, :add
72
+ allowed_actions :create, :remove, :make_cache, :add, :delete
73
+
74
+ # provide compatibility with the yum cookbook < 3.0 properties
75
+ alias_method :url, :baseurl
76
+ alias_method :keyurl, :gpgkey
74
77
  end
75
78
  end
76
79
  end
@@ -21,7 +21,7 @@
21
21
 
22
22
  class Chef
23
23
  CHEF_ROOT = File.expand_path("../..", __FILE__)
24
- VERSION = "12.14.60"
24
+ VERSION = "12.14.77"
25
25
  end
26
26
 
27
27
  #
@@ -99,8 +99,12 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
99
99
  usr
100
100
  end
101
101
 
102
- def create_user(username)
103
- user(username).run_action(:create) if ! windows_domain_user?(username)
102
+ def create_user(username, uid = nil)
103
+ if ! windows_domain_user?(username)
104
+ user_to_create = user(username)
105
+ user_to_create.uid(uid) if uid
106
+ user_to_create.run_action(:create)
107
+ end
104
108
  # TODO: User should exist
105
109
  end
106
110
 
@@ -169,8 +173,11 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
169
173
 
170
174
  describe "when the users exist" do
171
175
  before do
176
+ high_uid = 30000
172
177
  (spec_members).each do |member|
173
- create_user(member)
178
+ remove_user(member)
179
+ create_user(member, high_uid)
180
+ high_uid += 1
174
181
  end
175
182
  end
176
183
 
@@ -296,6 +303,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
296
303
  group = Chef::Resource::Group.new(group_name, run_context)
297
304
  group.members(included_members)
298
305
  group.excluded_members(excluded_members)
306
+ group.gid(30000) unless ohai[:platform_family] == "mac_os_x"
299
307
  group
300
308
  end
301
309
 
@@ -153,6 +153,16 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
153
153
  expect(@registry.data_exists?(reg_child, { :name => "Color", :type => :string, :data => "Orange" })).to eq(true)
154
154
  end
155
155
 
156
+ it "does not create the key if it already exists with same value and type but datatype of data differs" do
157
+ @new_resource.key(reg_child)
158
+ @new_resource.values([{ :name => "number", :type => :dword, :data => "12345" }])
159
+ @new_resource.run_action(:create)
160
+
161
+ expect(@new_resource).not_to be_updated_by_last_action
162
+ expect(@registry.key_exists?(reg_child)).to eq(true)
163
+ expect(@registry.data_exists?(reg_child, { :name => "number", :type => :dword, :data => 12344 })).to eq(true)
164
+ end
165
+
156
166
  it "creates a value if it does not exist" do
157
167
  @new_resource.key(reg_child)
158
168
  @new_resource.values([{ :name => "Mango", :type => :string, :data => "Yellow" }])
@@ -9,54 +9,70 @@ module ResourceActionSpec
9
9
  shared_context "ActionJackson" do
10
10
  it "the default action is the first declared action" do
11
11
  converge <<-EOM, __FILE__, __LINE__ + 1
12
- #{resource_dsl} "hi" do
13
- foo "foo!"
14
- end
15
- EOM
12
+ #{resource_dsl} "hi" do
13
+ foo "foo!"
14
+ end
15
+ EOM
16
16
  expect(ActionJackson.ran_action).to eq :access_recipe_dsl
17
17
  expect(ActionJackson.succeeded).to eq true
18
18
  end
19
19
 
20
+ context "when running in whyrun mode" do
21
+ before do
22
+ Chef::Config[:why_run] = true
23
+ end
24
+
25
+ it "the default action runs" do
26
+ converge <<-EOM, __FILE__, __LINE__ + 1
27
+ #{resource_dsl} "hi" do
28
+ foo "foo!"
29
+ end
30
+ EOM
31
+ expect(ActionJackson.ran_action).to eq :access_recipe_dsl
32
+ expect(ActionJackson.succeeded).to eq true
33
+ end
34
+ end
35
+
20
36
  it "the action can access recipe DSL" do
21
37
  converge <<-EOM, __FILE__, __LINE__ + 1
22
- #{resource_dsl} "hi" do
23
- foo "foo!"
24
- action :access_recipe_dsl
25
- end
26
- EOM
38
+ #{resource_dsl} "hi" do
39
+ foo "foo!"
40
+ action :access_recipe_dsl
41
+ end
42
+ EOM
27
43
  expect(ActionJackson.ran_action).to eq :access_recipe_dsl
28
44
  expect(ActionJackson.succeeded).to eq true
29
45
  end
30
46
 
31
47
  it "the action can access attributes" do
32
48
  converge <<-EOM, __FILE__, __LINE__ + 1
33
- #{resource_dsl} "hi" do
34
- foo "foo!"
35
- action :access_attribute
36
- end
37
- EOM
49
+ #{resource_dsl} "hi" do
50
+ foo "foo!"
51
+ action :access_attribute
52
+ end
53
+ EOM
38
54
  expect(ActionJackson.ran_action).to eq :access_attribute
39
55
  expect(ActionJackson.succeeded).to eq "foo!"
40
56
  end
41
57
 
42
58
  it "the action can access public methods" do
43
59
  converge <<-EOM, __FILE__, __LINE__ + 1
44
- #{resource_dsl} "hi" do
45
- foo "foo!"
46
- action :access_method
47
- end
48
- EOM
60
+ #{resource_dsl} "hi" do
61
+ foo "foo!"
62
+ action :access_method
63
+ end
64
+ EOM
49
65
  expect(ActionJackson.ran_action).to eq :access_method
50
66
  expect(ActionJackson.succeeded).to eq "foo_public!"
51
67
  end
52
68
 
53
69
  it "the action can access protected methods" do
54
70
  converge <<-EOM, __FILE__, __LINE__ + 1
55
- #{resource_dsl} "hi" do
56
- foo "foo!"
57
- action :access_protected_method
58
- end
59
- EOM
71
+ #{resource_dsl} "hi" do
72
+ foo "foo!"
73
+ action :access_protected_method
74
+ end
75
+ EOM
60
76
  expect(ActionJackson.ran_action).to eq :access_protected_method
61
77
  expect(ActionJackson.succeeded).to eq "foo_protected!"
62
78
  end
@@ -64,39 +80,39 @@ module ResourceActionSpec
64
80
  it "the action cannot access private methods" do
65
81
  expect do
66
82
  converge(<<-EOM, __FILE__, __LINE__ + 1)
67
- #{resource_dsl} "hi" do
68
- foo "foo!"
69
- action :access_private_method
70
- end
71
- EOM
83
+ #{resource_dsl} "hi" do
84
+ foo "foo!"
85
+ action :access_private_method
86
+ end
87
+ EOM
72
88
  end.to raise_error(NameError)
73
89
  expect(ActionJackson.ran_action).to eq :access_private_method
74
90
  end
75
91
 
76
92
  it "the action cannot access resource instance variables" do
77
93
  converge <<-EOM, __FILE__, __LINE__ + 1
78
- #{resource_dsl} "hi" do
79
- foo "foo!"
80
- action :access_instance_variable
81
- end
82
- EOM
94
+ #{resource_dsl} "hi" do
95
+ foo "foo!"
96
+ action :access_instance_variable
97
+ end
98
+ EOM
83
99
  expect(ActionJackson.ran_action).to eq :access_instance_variable
84
100
  expect(ActionJackson.succeeded).to be_nil
85
101
  end
86
102
 
87
103
  it "the action does not compile until the prior resource has converged" do
88
104
  converge <<-EOM, __FILE__, __LINE__ + 1
89
- ruby_block "wow" do
90
- block do
91
- ResourceActionSpec::ActionJackson.ruby_block_converged = "ruby_block_converged!"
105
+ ruby_block "wow" do
106
+ block do
107
+ ResourceActionSpec::ActionJackson.ruby_block_converged = "ruby_block_converged!"
108
+ end
92
109
  end
93
- end
94
110
 
95
- #{resource_dsl} "hi" do
96
- foo "foo!"
97
- action :access_class_method
98
- end
99
- EOM
111
+ #{resource_dsl} "hi" do
112
+ foo "foo!"
113
+ action :access_class_method
114
+ end
115
+ EOM
100
116
  expect(ActionJackson.ran_action).to eq :access_class_method
101
117
  expect(ActionJackson.succeeded).to eq "ruby_block_converged!"
102
118
  end
@@ -141,7 +157,7 @@ module ResourceActionSpec
141
157
 
142
158
  action :access_recipe_dsl do
143
159
  ActionJackson.ran_action = :access_recipe_dsl
144
- ruby_block "hi there" do
160
+ whyrun_safe_ruby_block "hi there" do
145
161
  block do
146
162
  ActionJackson.succeeded = true
147
163
  end
@@ -19,38 +19,59 @@
19
19
  require "spec_helper"
20
20
 
21
21
  describe Chef::FileContentManagement::Tempfile do
22
- let(:resource) do
23
- r = Chef::Resource::File.new("new_file")
24
- r.path "/foo/bar/new_file"
25
- r
26
- end
27
22
 
28
- subject { described_class.new(resource) }
23
+ def tempfile_object_for_path(path)
24
+ r = Chef::Resource::File.new("decorative name that should not matter")
25
+ r.path path
26
+ Chef::FileContentManagement::Tempfile.new(r)
27
+ end
29
28
 
30
29
  describe "#tempfile_basename" do
31
30
  it "should return a dotfile", :unix_only do
31
+ subject = tempfile_object_for_path("/foo/bar/new_file")
32
32
  expect(subject.send(:tempfile_basename)).to eql(".chef-new_file")
33
33
  end
34
34
 
35
35
  it "should return a file", :windows_only do
36
+ subject = tempfile_object_for_path("/foo/bar/new_file")
36
37
  expect(subject.send(:tempfile_basename)).to eql("chef-new_file")
37
38
  end
39
+
40
+ it "should strip the extension", :unix_only do
41
+ subject = tempfile_object_for_path("/foo/bar/new_file.html.erb")
42
+ expect(subject.send(:tempfile_basename)).to eql(".chef-new_file")
43
+ end
44
+
45
+ it "should strip the extension", :windows_only do
46
+ subject = tempfile_object_for_path("/foo/bar/new_file.html.erb")
47
+ expect(subject.send(:tempfile_basename)).to eql("chef-new_file")
48
+ end
49
+ end
50
+
51
+ describe "#tempfile_extension" do
52
+ it "should preserve the file extension" do
53
+ subject = tempfile_object_for_path("/foo/bar/new_file.html.erb")
54
+ expect(subject.send(:tempfile_extension)).to eql(".html.erb")
55
+ end
38
56
  end
39
57
 
40
58
  describe "#tempfile_dirnames" do
41
59
 
42
60
  it "should select a temp dir" do
61
+ subject = tempfile_object_for_path("/foo/bar/new_file")
43
62
  Chef::Config[:file_staging_uses_destdir] = false
44
63
  expect(Dir).to receive(:tmpdir).and_return("/tmp/dir")
45
64
  expect(subject.send(:tempfile_dirnames)).to eql(%w{ /tmp/dir })
46
65
  end
47
66
 
48
67
  it "should select the destdir" do
68
+ subject = tempfile_object_for_path("/foo/bar/new_file")
49
69
  Chef::Config[:file_staging_uses_destdir] = true
50
70
  expect(subject.send(:tempfile_dirnames)).to eql(%w{ /foo/bar })
51
71
  end
52
72
 
53
73
  it "should select the destdir and a temp dir" do
74
+ subject = tempfile_object_for_path("/foo/bar/new_file")
54
75
  Chef::Config[:file_staging_uses_destdir] = :auto
55
76
  expect(Dir).to receive(:tmpdir).and_return("/tmp/dir")
56
77
  expect(subject.send(:tempfile_dirnames)).to eql(%w{ /foo/bar /tmp/dir })
@@ -67,18 +88,27 @@ describe Chef::FileContentManagement::Tempfile do
67
88
  end
68
89
 
69
90
  it "should create a temporary file" do
91
+ subject = tempfile_object_for_path("/foo/bar/new_file")
70
92
  expect(subject.send(:tempfile_open)).to be_a(Tempfile)
71
93
  end
72
94
 
95
+ it "should preserve the extension in the tempfile path" do
96
+ subject = tempfile_object_for_path("/foo/bar/new_file.html.erb")
97
+ tempfile = subject.send(:tempfile_open)
98
+ expect(tempfile.path).to match(/chef-new_file.*\.html\.erb$/)
99
+ end
100
+
73
101
  it "should pick the destdir preferrentially" do
74
- expect(Tempfile).to receive(:open).with(tempname, "/foo/bar").and_return(tempfile)
102
+ subject = tempfile_object_for_path("/foo/bar/new_file")
103
+ expect(Tempfile).to receive(:open).with([tempname, ""], "/foo/bar").and_return(tempfile)
75
104
  subject.send(:tempfile_open)
76
105
  end
77
106
 
78
107
  it "should use ENV['TMP'] otherwise" do
108
+ subject = tempfile_object_for_path("/foo/bar/new_file")
79
109
  expect(Dir).to receive(:tmpdir).and_return("/tmp/dir")
80
- expect(Tempfile).to receive(:open).with(tempname, "/foo/bar").and_raise(SystemCallError, "foo")
81
- expect(Tempfile).to receive(:open).with(tempname, "/tmp/dir").and_return(tempfile)
110
+ expect(Tempfile).to receive(:open).with([tempname, ""], "/foo/bar").and_raise(SystemCallError, "foo")
111
+ expect(Tempfile).to receive(:open).with([tempname, ""], "/tmp/dir").and_return(tempfile)
82
112
  subject.send(:tempfile_open)
83
113
  end
84
114
  end
@@ -72,4 +72,18 @@ describe Chef::Provider::Log::ChefLog do
72
72
  expect(Chef::Log).to receive(:info).with(log_str).and_return(true)
73
73
  provider.run_action(:write)
74
74
  end
75
+
76
+ context "when count_log_resource_updates is passed in knife.rb" do
77
+ it "updates the resource count if count_log_resource_updates=true" do
78
+ Chef::Config[:count_log_resource_updates] = true
79
+ expect(new_resource).to receive(:updated_by_last_action)
80
+ provider.run_action(:write)
81
+ end
82
+
83
+ it "doesn't update the resource count if count_log_resource_updates=false" do
84
+ Chef::Config[:count_log_resource_updates] = false
85
+ expect(new_resource).not_to receive(:updated_by_last_action)
86
+ provider.run_action(:write)
87
+ end
88
+ end
75
89
  end
@@ -19,23 +19,6 @@
19
19
  require "spec_helper"
20
20
 
21
21
  shared_examples_for "a registry key" do
22
- before(:each) do
23
- @node = Chef::Node.new
24
- @events = Chef::EventDispatch::Dispatcher.new
25
- @run_context = Chef::RunContext.new(@node, {}, @events)
26
-
27
- @new_resource = Chef::Resource::RegistryKey.new("windows is fun", @run_context)
28
- @new_resource.key keyname
29
- @new_resource.values( testval1 )
30
- @new_resource.recursive false
31
-
32
- @provider = Chef::Provider::RegistryKey.new(@new_resource, @run_context)
33
-
34
- allow(@provider).to receive(:running_on_windows!).and_return(true)
35
- @double_registry = double(Chef::Win32::Registry)
36
- allow(@provider).to receive(:registry).and_return(@double_registry)
37
- end
38
-
39
22
  describe "when first created" do
40
23
  end
41
24
 
@@ -273,6 +256,23 @@ shared_examples_for "a registry key" do
273
256
  end
274
257
 
275
258
  describe Chef::Provider::RegistryKey do
259
+ before(:each) do
260
+ @node = Chef::Node.new
261
+ @events = Chef::EventDispatch::Dispatcher.new
262
+ @run_context = Chef::RunContext.new(@node, {}, @events)
263
+
264
+ @new_resource = Chef::Resource::RegistryKey.new("windows is fun", @run_context)
265
+ @new_resource.key keyname
266
+ @new_resource.values( testval1 )
267
+ @new_resource.recursive false
268
+
269
+ @provider = Chef::Provider::RegistryKey.new(@new_resource, @run_context)
270
+
271
+ allow(@provider).to receive(:running_on_windows!).and_return(true)
272
+ @double_registry = double(Chef::Win32::Registry)
273
+ allow(@provider).to receive(:registry).and_return(@double_registry)
274
+ end
275
+
276
276
  context "when the key data is safe" do
277
277
  let(:keyname) { 'HKLM\Software\Opscode\Testing\Safe' }
278
278
  let(:testval1) { { :name => "one", :type => :string, :data => "1" } }
@@ -292,4 +292,22 @@ describe Chef::Provider::RegistryKey do
292
292
 
293
293
  it_should_behave_like "a registry key"
294
294
  end
295
+
296
+ describe "action_create" do
297
+ context "when key exists and type matches" do
298
+ let(:keyname) { 'hklm\\software\\opscode\\testing\\dword' }
299
+ let(:dword_passed_as_integer) { { :name => "one", :type => :dword, :data => 12345 } }
300
+ let(:testval1) { { :name => "one", :type => :dword, :data => "12345" } }
301
+ before do
302
+ expect(@double_registry).to receive(:key_exists?).twice.with(keyname).and_return(true)
303
+ end
304
+
305
+ it "does not make a change for datatype of data value differing" do
306
+ expect(@double_registry).to receive(:get_values).with(keyname).and_return( dword_passed_as_integer )
307
+ expect(@double_registry).not_to receive(:set_value)
308
+ @provider.load_current_resource
309
+ @provider.action_create
310
+ end
311
+ end
312
+ end
295
313
  end
@@ -219,6 +219,8 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
219
219
  end
220
220
 
221
221
  before do
222
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
223
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
222
224
  new_resource.supports({ :manage_home => true })
223
225
  new_resource.home("/Users/toor")
224
226
 
@@ -237,6 +239,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
237
239
  end
238
240
 
239
241
  it "moves the users home to the new location if it exists and the target location is different" do
242
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
240
243
  new_resource.supports(:manage_home => true)
241
244
 
242
245
  current_home = CHEF_SPEC_DATA + "/old_home_dir"
@@ -856,6 +859,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
856
859
 
857
860
  describe "when Chef is removing the user" do
858
861
  it "removes the user from the groups and deletes home directory when the resource is configured to manage home" do
862
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
859
863
  new_resource.supports({ :manage_home => true })
860
864
  expect(provider).to receive(:run_dscl).with("list /Groups").and_return("my_group\nyour_group\nreal_group\n")
861
865
  expect(provider).to receive(:run_dscl).with("read /Groups/my_group").and_raise(Chef::Exceptions::DsclCommandFailed) # Empty group
@@ -45,20 +45,50 @@ describe Chef::Provider::User::Linux do
45
45
  @current_resource = Chef::Resource::User::LinuxUser.new("adam", @run_context)
46
46
  end
47
47
 
48
- it "sets supports manage_home to true" do
49
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
50
- expect( @new_resource.supports[:manage_home] ).to be true
48
+ it "supports manage_home does not exist", chef: ">= 13" do
49
+ expect( @new_resource.supports.key?(:manage_home) ).to be false
50
+ end
51
+
52
+ it "supports non_unique does not exist", chef: ">= 13" do
53
+ expect( @new_resource.supports.key?(:non_unique) ).to be false
54
+ end
55
+
56
+ # supports is a method on the superclass so can't totally be removed, but we should aggressively NOP it to decisively break it
57
+ it "disables the supports API", chef: ">= 13" do
58
+ @new_resource.supports( { manage_home: true } )
59
+ expect( @new_resource.supports.key?(:manage_home) ).to be false
60
+ end
61
+
62
+ it "sets supports manage_home to false" do
63
+ expect( @new_resource.supports[:manage_home] ).to be false
64
+ end
65
+
66
+ it "sets supports non-unique to false" do
67
+ expect( @new_resource.supports[:non_unique] ).to be false
51
68
  end
52
69
 
53
- it "sets supports non-unique to true" do
70
+ it "throws a deprecation warning on setting supports[:manage_home]" do
54
71
  Chef::Config[:treat_deprecation_warnings_as_errors] = false
55
- expect( @new_resource.supports[:non_unique] ).to be true
72
+ expect(Chef).to receive(:log_deprecation).with("supports { manage_home: true } on the user resource is deprecated and will be removed in Chef 13, set manage_home: true instead")
73
+ @new_resource.supports( { :manage_home => true } )
56
74
  end
57
75
 
58
- it "defaults manage_home to true" do
76
+ it "defaults manage_home to false" do
59
77
  expect( @new_resource.manage_home ).to be false
60
78
  end
61
79
 
80
+ it "supports[:manage_home] (incorectly) acts like manage_home" do
81
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
82
+ @new_resource.supports({ manage_home: true })
83
+ expect( provider.useradd_options ).to eql(["-m"])
84
+ end
85
+
86
+ it "supports[:manage_home] does not change behavior of manage_home: false", chef: ">= 13" do
87
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
88
+ @new_resource.supports({ manage_home: true })
89
+ expect( provider.useradd_options ).to eql(["-M"])
90
+ end
91
+
62
92
  it "by default manage_home is false and we use -M" do
63
93
  expect( provider.useradd_options ).to eql(["-M"])
64
94
  end
@@ -32,6 +32,8 @@ describe Chef::Provider::User::Pw do
32
32
  @new_resource.shell "/usr/bin/zsh"
33
33
  @new_resource.password "abracadabra"
34
34
 
35
+ # XXX: rip out in Chef-13
36
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
35
37
  @new_resource.supports :manage_home => true
36
38
 
37
39
  @current_resource = Chef::Resource::User::PwUser.new("adam")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.14.60
4
+ version: 12.14.77
5
5
  platform: universal-mingw32
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-09 00:00:00.000000000 Z
11
+ date: 2016-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 12.14.60
19
+ version: 12.14.77
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 12.14.60
26
+ version: 12.14.77
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mixlib-cli
29
29
  requirement: !ruby/object:Gem::Requirement