chef 13.6.0-universal-mingw32 → 13.6.4-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: 3e4e80c0de1137ddd227984e82625f3639a7f2a9
4
- data.tar.gz: 5fad1ea8fbe36e1df7ab94eb5f09010b2ac233af
3
+ metadata.gz: 5312db5aec7d7f3b32b5f91d1f869059fd6a1773
4
+ data.tar.gz: 62001ef77a66045535ad61574011cc88a034de4e
5
5
  SHA512:
6
- metadata.gz: ada2261cc4ec65adb6450bdf48261d6041680c92e276279d49d50ed9ed2df117f023a73912106ef9fe612bc20d7e21f175d406b14a9d0b3c1d1cac1fa4c18959
7
- data.tar.gz: 6faae2f2806281b90ef8df82418811f26e5f7197f56369d46c8af5804ae8a7d2b8f82b6b8932de996ea5fd141c836d20bcb18dbd414ae74d34cec2a46011713e
6
+ metadata.gz: eafd0d163281e7c7acce7ddb724942ee96fa88255d86d5688cdf1c2fc6a87c3b943b50a513cfccfa782f192a34ee0e82ee4af8f43da88524d6497fa3b466e0c4
7
+ data.tar.gz: 7d40acf7ee328e5bad963ab375885418acc47f3e661ee171d7934f93aabb34b333618057880839c985d37278dd2d7b228a74d818045e4e8ae727669e255b755f
data/VERSION CHANGED
@@ -1 +1 @@
1
- 13.6.0
1
+ 13.6.4
@@ -477,6 +477,9 @@ class Chef
477
477
  elsif candidate_version.nil?
478
478
  Chef::Log.debug("#{new_resource} #{package_name} has no candidate_version to upgrade to")
479
479
  target_version_array.push(nil)
480
+ elsif current_version.nil?
481
+ Chef::Log.debug("#{new_resource} has no existing installed version. Installing install #{candidate_version}")
482
+ target_version_array.push(candidate_version)
480
483
  elsif version_compare(current_version, candidate_version) == 1 && !new_resource.allow_downgrade
481
484
  Chef::Log.debug("#{new_resource} #{package_name} has installed version #{current_version}, which is newer than available version #{candidate_version}. Skipping...)")
482
485
  target_version_array.push(nil)
@@ -127,11 +127,20 @@ class Chef
127
127
 
128
128
  private
129
129
 
130
+ # compare 2 versions to each other to see which is newer.
131
+ # this differs from the standard package method because we
132
+ # need to be able to parse debian version strings which contain
133
+ # tildes which Gem cannot properly parse
134
+ #
135
+ # @return [Integer] 1 if v1 > v2. 0 if they're equal. -1 if v1 < v2
130
136
  def version_compare(v1, v2)
131
- gem_v1 = v1.gsub(/[_+]/, "+" => "-", "_" => "-") unless v1.nil?
132
- gem_v2 = v2.gsub(/[_+]/, "+" => "-", "_" => "-") unless v2.nil?
133
-
134
- Gem::Version.new(gem_v1) <=> Gem::Version.new(gem_v2)
137
+ if !shell_out_compact_timeout("dpkg", "--compare-versions", v1.to_s, "gt", v2.to_s).error?
138
+ 1
139
+ elsif !shell_out_compact_timeout("dpkg", "--compare-versions", v1.to_s, "eq", v2.to_s).error?
140
+ 0
141
+ else
142
+ -1
143
+ end
135
144
  end
136
145
 
137
146
  # Runs command via shell_out with magic environment to disable
@@ -106,6 +106,22 @@ class Chef
106
106
 
107
107
  private
108
108
 
109
+ # compare 2 versions to each other to see which is newer.
110
+ # this differs from the standard package method because we
111
+ # need to be able to parse debian version strings which contain
112
+ # tildes which Gem cannot properly parse
113
+ #
114
+ # @return [Integer] 1 if v1 > v2. 0 if they're equal. -1 if v1 < v2
115
+ def version_compare(v1, v2)
116
+ if !shell_out_compact_timeout("dpkg", "--compare-versions", v1.to_s, "gt", v2.to_s).error?
117
+ 1
118
+ elsif !shell_out_compact_timeout("dpkg", "--compare-versions", v1.to_s, "eq", v2.to_s).error?
119
+ 0
120
+ else
121
+ -1
122
+ end
123
+ end
124
+
109
125
  def read_current_version_of_package(package_name)
110
126
  Chef::Log.debug("#{new_resource} checking install state of #{package_name}")
111
127
  status = shell_out_compact_timeout!("dpkg", "-s", package_name, returns: [0, 1])
@@ -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("13.6.0")
26
+ VERSION = Chef::VersionString.new("13.6.4")
27
27
  end
28
28
 
29
29
  #
@@ -17,6 +17,8 @@
17
17
  #
18
18
 
19
19
  require "spec_helper"
20
+ require "mixlib/shellout"
21
+ require "chef/mixin/user_context"
20
22
  if Chef::Platform.windows?
21
23
  require "chef/win32/security"
22
24
  end
@@ -26,13 +28,37 @@ describe "Chef::Win32::Security", :windows_only do
26
28
  expect(Chef::ReservedNames::Win32::Security.has_admin_privileges?).to eq(true)
27
29
  end
28
30
 
29
- # We've done some investigation adding a negative test and it turned
30
- # out to be a lot of work since mixlib-shellout doesn't have user
31
- # support for windows.
32
- #
33
- # TODO - Add negative tests once mixlib-shellout has user support
34
- it "has_admin_privileges? returns false when running as non-admin" do
35
- skip "requires user support in mixlib-shellout"
31
+ describe "running as non admin user" do
32
+ include Chef::Mixin::UserContext
33
+ let(:user) { "security_user" }
34
+ let(:password) { "Security@123" }
35
+
36
+ let(:domain) do
37
+ whoami = Mixlib::ShellOut.new("whoami")
38
+ whoami.run_command
39
+ whoami.error!
40
+ whoami.stdout.split("\\")[0]
41
+ end
42
+ before do
43
+ allow_any_instance_of(Chef::Mixin::UserContext).to receive(:node).and_return({ "platform_family" => "windows" })
44
+ allow(Chef::Platform).to receive(:windows_server_2003?).and_return(false)
45
+ allow(Chef::ReservedNames::Win32::Security).to receive(:OpenProcessToken).and_return(true)
46
+ add_user = Mixlib::ShellOut.new("net user #{user} #{password} /ADD")
47
+ add_user.run_command
48
+ add_user.error!
49
+ end
50
+
51
+ after do
52
+ delete_user = Mixlib::ShellOut.new("net user #{user} /delete")
53
+ delete_user.run_command
54
+ delete_user.error!
55
+ end
56
+ it "has_admin_privileges? returns false" do
57
+ has_admin_privileges = with_user_context(user, password, domain) do
58
+ Chef::ReservedNames::Win32::Security.has_admin_privileges?
59
+ end
60
+ expect(has_admin_privileges).to eq(false)
61
+ end
36
62
  end
37
63
 
38
64
  describe "get_file_security" do
@@ -475,6 +475,40 @@ mpg123 1.12.1-0ubuntu1
475
475
  end
476
476
  end
477
477
 
478
+ describe "#action_install" do
479
+ it "should run dpkg to compare versions if an existing version is installed" do
480
+ allow(@provider).to receive(:get_current_versions).and_return("1.4.0")
481
+ allow(@new_resource).to receive(:allow_downgrade).and_return(false)
482
+ expect(@provider).to receive(:shell_out_compact_timeout).with(
483
+ "dpkg", "--compare-versions", "1.4.0", "gt", "0.8.12-7"
484
+ ).and_return(double(error?: false))
485
+ @provider.run_action(:upgrade)
486
+ end
487
+
488
+ it "should install the package if the installed version is older" do
489
+ allow(@provider).to receive(:get_current_versions).and_return("0.4.0")
490
+ allow(@new_resource).to receive(:allow_downgrade).and_return(false)
491
+ expect(@provider).to receive(:version_compare).and_return(-1)
492
+ expect(@provider).to receive(:shell_out!).with(
493
+ "apt-get", "-q", "-y", "install", "irssi=0.8.12-7",
494
+ :env => { "DEBIAN_FRONTEND" => "noninteractive" },
495
+ :timeout => @timeout
496
+ )
497
+ @provider.run_action(:upgrade)
498
+ end
499
+
500
+ it "should not compare versions if an existing version is not installed" do
501
+ allow(@provider).to receive(:get_current_versions).and_return(nil)
502
+ allow(@new_resource).to receive(:allow_downgrade).and_return(false)
503
+ expect(@provider).not_to receive(:version_compare)
504
+ expect(@provider).to receive(:shell_out!).with(
505
+ "apt-get", "-q", "-y", "install", "irssi=0.8.12-7",
506
+ :env => { "DEBIAN_FRONTEND" => "noninteractive" },
507
+ :timeout => @timeout
508
+ )
509
+ @provider.run_action(:upgrade)
510
+ end
511
+ end
478
512
  end
479
513
  end
480
514
  end
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: 13.6.0
4
+ version: 13.6.4
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: 2017-10-30 00:00:00.000000000 Z
11
+ date: 2017-11-07 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: 13.6.0
19
+ version: 13.6.4
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: 13.6.0
26
+ version: 13.6.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mixlib-cli
29
29
  requirement: !ruby/object:Gem::Requirement