chef 15.12.22-universal-mingw32 → 15.13.8-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -4
  3. data/chef-universal-mingw32.gemspec +2 -2
  4. data/lib/chef/chef_fs/file_system/repository/base_file.rb +1 -0
  5. data/lib/chef/deprecated.rb +4 -0
  6. data/lib/chef/exceptions.rb +3 -0
  7. data/lib/chef/knife/bootstrap.rb +1 -1
  8. data/lib/chef/knife/bootstrap/train_connector.rb +1 -0
  9. data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
  10. data/lib/chef/knife/core/hashed_command_loader.rb +1 -0
  11. data/lib/chef/knife/core/subcommand_loader.rb +1 -1
  12. data/lib/chef/knife/ssh.rb +4 -0
  13. data/lib/chef/log.rb +1 -1
  14. data/lib/chef/mixin/openssl_helper.rb +26 -3
  15. data/lib/chef/mixin/template.rb +1 -0
  16. data/lib/chef/node_map.rb +5 -2
  17. data/lib/chef/provider/mount/solaris.rb +0 -1
  18. data/lib/chef/provider/package/zypper.rb +0 -1
  19. data/lib/chef/provider/yum_repository.rb +1 -1
  20. data/lib/chef/provider/zypper_repository.rb +1 -1
  21. data/lib/chef/resource.rb +2 -0
  22. data/lib/chef/resource/cron_access.rb +2 -2
  23. data/lib/chef/resource/cron_d.rb +1 -1
  24. data/lib/chef/resource/lwrp_base.rb +7 -0
  25. data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
  26. data/lib/chef/resource/sudo.rb +1 -1
  27. data/lib/chef/shell/shell_session.rb +2 -0
  28. data/lib/chef/version.rb +2 -2
  29. data/spec/functional/knife/ssh_spec.rb +4 -4
  30. data/spec/functional/resource/aix_service_spec.rb +0 -1
  31. data/spec/functional/resource/aixinit_service_spec.rb +0 -1
  32. data/spec/functional/resource/apt_package_spec.rb +0 -1
  33. data/spec/functional/resource/cron_spec.rb +0 -1
  34. data/spec/functional/resource/insserv_spec.rb +0 -1
  35. data/spec/functional/run_lock_spec.rb +2 -1
  36. data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
  37. data/spec/functional/version_spec.rb +1 -1
  38. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  39. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  40. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  41. data/spec/integration/recipes/notifies_spec.rb +1 -1
  42. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  43. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
  44. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +2 -0
  45. data/spec/integration/recipes/resource_load_spec.rb +1 -0
  46. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  47. data/spec/scripts/ssl-serve.rb +1 -1
  48. data/spec/spec_helper.rb +5 -4
  49. data/spec/support/shared/integration/knife_support.rb +2 -5
  50. data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +2 -4
  51. data/spec/unit/cookbook/gem_installer_spec.rb +2 -1
  52. data/spec/unit/dsl/platform_introspection_spec.rb +1 -0
  53. data/spec/unit/event_dispatch/dispatcher_spec.rb +3 -0
  54. data/spec/unit/knife/cookbook_upload_spec.rb +5 -6
  55. data/spec/unit/lwrp_spec.rb +4 -4
  56. data/spec/unit/mixin/securable_spec.rb +0 -1
  57. data/spec/unit/property_spec.rb +5 -5
  58. data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -1
  59. data/spec/unit/provider/package/rubygems_spec.rb +5 -10
  60. data/spec/unit/provider/package/windows_spec.rb +30 -53
  61. data/spec/unit/provider/service/windows_spec.rb +2 -6
  62. data/spec/unit/provider/systemd_unit_spec.rb +28 -24
  63. data/spec/unit/provider_spec.rb +1 -0
  64. data/spec/unit/resource/windows_package_spec.rb +1 -0
  65. data/spec/unit/run_context/cookbook_compiler_spec.rb +1 -1
  66. data/spec/unit/win32/security_spec.rb +4 -3
  67. metadata +14 -8
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  #
3
2
  # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
4
3
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  #
3
2
  # Author:: Dheeraj Dubey (<dheeraj.dubey@msystechnologies.com>)
4
3
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require File.expand_path("../../spec_helper", __FILE__)
18
+ require File.expand_path("../spec_helper", __dir__)
19
19
  require "chef/client"
20
20
 
21
21
  describe Chef::RunLock do
@@ -435,6 +435,7 @@ describe Chef::RunLock do
435
435
 
436
436
  class TestRunLock < Chef::RunLock
437
437
  attr_accessor :client_process
438
+
438
439
  def create_lock
439
440
  super
440
441
  client_process.fire_event("created lock")
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  require "chef/json_compat"
20
- require File.expand_path("../../../../spec_helper", __FILE__)
20
+ require File.expand_path("../../../spec_helper", __dir__)
21
21
 
22
22
  describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
23
23
  before(:all) do
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require File.expand_path("../../spec_helper", __FILE__)
18
+ require File.expand_path("../spec_helper", __dir__)
19
19
  require "chef/mixin/shell_out"
20
20
  require "chef/version"
21
21
  require "ohai/version"
@@ -6,7 +6,7 @@ describe "Accumulators" do
6
6
  include IntegrationSupport
7
7
  include Chef::Mixin::ShellOut
8
8
 
9
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
9
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
10
10
 
11
11
  # Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
12
12
  # following constraints are satisfied:
@@ -6,7 +6,7 @@ describe "LWRPs with inline resources" do
6
6
  include IntegrationSupport
7
7
  include Chef::Mixin::ShellOut
8
8
 
9
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
9
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
10
10
 
11
11
  # Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
12
12
  # following constraints are satisfied:
@@ -6,7 +6,7 @@ describe "LWRPs" do
6
6
  include IntegrationSupport
7
7
  include Chef::Mixin::ShellOut
8
8
 
9
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
9
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
10
10
 
11
11
  # Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
12
12
  # following constraints are satisfied:
@@ -6,7 +6,7 @@ describe "notifications" do
6
6
  include IntegrationSupport
7
7
  include Chef::Mixin::ShellOut
8
8
 
9
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
9
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
10
10
  let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
11
11
 
12
12
  when_the_repository "notifies a nameless resource" do
@@ -23,7 +23,7 @@ describe "notifying_block" do
23
23
  include IntegrationSupport
24
24
  include Chef::Mixin::ShellOut
25
25
 
26
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
26
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
27
27
  let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
28
28
 
29
29
  when_the_repository "notifying_block test one" do
@@ -1319,7 +1319,7 @@ describe "Recipe DSL methods" do
1319
1319
 
1320
1320
  it "utf-8 dsl names work" do
1321
1321
  recipe = converge do
1322
- Straße("blah") {}
1322
+ Straße("blah") {} # rubocop: disable Naming/AsciiIdentifiers
1323
1323
  end
1324
1324
  expect(recipe.logged_warnings).to eq ""
1325
1325
  expect(BaseThingy.created_resource).to eq(UTF8Thingy)
@@ -6,6 +6,7 @@ describe "Resource::ActionClass#converge_if_changed" do
6
6
  module Namer
7
7
  extend self
8
8
  attr_accessor :current_index
9
+
9
10
  def incrementing_value
10
11
  @incrementing_value += 1
11
12
  @incrementing_value
@@ -30,6 +31,7 @@ describe "Resource::ActionClass#converge_if_changed" do
30
31
  property :state2, default: "default_state2"
31
32
  property :sensitive1, default: "default_dontprintme", sensitive: true
32
33
  attr_accessor :converged
34
+
33
35
  def initialize(*args)
34
36
  super
35
37
  @converged = 0
@@ -6,6 +6,7 @@ describe "Resource.load_current_value" do
6
6
  module Namer
7
7
  extend self
8
8
  attr_accessor :current_index
9
+
9
10
  def incrementing_value
10
11
  @incrementing_value += 1
11
12
  @incrementing_value
@@ -6,7 +6,7 @@ describe "Unified Mode" do
6
6
  include IntegrationSupport
7
7
  include Chef::Mixin::ShellOut
8
8
 
9
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
9
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
10
10
 
11
11
  let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
12
12
 
@@ -12,7 +12,7 @@ require "webrick/https"
12
12
 
13
13
  $ssl = true
14
14
 
15
- CHEF_SPEC_DATA = File.expand_path("../../data", __FILE__)
15
+ CHEF_SPEC_DATA = File.expand_path("../data", __dir__)
16
16
  cert_text = File.read(File.expand_path("ssl/chef-rspec.cert", CHEF_SPEC_DATA))
17
17
  cert = OpenSSL::X509::Certificate.new(cert_text)
18
18
  key_text = File.read(File.expand_path("ssl/chef-rspec.key", CHEF_SPEC_DATA))
@@ -24,10 +24,10 @@ module Shell
24
24
  IRB = nil unless defined? IRB
25
25
  end
26
26
 
27
- $LOAD_PATH.unshift File.expand_path("../..", __FILE__)
28
- $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
29
- $LOAD_PATH.unshift File.expand_path("../../chef-config/lib", __FILE__)
30
- $LOAD_PATH.unshift File.expand_path("../../chef-utils/lib", __FILE__)
27
+ $LOAD_PATH.unshift File.expand_path("..", __dir__)
28
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
29
+ $LOAD_PATH.unshift File.expand_path("../chef-config/lib", __dir__)
30
+ $LOAD_PATH.unshift File.expand_path("../chef-utils/lib", __dir__)
31
31
  $LOAD_PATH.unshift File.dirname(__FILE__)
32
32
 
33
33
  require "rubygems"
@@ -124,6 +124,7 @@ RSpec.configure do |config|
124
124
  end
125
125
  config.mock_with :rspec do |c|
126
126
  c.syntax = :expect
127
+ c.allow_message_expectations_on_nil = false
127
128
  end
128
129
 
129
130
  # Only run these tests on platforms that are also chef workstations
@@ -39,10 +39,7 @@ module KnifeSupport
39
39
 
40
40
  # Work on machines where we can't access /var
41
41
  Dir.mktmpdir("checksums") do |checksums_cache_dir|
42
- Chef::Config[:cache_options] = {
43
- path: checksums_cache_dir,
44
- skip_expires: true,
45
- }
42
+ Chef::Config[:syntax_check_cache_path] = checksums_cache_dir
46
43
 
47
44
  # This is Chef::Knife.run without load_commands--we'll load stuff
48
45
  # ourselves, thank you very much
@@ -117,7 +114,7 @@ module KnifeSupport
117
114
  ensure
118
115
  Chef::Log.use_log_devices(old_loggers)
119
116
  Chef::Log.level = old_log_level
120
- Chef::Config.delete(:cache_options)
117
+ Chef::Config.delete(:syntax_check_cache_path)
121
118
  Chef::Config.delete(:concurrency)
122
119
  end
123
120
 
@@ -25,11 +25,9 @@ describe Chef::ChefFS::FileSystem::OperationFailedError do
25
25
 
26
26
  context "has a cause attribute and HTTP result code is 400" do
27
27
  it "include error cause" do
28
- allow_message_expectations_on_nil
29
28
  response_body = '{"error":["Invalid key test in request body"]}'
30
- allow(@response).to receive(:code).and_return("400")
31
- allow(@response).to receive(:body).and_return(response_body)
32
- exception = Net::HTTPClientException.new("(exception) unauthorized", @response)
29
+ response = double(:response, code: "400", body: response_body)
30
+ exception = Net::HTTPClientException.new("(exception) unauthorized", response)
33
31
  expect do
34
32
  raise Chef::ChefFS::FileSystem::OperationFailedError.new(:write, self, exception), error_message
35
33
  end.to raise_error(Chef::ChefFS::FileSystem::OperationFailedError, "#{error_message} cause: #{response_body}")
@@ -95,7 +95,8 @@ describe Chef::Cookbook::GemInstaller do
95
95
 
96
96
  it "skip metadata installation when Chef::Config[:skip_gem_metadata_installation] is set to true" do
97
97
  Chef::Config[:skip_gem_metadata_installation] = true
98
- expect(gem_installer.install).to_not receive(:shell_out!)
98
+ expect(gem_installer).to_not receive(:shell_out!)
99
+ expect(gem_installer.install).to be_nil
99
100
  end
100
101
 
101
102
  it "install metadata when Chef::Config[:skip_gem_metadata_installation] is not true" do
@@ -21,6 +21,7 @@ require "chef/dsl/platform_introspection"
21
21
 
22
22
  class LanguageTester
23
23
  attr_reader :node
24
+
24
25
  def initialize(node)
25
26
  @node = node
26
27
  end
@@ -61,6 +61,7 @@ describe Chef::EventDispatch::Dispatcher do
61
61
  let(:event_sink) do
62
62
  Class.new(Chef::EventDispatch::Base) do
63
63
  attr_reader :synchronized_cookbook_args
64
+
64
65
  def synchronized_cookbook(cookbook_name)
65
66
  @synchronized_cookbook_args = [cookbook_name]
66
67
  end
@@ -79,6 +80,7 @@ describe Chef::EventDispatch::Dispatcher do
79
80
  let(:event_sink_1) do
80
81
  Class.new(Chef::EventDispatch::Base) do
81
82
  attr_reader :synchronized_cookbook_args
83
+
82
84
  def synchronized_cookbook(cookbook_name)
83
85
  @synchronized_cookbook_args = [cookbook_name]
84
86
  end
@@ -87,6 +89,7 @@ describe Chef::EventDispatch::Dispatcher do
87
89
  let(:event_sink_2) do
88
90
  Class.new(Chef::EventDispatch::Base) do
89
91
  attr_reader :synchronized_cookbook_args
92
+
90
93
  def synchronized_cookbook(cookbook_name, cookbook)
91
94
  @synchronized_cookbook_args = [cookbook_name, cookbook]
92
95
  end
@@ -323,19 +323,18 @@ describe Chef::Knife::CookbookUpload do
323
323
 
324
324
  context "when cookbook path is an array" do
325
325
  it "should warn users that no cookbooks exist" do
326
- knife.config[:cookbook_path] = ["/chef-repo/cookbooks", "/home/user/cookbooks"]
327
- expect(knife.ui).to receive(:warn).with(
328
- /Could not find any cookbooks in your cookbook path: '#{knife.config[:cookbook_path].join(', ')}'\. Use --cookbook-path to specify the desired path\./
329
- )
326
+ cookbook_path = windows? ? "C:/chef-repo/cookbooks" : "/chef-repo/cookbooks"
327
+ knife.config[:cookbook_path] = [cookbook_path, "/home/user/cookbooks"]
328
+ expect(knife.ui).to receive(:warn).with("Could not find any cookbooks in your cookbook path: '#{knife.config[:cookbook_path].join(", ")}'. Use --cookbook-path to specify the desired path.")
330
329
  knife.run
331
330
  end
332
331
  end
333
332
 
334
333
  context "when cookbook path is a string" do
335
334
  it "should warn users that no cookbooks exist" do
336
- knife.config[:cookbook_path] = "/chef-repo/cookbooks"
335
+ knife.config[:cookbook_path] = windows? ? "C:/chef-repo/cookbooks" : "/chef-repo/cookbooks"
337
336
  expect(knife.ui).to receive(:warn).with(
338
- /Could not find any cookbooks in your cookbook path: '#{knife.config[:cookbook_path]}'\. Use --cookbook-path to specify the desired path\./
337
+ "Could not find any cookbooks in your cookbook path: '#{knife.config[:cookbook_path]}'. Use --cookbook-path to specify the desired path."
339
338
  )
340
339
  knife.run
341
340
  end
@@ -140,7 +140,7 @@ describe "LWRP" do
140
140
  before do
141
141
  @tmpdir = Dir.mktmpdir("lwrp_test")
142
142
  @lwrp_path = File.join(@tmpdir, "foo.rb")
143
- content = IO.read(File.expand_path("../../data/lwrp/resources/foo.rb", __FILE__))
143
+ content = IO.read(File.expand_path("../data/lwrp/resources/foo.rb", __dir__))
144
144
  IO.write(@lwrp_path, content)
145
145
  Chef::Resource::LWRPBase.build_from_file("lwrp", @lwrp_path, nil)
146
146
  @original_resource = Chef::ResourceResolver.resolve(:lwrp_foo)
@@ -152,7 +152,7 @@ describe "LWRP" do
152
152
 
153
153
  context "And the LWRP is asked to load again, this time with different code" do
154
154
  before do
155
- content = IO.read(File.expand_path("../../data/lwrp_override/resources/foo.rb", __FILE__))
155
+ content = IO.read(File.expand_path("../data/lwrp_override/resources/foo.rb", __dir__))
156
156
  IO.write(@lwrp_path, content)
157
157
  Chef::Resource::LWRPBase.build_from_file("lwrp", @lwrp_path, nil)
158
158
  end
@@ -390,11 +390,11 @@ describe "LWRP" do
390
390
  end
391
391
 
392
392
  before(:each) do
393
- Dir[File.expand_path(File.expand_path("../../data/lwrp/resources/*", __FILE__))].each do |file|
393
+ Dir[File.expand_path(File.expand_path("../data/lwrp/resources/*", __dir__))].each do |file|
394
394
  Chef::Resource::LWRPBase.build_from_file(lwrp_cookbook_name, file, run_context)
395
395
  end
396
396
 
397
- Dir[File.expand_path(File.expand_path("../../data/lwrp/providers/*", __FILE__))].each do |file|
397
+ Dir[File.expand_path(File.expand_path("../data/lwrp/providers/*", __dir__))].each do |file|
398
398
  Chef::Provider::LWRPBase.build_from_file(lwrp_cookbook_name, file, run_context)
399
399
  end
400
400
  end
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  #
3
2
  # Author:: Mark Mzyk (<mmzyk@chef.io>)
4
3
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -111,11 +111,11 @@ describe "Chef::Resource.property" do
111
111
 
112
112
  with_property ":Straße" do
113
113
  it "properties with UTF-8 in their name work" do
114
- expect(resource.Straße).to eql(nil)
115
- expect(resource.Straße "foo").to eql("foo")
116
- expect(resource.Straße).to eql("foo")
117
- expect(resource.Straße = "bar").to eql("bar")
118
- expect(resource.Straße).to eql("bar")
114
+ expect(resource.Straße).to eql(nil) # rubocop: disable Naming/AsciiIdentifiers
115
+ expect(resource.Straße "foo").to eql("foo") # rubocop: disable Naming/AsciiIdentifiers
116
+ expect(resource.Straße).to eql("foo") # rubocop: disable Naming/AsciiIdentifiers
117
+ expect(resource.Straße = "bar").to eql("bar") # rubocop: disable Naming/AsciiIdentifiers
118
+ expect(resource.Straße).to eql("bar") # rubocop: disable Naming/AsciiIdentifiers
119
119
  end
120
120
  end
121
121
 
@@ -22,7 +22,7 @@ require "spec_helper"
22
22
  describe Chef::Provider::Package::Dnf::PythonHelper do
23
23
  let(:helper) { Chef::Provider::Package::Dnf::PythonHelper.instance }
24
24
 
25
- it "propagates stacktraces on stderr from the forked subprocess" do
25
+ it "propagates stacktraces on stderr from the forked subprocess", :rhel do
26
26
  allow(helper).to receive(:dnf_command).and_return("ruby -e 'raise \"your hands in the air\"'")
27
27
  expect { helper.query(:whatprovides, "tcpdump") }.to raise_error(/your hands in the air/)
28
28
  end
@@ -106,30 +106,25 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
106
106
  context "new default rubygems behavior" do
107
107
  before do
108
108
  Chef::Config[:rubygems_cache_enabled] = false
109
+
110
+ dep_installer = Gem::DependencyInstaller.new
111
+ expect(dep_installer).not_to receive(:find_gems_with_sources)
112
+ allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer)
109
113
  end
110
114
 
111
115
  it "finds a matching gem candidate version on rubygems 2.0.0+" do
112
116
  dep = Gem::Dependency.new("rspec", ">= 0")
113
- dep_installer = Gem::DependencyInstaller.new
114
- allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer)
115
- expect(dep_installer).not_to receive(:find_gems_with_sources).with(dep).and_call_original
116
117
  expect(@gem_env.candidate_version_from_remote(dep)).to be_kind_of(Gem::Version)
117
118
  end
118
119
 
119
120
  it "gives the candidate version as nil if none is found" do
120
121
  dep = Gem::Dependency.new("lksdjflksdjflsdkfj", ">= 0")
121
- dep_installer = Gem::DependencyInstaller.new
122
- allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer)
123
- expect(dep_installer).not_to receive(:find_gems_with_sources).with(dep).and_call_original
124
122
  expect(@gem_env.candidate_version_from_remote(dep)).to be_nil
125
123
  end
126
124
 
127
125
  it "finds a matching gem from a specific gemserver when explicit sources are given (to a server that doesn't respond to api requests)" do
128
126
  dep = Gem::Dependency.new("rspec", ">= 0")
129
- dep_installer = Gem::DependencyInstaller.new
130
- allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer)
131
- expect(dep_installer).not_to receive(:find_gems_with_sources).with(dep).and_call_original
132
- expect(@gem_env.candidate_version_from_remote(dep, "http://production.cf.rubygems.org")).to be_kind_of(Gem::Version)
127
+ expect(@gem_env.candidate_version_from_remote(dep, "https://rubygems.org")).to be_kind_of(Gem::Version)
133
128
  end
134
129
  end
135
130
 
@@ -42,7 +42,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
42
42
  let(:cache_path) { 'c:\\cache\\' }
43
43
 
44
44
  before(:each) do
45
- allow(::File).to receive(:exist?).with(provider.new_resource.source).and_return(true)
45
+ allow(::File).to receive(:exist?).with(new_resource.source).and_return(true)
46
46
  end
47
47
 
48
48
  describe "load_current_resource" do
@@ -66,20 +66,22 @@ describe Chef::Provider::Package::Windows, :windows_only do
66
66
 
67
67
  it "sets the version to be installed" do
68
68
  provider.load_current_resource
69
- expect(provider.new_resource.version).to eql("2.0")
69
+ expect(new_resource.version).to eql("2.0")
70
70
  end
71
71
  end
72
72
 
73
- context "when the source is a uri" do
74
- let(:resource_source) { "https://foo.bar/calculator.msi" }
75
-
76
- context "when the source has not been downloaded" do
73
+ context "when the source is not present it loads from cache" do
74
+ context "when the package is not installed" do
77
75
  before(:each) do
78
- allow(provider).to receive(:downloadable_file_missing?).and_return(true)
76
+ allow(provider).to receive(:uri_scheme?).and_return(false)
77
+ allow(provider.package_provider).to receive(:get_product_property).and_return(nil)
78
+ allow(provider.package_provider).to receive(:get_installed_version).and_return(nil)
79
+ allow(provider.package_provider).to receive(:package_version).and_return(nil)
79
80
  end
80
- it "sets the current version to unknown" do
81
+
82
+ it "sets the current version nil" do
81
83
  provider.load_current_resource
82
- expect(provider.current_resource.version).to eql("unknown")
84
+ expect(provider.current_resource.version).to eql(nil)
83
85
  end
84
86
  end
85
87
 
@@ -233,9 +235,9 @@ describe Chef::Provider::Package::Windows, :windows_only do
233
235
  end
234
236
  end
235
237
 
236
- it "returns @installer_type if it is set" do
237
- provider.new_resource.installer_type(:downeaster)
238
- expect(provider.installer_type).to eql(:downeaster)
238
+ it "returns the resource's installer_type if it is set" do
239
+ new_resource.installer_type(:nsis)
240
+ expect(provider.installer_type).to eql(:nsis)
239
241
  end
240
242
 
241
243
  it "sets installer_type to inno if the source contains inno" do
@@ -275,7 +277,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
275
277
 
276
278
  it "raises an error" do
277
279
  allow(::Kernel).to receive(:open).and_yield(StringIO.new(""))
278
- provider.new_resource.installer_type(nil)
280
+ new_resource.installer_type(nil)
279
281
  expect { provider.installer_type }.to raise_error(Chef::Exceptions::CannotDetermineWindowsInstallerType)
280
282
  end
281
283
  end
@@ -312,7 +314,10 @@ describe Chef::Provider::Package::Windows, :windows_only do
312
314
  let(:resource_source) { "https://foo.bar/calculator.exe" }
313
315
 
314
316
  it "downloads the http resource" do
315
- allow(File).to receive(:exist?).with('c:\cache\calculator.exe').and_return(false)
317
+ allow(provider).to receive(:uri_scheme?).and_return(true)
318
+ allow(provider).to receive(:installer_type).and_return(nil)
319
+ allow(File).to receive(:exist?).with("https\\foo.bar\\calculator.exe").and_return(false)
320
+ allow(provider).to receive(:compile_and_converge_action)
316
321
  expect(provider).to receive(:download_source_file)
317
322
  provider.run_action(:install)
318
323
  end
@@ -400,7 +405,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
400
405
  let(:resource_source) { "C:/a_missing_file.exe" }
401
406
  let(:installer_type) { nil }
402
407
  before do
403
- allow(::File).to receive(:exist?).with(provider.new_resource.source).and_return(false)
408
+ allow(::File).to receive(:exist?).with(new_resource.source).and_return(false)
404
409
  provider.load_current_resource
405
410
  end
406
411
 
@@ -414,51 +419,23 @@ describe Chef::Provider::Package::Windows, :windows_only do
414
419
  Chef::Config[:why_run] = false
415
420
  end
416
421
  end
417
- end
418
422
 
419
- shared_context "valid checksum" do
420
- context "checksum is valid" do
421
- before do
422
- allow(provider).to receive(:checksum).and_return("jiie00u3bbs92vsbhvgvklb2lasgh20ah")
423
- end
423
+ it "does not raise an error with a valid checksum" do
424
+ expect(Chef::Digester).to receive(:checksum_for_file).with(new_resource.source).and_return("abcdef1234567890")
425
+ expect(provider).to receive(:install_package)
424
426
 
425
- it "does not raise the checksum mismatch exception" do
426
- expect { provider.send(:validate_content!) }.to_not raise_error
427
- end
428
- end
429
- end
430
-
431
- shared_context "invalid checksum" do
432
- context "checksum is invalid" do
433
- before do
434
- allow(provider).to receive(:checksum).and_return("kiie30u3bbs92vsbhvgvklb2lasgh20ah")
435
- end
427
+ new_resource.checksum("abcdef1234567890")
436
428
 
437
- it "raises the checksum mismatch exception" do
438
- expect { provider.send(:validate_content!) }.to raise_error(
439
- Chef::Exceptions::ChecksumMismatch
440
- )
441
- end
429
+ provider.run_action(:install)
442
430
  end
443
- end
444
431
 
445
- describe "validate_content!" do
446
- before(:each) do
447
- new_resource.checksum("jiie00u3bbs92vsbhvgvklb2lasgh20ah")
448
- end
449
-
450
- context "checksum is in lowercase" do
451
- include_context "valid checksum"
452
- include_context "invalid checksum"
453
- end
432
+ it "raises an error with an invalid checksum" do
433
+ expect(Chef::Digester).to receive(:checksum_for_file).with(new_resource.source).and_return("abcdef1234567890")
434
+ expect(provider).not_to receive(:install_package)
454
435
 
455
- context "checksum is in uppercase" do
456
- before do
457
- new_resource.checksum = new_resource.checksum.upcase
458
- end
436
+ new_resource.checksum("ffffffffffffffff")
459
437
 
460
- include_context "valid checksum"
461
- include_context "invalid checksum"
438
+ expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
462
439
  end
463
440
  end
464
441
  end