chef 14.9.13-universal-mingw32 → 14.10.9-universal-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98119483f2b582dd32ad2fceac40b9b091c0d16ec573d7d57f8d2b36e186cdaf
4
- data.tar.gz: aa232f1d87949b67f4af917a6a53030a9e8203e0cff9c302f609cb8653e450e3
3
+ metadata.gz: bdb9b97138fd017803fadc2a2a09020e056c39416515ed4d223698fc56f97e42
4
+ data.tar.gz: c26b9d7932b123aa9c0d71d699678411420255619f77a60fcd69dc65aa7c2620
5
5
  SHA512:
6
- metadata.gz: 681c2c5e5c9bf2c0a9d4b65b2bc070bdc692ebde1dc5eb838992a375b9885b1a05b88c35ad7571f226cc102bf98fac4b8a1f25b32814a28a1b772963c1ec8dc3
7
- data.tar.gz: 4a0c5eea5e3a2481a314672da5c734d745a124f8c1f666717dcacd2c06c95316deb270cc58ec022f03a7a5db4851bcc1af51d993a51000a89325e526cd156793
6
+ metadata.gz: e51efb7f6bae1709004a179313f1982225c524659baff63ffaad62f06033f356d11426b6fd8582a982593e387739a466142afe872486145f973037d34e6848ce
7
+ data.tar.gz: 3fa8030a0eef137128c2f7aaf6c032fab7608e7777f412b211c7c3be28d9b3d3506feeff90c4f3c7fb2ca00722729247abe9ba2c50feffb1cbc9772c9ab4cfba
@@ -376,6 +376,10 @@ class Chef::Application::Client < Chef::Application
376
376
  end
377
377
 
378
378
  if mode = config[:audit_mode] || Chef::Config[:audit_mode]
379
+ if [:enabled, :audit_only].include?(mode)
380
+ Chef.deprecated(:audit_mode, "Chef's Audit mode has been deprecated and will be removed in Chef 15 (April 2019). Consider migrating to InSpec as a replacement for this functionality.")
381
+ end
382
+
379
383
  expected_modes = [:enabled, :disabled, :audit_only]
380
384
  unless expected_modes.include?(mode)
381
385
  Chef::Application.fatal!(unrecognized_audit_mode(mode))
@@ -68,8 +68,8 @@ class Chef
68
68
 
69
69
  def warn_about_cookbook_shadowing
70
70
  unless merged_cookbooks.empty?
71
- Chef::Log.deprecation "The cookbook(s): #{merged_cookbooks.join(', ')} exist in multiple places in your cookbook_path. " +
72
- "A composite version has been compiled. This has been deprecated since 0.10.4, in Chef 13 this behavior will be REMOVED."
71
+ Chef.deprecated(:cookbook_shadowing, "The cookbook(s): #{merged_cookbooks.join(', ')} exist in multiple places in your cookbook_path. " +
72
+ "A composite version has been compiled. This has been deprecated since 0.10.4, in Chef 15 this behavior will be REMOVED.")
73
73
  end
74
74
  end
75
75
 
@@ -207,12 +207,6 @@ class Chef
207
207
  target 23
208
208
  end
209
209
 
210
- class MapCollision < Base
211
- target 25
212
- end
213
-
214
- # id 3694 was deleted
215
-
216
210
  # Returned when using the deprecated option on a property
217
211
  class Property < Base
218
212
  target 24
@@ -222,10 +216,24 @@ class Chef
222
216
  end
223
217
  end
224
218
 
219
+ class MapCollision < Base
220
+ target 25
221
+ end
222
+
225
223
  class ShellOut < Base
226
224
  target 26
227
225
  end
228
226
 
227
+ class AuditMode < Base
228
+ target 27
229
+ end
230
+
231
+ class CookbookShadowing < Base
232
+ target 28
233
+ end
234
+
235
+ # id 3694 was deleted and should not be reused
236
+
229
237
  class Generic < Base
230
238
  def url
231
239
  "https://docs.chef.io/chef_deprecations_client.html"
@@ -24,9 +24,12 @@ class Chef
24
24
  end
25
25
  end
26
26
 
27
- # Print text. This will start a new line and indent if necessary
27
+ # Print text. This will start a new line and indent if necessary
28
28
  # but will not terminate the line (future print and puts statements
29
29
  # will start off where this print left off).
30
+ #
31
+ # @param string [String]
32
+ # @param args [Array<Hash,Symbol>]
30
33
  def color(string, *args)
31
34
  print(string, from_args(args))
32
35
  end
@@ -34,18 +37,27 @@ class Chef
34
37
  # Print the start of a new line. This will terminate any existing lines and
35
38
  # cause indentation but will not move to the next line yet (future 'print'
36
39
  # and 'puts' statements will stay on this line).
40
+ #
41
+ # @param string [String]
42
+ # @param args [Array<Hash,Symbol>]
37
43
  def start_line(string, *args)
38
44
  print(string, from_args(args, start_line: true))
39
45
  end
40
46
 
41
47
  # Print a line. This will continue from the last start_line or print,
42
48
  # or start a new line and indent if necessary.
49
+ #
50
+ # @param string [String]
51
+ # @param args [Array<Hash,Symbol>]
43
52
  def puts(string, *args)
44
53
  print(string, from_args(args, end_line: true))
45
54
  end
46
55
 
47
56
  # Print an entire line from start to end. This will terminate any existing
48
57
  # lines and cause indentation.
58
+ #
59
+ # @param string [String]
60
+ # @param args [Array<Hash,Symbol>]
49
61
  def puts_line(string, *args)
50
62
  print(string, from_args(args, start_line: true, end_line: true))
51
63
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright 2009-2016, Chef Software, Inc.
3
+ # Copyright:: Copyright 2009-2019, Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,6 +29,12 @@ class Chef
29
29
 
30
30
  banner "knife cookbook site download COOKBOOK [VERSION] (options)"
31
31
  category "cookbook site"
32
+
33
+ def run
34
+ Chef::Log.warn("knife cookbook site download has been deprecated in favor of knife supermarket download. In Chef 16 (April 2020) this will result in an error!")
35
+ super
36
+ end
37
+
32
38
  end
33
39
  end
34
40
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright 2010-2018, Chef Software Inc.
3
+ # Copyright:: Copyright 2010-2019, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,6 +30,11 @@ class Chef
30
30
  banner "knife cookbook site install COOKBOOK [VERSION] (options)"
31
31
  category "cookbook site"
32
32
 
33
+ def run
34
+ Chef::Log.warn("knife cookbook site install has been deprecated in favor of knife supermarket install. In Chef 16 (April 2020) this will result in an error!")
35
+ super
36
+ end
37
+
33
38
  end
34
39
  end
35
40
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright 2009-2016, Chef Software Inc.
3
+ # Copyright:: Copyright 2009-2019, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,6 +30,11 @@ class Chef
30
30
  banner "knife cookbook site list (options)"
31
31
  category "cookbook site"
32
32
 
33
+ def run
34
+ Chef::Log.warn("knife cookbook site list has been deprecated in favor of knife supermarket list. In Chef 16 (April 2020) this will result in an error!")
35
+ super
36
+ end
37
+
33
38
  end
34
39
  end
35
40
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright 2009-2016, Chef Software Inc.
3
+ # Copyright:: Copyright 2009-2019, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,6 +30,11 @@ class Chef
30
30
  banner "knife cookbook site search QUERY (options)"
31
31
  category "cookbook site"
32
32
 
33
+ def run
34
+ Chef::Log.warn("knife cookbook site search has been deprecated in favor of knife supermarket search. In Chef 16 (April 2020) this will result in an error!")
35
+ super
36
+ end
37
+
33
38
  end
34
39
  end
35
40
  end
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Nuo Yan (<nuo@chef.io>)
3
3
  # Author:: Tim Hinderliter (<tim@chef.io>)
4
- # Copyright:: Copyright 2010-2016, Chef Software Inc.
4
+ # Copyright:: Copyright 2010-2019, Chef Software Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -31,6 +31,11 @@ class Chef
31
31
  banner "knife cookbook site share COOKBOOK [CATEGORY] (options)"
32
32
  category "cookbook site"
33
33
 
34
+ def run
35
+ Chef::Log.warn("knife cookbook site share has been deprecated in favor of knife supermarket share. In Chef 16 (April 2020) this will result in an error!")
36
+ super
37
+ end
38
+
34
39
  end
35
40
  end
36
41
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright 2009-2016, Chef Software Inc.
3
+ # Copyright:: Copyright 2009-2019, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,6 +30,11 @@ class Chef
30
30
  banner "knife cookbook site show COOKBOOK [VERSION] (options)"
31
31
  category "cookbook site"
32
32
 
33
+ def run
34
+ Chef::Log.warn("knife cookbook site show has been deprecated in favor of knife supermarket show. In Chef 16 (April 2020) this will result in an error!")
35
+ super
36
+ end
37
+
33
38
  end
34
39
  end
35
40
  end
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Stephen Delano (<stephen@chef.io>)
3
3
  # Author:: Tim Hinderliter (<tim@chef.io>)
4
- # Copyright:: Copyright 2010-2016, Chef Software Inc.
4
+ # Copyright:: Copyright 2010-2019, Chef Software Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -31,6 +31,11 @@ class Chef
31
31
  banner "knife cookbook site unshare COOKBOOK (options)"
32
32
  category "cookbook site"
33
33
 
34
+ def run
35
+ Chef::Log.warn("knife cookbook site unshare has been deprecated in favor of knife supermarket unshare. In Chef 16 (April 2020) this will result in an error!")
36
+ super
37
+ end
38
+
34
39
  end
35
40
  end
36
41
  end
@@ -62,7 +62,7 @@ class Chef
62
62
  end
63
63
 
64
64
  # Contains commands and content, see trusted_certs_content
65
- # TODO: Rename to trusted_certs_script
65
+ # @todo Rename to trusted_certs_script
66
66
  def trusted_certs
67
67
  @trusted_certs ||= trusted_certs_content
68
68
  end
@@ -25,7 +25,7 @@ class Chef
25
25
  # Allows includer knife commands to return multiple attributes
26
26
  # @brief knife node show NAME -a ATTR1 -a ATTR2
27
27
  module MultiAttributeReturnOption
28
- # :nodoc:
28
+ # @private
29
29
  def self.included(includer)
30
30
  includer.class_eval do
31
31
  option :field_separator,
@@ -45,7 +45,6 @@ class Chef
45
45
  end
46
46
  end
47
47
 
48
- #==Chef::Knife::Core::GenericPresenter
49
48
  # The base presenter class for displaying structured data in knife commands.
50
49
  # This is not an abstract base class, and it is suitable for displaying
51
50
  # most kinds of objects that knife needs to display.
@@ -26,7 +26,7 @@ class Chef
26
26
  # This module may be included into a knife subcommand class to automatically
27
27
  # add configuration options used by the NodePresenter
28
28
  module NodeFormattingOptions
29
- # :nodoc:
29
+ # @private
30
30
  # Would prefer to do this in a rational way, but can't be done b/c of
31
31
  # Mixlib::CLI's design :(
32
32
  def self.included(includer)
@@ -48,7 +48,6 @@ class Chef
48
48
  end
49
49
  end
50
50
 
51
- #==Chef::Knife::Core::NodePresenter
52
51
  # A customized presenter for Chef::Node objects. Supports variable-length
53
52
  # output formats for displaying node data
54
53
  class NodePresenter < GenericPresenter
@@ -26,7 +26,7 @@ class Chef
26
26
  # This module may be included into a knife subcommand class to automatically
27
27
  # add configuration options used by the StatusPresenter
28
28
  module StatusFormattingOptions
29
- # :nodoc:
29
+ # @private
30
30
  # Would prefer to do this in a rational way, but can't be done b/c of
31
31
  # Mixlib::CLI's design :(
32
32
  def self.included(includer)
@@ -48,7 +48,6 @@ class Chef
48
48
  end
49
49
  end
50
50
 
51
- #==Chef::Knife::Core::StatusPresenter
52
51
  # A customized presenter for Chef::Node objects. Supports variable-length
53
52
  # output formats for displaying node data
54
53
  class StatusPresenter < GenericPresenter
@@ -148,8 +147,8 @@ class Chef
148
147
  ui.color(key_text, :cyan)
149
148
  end
150
149
 
151
- # :nodoc:
152
- # TODO: this is duplicated from StatusHelper in the Webui. dedup.
150
+ # @private
151
+ # @todo this is duplicated from StatusHelper in the Webui. dedup.
153
152
  def time_difference_in_hms(unix_time)
154
153
  now = Time.now.to_i
155
154
  difference = now - unix_time.to_i
@@ -26,7 +26,6 @@ require "tempfile"
26
26
  class Chef
27
27
  class Knife
28
28
 
29
- #==Chef::Knife::UI
30
29
  # The User Interaction class used by knife.
31
30
  class UI
32
31
 
@@ -64,6 +63,8 @@ class Chef
64
63
 
65
64
  # Prints a message to stdout. Aliased as +info+ for compatibility with
66
65
  # the logger API.
66
+ #
67
+ # @param message [String] the text string
67
68
  def msg(message)
68
69
  stdout.puts message
69
70
  rescue Errno::EPIPE => e
@@ -72,6 +73,8 @@ class Chef
72
73
  end
73
74
 
74
75
  # Prints a msg to stderr. Used for info, warn, error, and fatal.
76
+ #
77
+ # @param message [String] the text string
75
78
  def log(message)
76
79
  stderr.puts message
77
80
  rescue Errno::EPIPE => e
@@ -83,16 +86,22 @@ class Chef
83
86
  alias :err :log
84
87
 
85
88
  # Print a warning message
89
+ #
90
+ # @param message [String] the text string
86
91
  def warn(message)
87
92
  log("#{color('WARNING:', :yellow, :bold)} #{message}")
88
93
  end
89
94
 
90
95
  # Print an error message
96
+ #
97
+ # @param message [String] the text string
91
98
  def error(message)
92
99
  log("#{color('ERROR:', :red, :bold)} #{message}")
93
100
  end
94
101
 
95
102
  # Print a message describing a fatal error.
103
+ #
104
+ # @param message [String] the text string
96
105
  def fatal(message)
97
106
  log("#{color('FATAL:', :red, :bold)} #{message}")
98
107
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Christopher Webber (<cwebber@chef.io>)
3
- # Copyright:: Copyright (c) 2014-2018 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) 2014-2019 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,15 +18,14 @@
18
18
 
19
19
  require "chef/knife"
20
20
  require "chef/exceptions"
21
- require "shellwords"
22
- require "mixlib/archive"
23
21
 
24
22
  class Chef
25
23
  class Knife
26
24
  class SupermarketInstall < Knife
27
25
 
28
26
  deps do
29
- require "chef/mixin/shell_out"
27
+ require "shellwords"
28
+ require "mixlib/archive"
30
29
  require "chef/knife/core/cookbook_scm_repo"
31
30
  require "chef/cookbook/metadata"
32
31
  end
@@ -71,8 +70,6 @@ class Chef
71
70
  attr_reader :vendor_path
72
71
 
73
72
  def run
74
- extend Chef::Mixin::ShellOut
75
-
76
73
  if config[:cookbook_path]
77
74
  Chef::Config[:cookbook_path] = config[:cookbook_path]
78
75
  else
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Christopher Webber (<cwebber@chef.io>)
3
- # Copyright:: Copyright (c) 2014-2018 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) 2014-2019 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,7 +17,6 @@
17
17
  #
18
18
 
19
19
  require "chef/knife"
20
- require "chef/mixin/shell_out"
21
20
 
22
21
  class Chef
23
22
  class Knife
@@ -29,11 +28,9 @@ class Chef
29
28
  require "chef/cookbook_loader"
30
29
  require "chef/cookbook_uploader"
31
30
  require "chef/cookbook_site_streaming_uploader"
32
- require "mixlib/shellout"
31
+ require "chef/mixin/shell_out"
33
32
  end
34
33
 
35
- include Chef::Mixin::ShellOut
36
-
37
34
  banner "knife supermarket share COOKBOOK [CATEGORY] (options)"
38
35
  category "supermarket"
39
36
 
@@ -21,6 +21,7 @@ require "chef/dsl/declare_resource"
21
21
  require "chef/mixin/shell_out"
22
22
  require "chef/http/simple"
23
23
  require "chef/provider/noop"
24
+ require "tmpdir"
24
25
 
25
26
  class Chef
26
27
  class Provider
@@ -200,13 +201,15 @@ class Chef
200
201
  def install_key_from_uri(key)
201
202
  key_name = key.gsub(/[^0-9A-Za-z\-]/, "_")
202
203
  cached_keyfile = ::File.join(Chef::Config[:file_cache_path], key_name)
204
+ tmp_dir = Dir.mktmpdir(".gpg")
205
+ at_exit { FileUtils.remove_entry(tmp_dir) }
203
206
 
204
207
  declare_resource(key_type(key), cached_keyfile) do
205
208
  source key
206
209
  mode "0644"
207
210
  sensitive new_resource.sensitive
208
211
  action :create
209
- verify "gpg %{path}"
212
+ verify "gpg --homedir #{tmp_dir} %{path}"
210
213
  end
211
214
 
212
215
  declare_resource(:execute, "apt-key add #{cached_keyfile}") do
@@ -151,7 +151,7 @@ class Chef
151
151
  end
152
152
 
153
153
  def clone
154
- converge_by("clone from #{new_resource.repository} into #{cwd}") do
154
+ converge_by("clone from #{repo_url} into #{cwd}") do
155
155
  remote = new_resource.remote
156
156
 
157
157
  clone_cmd = ["clone"]
@@ -161,7 +161,7 @@ class Chef
161
161
  clone_cmd << "\"#{new_resource.repository}\""
162
162
  clone_cmd << "\"#{cwd}\""
163
163
 
164
- logger.info "#{new_resource} cloning repo #{new_resource.repository} to #{cwd}"
164
+ logger.info "#{new_resource} cloning repo #{repo_url} to #{cwd}"
165
165
  git clone_cmd
166
166
  end
167
167
  end
@@ -342,6 +342,16 @@ class Chef
342
342
  string =~ /^[0-9a-f]{40}$/
343
343
  end
344
344
 
345
+ # Returns a message for sensitive repository URL if sensitive is true otherwise
346
+ # repository URL is returned
347
+ # @return [String]
348
+ def repo_url
349
+ if new_resource.sensitive
350
+ "**Suppressed Sensitive URL**"
351
+ else
352
+ new_resource.repository
353
+ end
354
+ end
345
355
  end
346
356
  end
347
357
  end
@@ -59,7 +59,19 @@ class Chef
59
59
 
60
60
  action :create do
61
61
  description "Creates or updates a certificate."
62
- add_cert(OpenSSL::X509::Certificate.new(raw_source))
62
+
63
+ cert_obj = OpenSSL::X509::Certificate.new(raw_source) # A certificate object in memory
64
+ thumbprint = OpenSSL::Digest::SHA1.new(cert_obj.to_der).to_s # Fetch its thumbprint
65
+
66
+ # Need to check if return value is Boolean:true
67
+ # If not then the given certificate should be added in certstore
68
+ if verify_cert(thumbprint) == true
69
+ Chef::Log.debug("Certificate is already present")
70
+ else
71
+ converge_by("Adding certificate #{new_resource.source} into Store #{new_resource.store_name}") do
72
+ add_cert(cert_obj)
73
+ end
74
+ end
63
75
  end
64
76
 
65
77
  # acl_add is a modify-if-exists operation : not idempotent
@@ -95,6 +107,8 @@ class Chef
95
107
  converge_by("Deleting certificate #{new_resource.source} from Store #{new_resource.store_name}") do
96
108
  delete_cert
97
109
  end
110
+ else
111
+ Chef::Log.debug("Certificate not found")
98
112
  end
99
113
  end
100
114
 
@@ -105,7 +119,7 @@ class Chef
105
119
  if cert_obj
106
120
  show_or_store_cert(cert_obj)
107
121
  else
108
- Chef::Log.info("Certificate not found")
122
+ Chef::Log.debug("Certificate not found")
109
123
  end
110
124
  end
111
125
 
@@ -135,9 +149,14 @@ class Chef
135
149
  store.get(new_resource.source)
136
150
  end
137
151
 
138
- def verify_cert
152
+ # Checks whether a certificate with the given thumbprint
153
+ # is already present and valid in certificate store
154
+ # If the certificate is not present, verify_cert returns a String: "Certificate not found"
155
+ # But if it is present but expired, it returns a Boolean: false
156
+ # Otherwise, it returns a Boolean: true
157
+ def verify_cert(thumbprint = new_resource.source)
139
158
  store = ::Win32::Certstore.open(new_resource.store_name)
140
- store.valid?(new_resource.source)
159
+ store.valid?(thumbprint)
141
160
  end
142
161
 
143
162
  def show_or_store_cert(cert_obj)
@@ -241,11 +260,15 @@ class Chef
241
260
  set_acl_script
242
261
  end
243
262
 
263
+ # Returns the certificate string of the given
264
+ # input certificate in PEM format
244
265
  def raw_source
245
266
  ext = ::File.extname(new_resource.source)
246
267
  convert_pem(ext, new_resource.source)
247
268
  end
248
269
 
270
+ # Uses powershell command to convert crt/der/cer/pfx & p7b certificates
271
+ # In PEM format and returns its certificate content
249
272
  def convert_pem(ext, source)
250
273
  out = case ext
251
274
  when ".crt", ".der"
@@ -261,6 +284,7 @@ class Chef
261
284
  format_raw_out(out)
262
285
  end
263
286
 
287
+ # Returns the certificate content
264
288
  def format_raw_out(out)
265
289
  begin_cert = "-----BEGIN CERTIFICATE-----"
266
290
  end_cert = "-----END CERTIFICATE-----"
@@ -23,7 +23,7 @@ require "chef/version_string"
23
23
 
24
24
  class Chef
25
25
  CHEF_ROOT = File.expand_path("../..", __FILE__)
26
- VERSION = Chef::VersionString.new("14.9.13")
26
+ VERSION = Chef::VersionString.new("14.10.9")
27
27
  end
28
28
 
29
29
  #
@@ -0,0 +1,21 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDgDCCAmigAwIBAgIQEyXvJXC8z6lBIxwnT7/d5jANBgkqhkiG9w0BAQsFADBD
3
+ MRwwGgYDVQQDDBNBIER1bW15IENlcnRpZmljYXRlMSMwIQYJKoZIhvcNAQkBFhR0
4
+ ZXN0Ynlyc3BlY0BjaGVmLmNvbTAeFw0xOTAxMjMxODEzNTBaFw0yMDAxMjMxODMz
5
+ NTBaMEMxHDAaBgNVBAMME0EgRHVtbXkgQ2VydGlmaWNhdGUxIzAhBgkqhkiG9w0B
6
+ CQEWFHRlc3RieXJzcGVjQGNoZWYuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
7
+ MIIBCgKCAQEA1IPsH+S+HKVsJJDuHsqgSQnWAWp7SsBqwnx/t/NZAM6g41mbwafP
8
+ EZixFB5G6VAIiUosHcLhFwz00uPwVZIDND1Ez4TxACraF0iJQpy2kmriDq449ccu
9
+ fn/d8k417Vj0Hm7mcNpv6uaQrjYhIYFHXKV5aQS/OROQGvwFuWe56uJI25ua9lWR
10
+ 8yBR621bgn6oW7elBZ8YDQAH88Y0LNo15FBeL2IDUXHBajEfkIRDE3BH+8zcuK4g
11
+ RnRJYBBkzFCXvTXLcRyr1zXaow31TeECrUdPGgBO+nTpLqWYWTylAv36C1nMYBn2
12
+ 5ItKAsswVEpQMIeQ5ysfaab0Ei3DRZIEjQIDAQABo3AwbjAOBgNVHQ8BAf8EBAMC
13
+ BaAwHQYDVR0lBBYwFAYIKwYBBQUHAwIGCCsGAQUFBwMBMB4GA1UdEQQXMBWCE3d3
14
+ dy50ZXN0Ynlyc3BlYy5jb20wHQYDVR0OBBYEFMeiyQLCtZBHbmVnvCkoDnRkR+tB
15
+ MA0GCSqGSIb3DQEBCwUAA4IBAQA1hy2yADJ9ULaQMduBt0PiVKP+UKD87OQj0pJK
16
+ vFE7WVSxWaphA4XS15hityJt4eHmGF8R6tNxip7eS2mloGGMguijslqvQLICeeCN
17
+ /7Ov9CsJJG3R8xVrbEZkPExUbV8swJX68GoVxPi4nSj2TFhizBScaOKLedzIXtv5
18
+ hGSXpl3RfETckTq1wmIVEQE9CUoWkea74zvGc5wXTi3r2ZZxof6olGELqT8W/jyT
19
+ vSzUDIC0iwuSVS0AyonBlAnA34ak3Q6a0RCZGK3l1IYz6Cb1JbHHpuCDZPPHooBi
20
+ Hbd+SuvfCH9DLgDFJCAOg+X7WCMQAoy9gCY8Ne5oBTYyjmCz
21
+ -----END CERTIFICATE-----
@@ -0,0 +1,340 @@
1
+ # Author: Nimesh Patni (nimesh.patni@msystechnologies.com)
2
+ # Copyright: Copyright 2008-2018, Chef Software, Inc.
3
+ # License: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "spec_helper"
19
+ require "chef/mixin/powershell_out"
20
+ require "chef/resource/windows_certificate"
21
+
22
+ module WindowsCertificateHelper
23
+ include Chef::Mixin::PowershellOut
24
+
25
+ def create_store(store)
26
+ path = "Cert:\\LocalMachine\\" + store
27
+ command = <<~EOC
28
+ New-Item -Path #{path}
29
+ EOC
30
+ powershell_out(command)
31
+ end
32
+
33
+ def cleanup(store)
34
+ path = "Cert:\\LocalMachine\\" + store
35
+ command = <<~EOC
36
+ Remove-Item -Path #{path} -Recurse
37
+ EOC
38
+ powershell_out(command)
39
+ end
40
+
41
+ def no_of_certificates
42
+ path = "Cert:\\LocalMachine\\" + store
43
+ command = <<~EOC
44
+ Write-Host (dir #{path} | measure).Count;
45
+ EOC
46
+ powershell_out(command).stdout.to_i
47
+ end
48
+ end
49
+
50
+ describe Chef::Resource::WindowsCertificate, :windows_only, :appveyor_only do
51
+ include WindowsCertificateHelper
52
+
53
+ let(:stdout) { StringIO.new }
54
+ let(:username) { "ChefFunctionalTest" }
55
+ let(:node) { Chef::Node.new }
56
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
57
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
58
+ let(:new_resource) { Chef::Resource::WindowsCertificate.new(username, run_context) }
59
+ let(:password) { "P@ssw0rd!" }
60
+ let(:store) { "Chef-Functional-Test" }
61
+ let(:certificate_path) { File.expand_path(File.join(CHEF_SPEC_DATA, "windows_certificates")) }
62
+ let(:cer_path) { File.join(certificate_path, "test.cer") }
63
+ let(:pem_path) { File.join(certificate_path, "test.pem") }
64
+ let(:out_path) { File.join(certificate_path, "testout.pem") }
65
+ let(:tests_thumbprint) { "3180B3E3217862600BD7B2D28067B03D41576A4F" }
66
+ let(:other_cer_path) { File.join(certificate_path, "othertest.cer") }
67
+ let(:others_thumbprint) { "AD393859B2D2D4161D224F16CBD3D16555753A20" }
68
+
69
+ before do
70
+ opts = { store_name: store }
71
+ key = :store_name
72
+ to_be = ["TRUSTEDPUBLISHER", "TrustedPublisher", "CLIENTAUTHISSUER",
73
+ "REMOTE DESKTOP", "ROOT", "TRUSTEDDEVICES", "WEBHOSTING",
74
+ "CA", "AUTHROOT", "TRUSTEDPEOPLE", "MY", "SMARTCARDROOT", "TRUST",
75
+ "DISALLOWED"]
76
+
77
+ # Byepassing the validation so that we may create a custom store
78
+ allow_any_instance_of(Chef::Mixin::ParamsValidate)
79
+ .to receive(:_pv_equal_to)
80
+ .with(opts, key, to_be)
81
+ .and_return(true)
82
+
83
+ # Creating a custom store for the testing
84
+ create_store(store)
85
+
86
+ allow(Chef::Log).to receive(:info) do |msg|
87
+ stdout.puts(msg)
88
+ end
89
+ end
90
+
91
+ after { cleanup(store) }
92
+
93
+ subject(:win_certificate) do
94
+ new_resource.store_name = store
95
+ new_resource
96
+ end
97
+
98
+ it "Initially there are no certificates" do
99
+ expect(no_of_certificates).to eq(0)
100
+ end
101
+
102
+ describe "action :create" do
103
+ before do
104
+ win_certificate.source = cer_path
105
+ win_certificate.run_action(:create)
106
+ end
107
+
108
+ context "Adding a certificate" do
109
+ it "Imports certificate into store" do
110
+ expect(no_of_certificates).to eq(1)
111
+ end
112
+
113
+ it "Converges while addition" do
114
+ expect(win_certificate).to be_updated_by_last_action
115
+ end
116
+ end
117
+
118
+ context "Again adding the same certificate" do
119
+ before do
120
+ win_certificate.run_action(:create)
121
+ end
122
+ it "Does not imports certificate into store" do
123
+ expect(no_of_certificates).to eq(1)
124
+ end
125
+ it "Idempotent: Does not converge while addition" do
126
+ expect(no_of_certificates).to eq(1)
127
+ expect(win_certificate).not_to be_updated_by_last_action
128
+ end
129
+ end
130
+
131
+ context "Again adding the same certificate of other format" do
132
+ before do
133
+ win_certificate.source = pem_path
134
+ win_certificate.run_action(:create)
135
+ end
136
+ it "Does not imports certificate into store" do
137
+ expect(no_of_certificates).to eq(1)
138
+ end
139
+ it "Idempotent: Does not converge while addition" do
140
+ expect(no_of_certificates).to eq(1)
141
+ expect(win_certificate).not_to be_updated_by_last_action
142
+ end
143
+ end
144
+
145
+ context "Adding another certificate" do
146
+ before do
147
+ win_certificate.source = other_cer_path
148
+ win_certificate.run_action(:create)
149
+ end
150
+ it "Imports certificate into store" do
151
+ expect(no_of_certificates).to eq(2)
152
+ end
153
+ it "Converges while addition" do
154
+ expect(no_of_certificates).to eq(2)
155
+ expect(win_certificate).to be_updated_by_last_action
156
+ end
157
+ end
158
+ end
159
+
160
+ describe "action: verify" do
161
+ context "When a certificate is not present" do
162
+ before do
163
+ win_certificate.source = tests_thumbprint
164
+ win_certificate.run_action(:verify)
165
+ end
166
+ it "Initial check if certificate is not present" do
167
+ expect(no_of_certificates).to eq(0)
168
+ end
169
+ it "Displays correct message" do
170
+ expect(stdout.string.strip).to eq("Certificate not found")
171
+ end
172
+ it "Does not converge while verifying" do
173
+ expect(win_certificate).not_to be_updated_by_last_action
174
+ end
175
+ end
176
+
177
+ context "When a certificate is present" do
178
+ before do
179
+ win_certificate.source = cer_path
180
+ win_certificate.run_action(:create)
181
+ end
182
+
183
+ context "For a valid thumbprint" do
184
+ before do
185
+ win_certificate.source = tests_thumbprint
186
+ win_certificate.run_action(:verify)
187
+ end
188
+ it "Initial check if certificate is present" do
189
+ expect(no_of_certificates).to eq(1)
190
+ end
191
+ it "Displays correct message" do
192
+ expect(stdout.string.strip).to eq("Certificate is valid")
193
+ end
194
+ it "Does not converge while verifying" do
195
+ expect(win_certificate).not_to be_updated_by_last_action
196
+ end
197
+ end
198
+
199
+ context "For an invalid thumbprint" do
200
+ before do
201
+ win_certificate.source = others_thumbprint
202
+ win_certificate.run_action(:verify)
203
+ end
204
+ it "Initial check if certificate is present" do
205
+ expect(no_of_certificates).to eq(1)
206
+ end
207
+ it "Displays correct message" do
208
+ expect(stdout.string.strip).to eq("Certificate not found")
209
+ end
210
+ it "Does not converge while verifying" do
211
+ expect(win_certificate).not_to be_updated_by_last_action
212
+ end
213
+ end
214
+ end
215
+ end
216
+
217
+ describe "action: fetch" do
218
+ context "When a certificate is not present" do
219
+ before do
220
+ win_certificate.source = tests_thumbprint
221
+ win_certificate.run_action(:fetch)
222
+ end
223
+ it "Initial check if certificate is not present" do
224
+ expect(no_of_certificates).to eq(0)
225
+ end
226
+ it "Does not show any content" do
227
+ expect(stdout.string.strip).to be_empty
228
+ end
229
+ it "Does not converge while fetching" do
230
+ expect(win_certificate).not_to be_updated_by_last_action
231
+ end
232
+ end
233
+
234
+ context "When a certificate is present" do
235
+ before do
236
+ win_certificate.source = cer_path
237
+ win_certificate.run_action(:create)
238
+ end
239
+
240
+ after do
241
+ if File.exists?(out_path)
242
+ File.delete(out_path)
243
+ end
244
+ end
245
+
246
+ context "For a valid thumbprint" do
247
+ before do
248
+ win_certificate.source = tests_thumbprint
249
+ win_certificate.cert_path = out_path
250
+ win_certificate.run_action(:fetch)
251
+ end
252
+ it "Initial check if certificate is present" do
253
+ expect(no_of_certificates).to eq(1)
254
+ end
255
+ it "Stores Certificate content at given path" do
256
+ expect(File.exists?(out_path)).to be_truthy
257
+ end
258
+ it "Does not converge while fetching" do
259
+ expect(win_certificate).not_to be_updated_by_last_action
260
+ end
261
+ end
262
+
263
+ context "For an invalid thumbprint" do
264
+ before do
265
+ win_certificate.source = others_thumbprint
266
+ win_certificate.cert_path = out_path
267
+ win_certificate.run_action(:fetch)
268
+ end
269
+ it "Initial check if certificate is present" do
270
+ expect(no_of_certificates).to eq(1)
271
+ end
272
+ it "Does not show any content" do
273
+ expect(stdout.string.strip).to be_empty
274
+ end
275
+ it "Does not store certificate content at given path" do
276
+ expect(File.exists?(out_path)).to be_falsy
277
+ end
278
+ it "Does not converge while fetching" do
279
+ expect(win_certificate).not_to be_updated_by_last_action
280
+ end
281
+ end
282
+ end
283
+ end
284
+
285
+ describe "action: delete" do
286
+ context "When a certificate is not present" do
287
+ before do
288
+ win_certificate.source = tests_thumbprint
289
+ win_certificate.run_action(:delete)
290
+ end
291
+ it "Initial check if certificate is not present" do
292
+ expect(no_of_certificates).to eq(0)
293
+ end
294
+ it "Does not delete any certificate" do
295
+ expect(stdout.string.strip).to be_empty
296
+ end
297
+ end
298
+
299
+ context "When a certificate is present" do
300
+ before do
301
+ win_certificate.source = cer_path
302
+ win_certificate.run_action(:create)
303
+ end
304
+ before { win_certificate.source = tests_thumbprint }
305
+ it "Initial check if certificate is present" do
306
+ expect(no_of_certificates).to eq(1)
307
+ end
308
+ it "Deletes the certificate" do
309
+ win_certificate.run_action(:delete)
310
+ expect(no_of_certificates).to eq(0)
311
+ end
312
+ it "Converges while deleting" do
313
+ win_certificate.run_action(:delete)
314
+ expect(win_certificate).to be_updated_by_last_action
315
+ end
316
+ it "Idempotent: Does not converge while deleting again" do
317
+ win_certificate.run_action(:delete)
318
+ win_certificate.run_action(:delete)
319
+ expect(no_of_certificates).to eq(0)
320
+ expect(win_certificate).not_to be_updated_by_last_action
321
+ end
322
+ it "Deletes the valid certificate" do
323
+ # Add another certificate"
324
+ win_certificate.source = other_cer_path
325
+ win_certificate.run_action(:create)
326
+ expect(no_of_certificates).to eq(2)
327
+
328
+ # Delete previously added certificate
329
+ win_certificate.source = tests_thumbprint
330
+ win_certificate.run_action(:delete)
331
+ expect(no_of_certificates).to eq(1)
332
+
333
+ # Verify another certificate still exists
334
+ win_certificate.source = others_thumbprint
335
+ win_certificate.run_action(:verify)
336
+ expect(stdout.string.strip).to eq("Certificate is valid")
337
+ end
338
+ end
339
+ end
340
+ end
@@ -434,6 +434,7 @@ EOM
434
434
  local_mode true
435
435
  cookbook_path "#{path_to('cookbooks')}"
436
436
  audit_mode :enabled
437
+ silence_deprecation_warnings %w{chef-27}
437
438
  EOM
438
439
  end
439
440
 
@@ -39,6 +39,7 @@ EOM
39
39
  local_mode true
40
40
  cookbook_path "#{path_to('cookbooks')}"
41
41
  audit_mode :audit_only
42
+ silence_deprecation_warnings %w{chef-27}
42
43
  EOM
43
44
  end
44
45
 
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: 14.9.13
4
+ version: 14.10.9
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: 2019-01-22 00:00:00.000000000 Z
11
+ date: 2019-01-29 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: 14.9.13
19
+ version: 14.10.9
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: 14.9.13
26
+ version: 14.10.9
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mixlib-cli
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -1891,6 +1891,10 @@ files:
1891
1891
  - spec/data/trusted_certs/intermediate.pem
1892
1892
  - spec/data/trusted_certs/opscode.pem
1893
1893
  - spec/data/trusted_certs/root.pem
1894
+ - spec/data/windows_certificates/othertest.cer
1895
+ - spec/data/windows_certificates/test.cer
1896
+ - spec/data/windows_certificates/test.pem
1897
+ - spec/data/windows_certificates/test.pfx
1894
1898
  - spec/functional/application_spec.rb
1895
1899
  - spec/functional/assets/PkgA.1.0.0.0.bff
1896
1900
  - spec/functional/assets/PkgA.2.0.0.0.bff
@@ -1997,6 +2001,7 @@ files:
1997
2001
  - spec/functional/resource/timezone_spec.rb
1998
2002
  - spec/functional/resource/user/dscl_spec.rb
1999
2003
  - spec/functional/resource/user/windows_spec.rb
2004
+ - spec/functional/resource/windows_certificate_spec.rb
2000
2005
  - spec/functional/resource/windows_env_spec.rb
2001
2006
  - spec/functional/resource/windows_package_spec.rb
2002
2007
  - spec/functional/resource/windows_path_spec.rb