summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorMatt Wrock <matt@mattwrock.com>2015-09-10 22:08:51 -0700
committerMatt Wrock <matt@mattwrock.com>2015-09-10 22:08:51 -0700
commit716eb7679cd30cd0e371ea8699d5dbdb47a05169 (patch)
tree1e9f35d60137c2cc22333ee37e6dd68f16b94996 /spec
parentb8625814b1065da1d8e1b44523ef50ed7d8f57f0 (diff)
downloadchef-716eb7679cd30cd0e371ea8699d5dbdb47a05169.tar.gz
remove pending reboot check for HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile if not on windows 2003mwrock/reboot_pending
Diffstat (limited to 'spec')
-rw-r--r--spec/functional/dsl/reboot_pending_spec.rb76
-rw-r--r--spec/unit/dsl/reboot_pending_spec.rb16
2 files changed, 44 insertions, 48 deletions
diff --git a/spec/functional/dsl/reboot_pending_spec.rb b/spec/functional/dsl/reboot_pending_spec.rb
index 14dd9412d5..1d11f38dbc 100644
--- a/spec/functional/dsl/reboot_pending_spec.rb
+++ b/spec/functional/dsl/reboot_pending_spec.rb
@@ -30,13 +30,6 @@ describe Chef::DSL::RebootPending, :windows_only do
ohai
end
- def registry_unsafe?
- registry.value_exists?('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager', { :name => 'PendingFileRenameOperations' }) ||
- registry.key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired')
- registry.key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootRequired') ||
- registry.key_exists?('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile')
- end
-
let(:node) { Chef::Node.new }
let(:events) { Chef::EventDispatch::Dispatcher.new }
let!(:ohai) { run_ohai } # Ensure we have necessary node data
@@ -45,76 +38,73 @@ describe Chef::DSL::RebootPending, :windows_only do
let(:registry) { Chef::Win32::Registry.new(run_context) }
describe "reboot_pending?" do
+ let(:reg_key) { nil }
+ let(:original_set) { false }
- describe "when there is nothing to indicate a reboot is pending" do
- it "should return false" do
- skip "Found existing registry keys" if registry_unsafe?
- expect(recipe.reboot_pending?).to be_falsey
- end
- end
+ before(:all) { @any_flag = Hash.new }
+
+ after { @any_flag[reg_key] = original_set }
describe 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations' do
+ let(:reg_key) { 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager' }
+ let(:original_set) { registry.value_exists?(reg_key, { :name => 'PendingFileRenameOperations' }) }
+
it "returns true if the registry value exists" do
- skip "Found existing registry keys" if registry_unsafe?
- registry.set_value('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager',
+ skip 'found existing registry key' if original_set
+ registry.set_value(reg_key,
{ :name => 'PendingFileRenameOperations', :type => :multi_string, :data => ['\??\C:\foo.txt|\??\C:\bar.txt'] })
expect(recipe.reboot_pending?).to be_truthy
end
after do
- unless registry_unsafe?
- registry.delete_value('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager', { :name => 'PendingFileRenameOperations' })
+ unless original_set
+ registry.delete_value(reg_key, { :name => 'PendingFileRenameOperations' })
end
end
end
- describe 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired' do
+ describe 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootRequired' do
+ let(:reg_key) { 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootRequired' }
+ let(:original_set) { registry.key_exists?(reg_key) }
+
it "returns true if the registry key exists" do
- skip "Found existing registry keys" if registry_unsafe?
- registry.create_key('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired', false)
+ skip 'found existing registry key' if original_set
+ pending "Permissions are limited to 'TrustedInstaller' by default"
+ registry.create_key(reg_key, false)
expect(recipe.reboot_pending?).to be_truthy
end
after do
- unless registry_unsafe?
- registry.delete_key('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired', false)
+ unless original_set
+ registry.delete_key(reg_key, false)
end
end
end
- describe 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootRequired' do
+ describe 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired' do
+ let(:reg_key) { 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired' }
+ let(:original_set) { registry.key_exists?(reg_key) }
+
it "returns true if the registry key exists" do
- pending "Permissions are limited to 'TrustedInstaller' by default"
- skip "Found existing registry keys" if registry_unsafe?
- registry.create_key('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootRequired', false)
+ skip 'found existing registry key' if original_set
+ registry.create_key(reg_key, false)
expect(recipe.reboot_pending?).to be_truthy
end
after do
- unless registry_unsafe?
- registry.delete_key('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootRequired', false)
+ unless original_set
+ registry.delete_key(reg_key, false)
end
end
end
- describe 'HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile\Flags' do
- it "returns true if the registry key exists" do
- skip "Found existing registry keys" if registry_unsafe?
- registry.create_key('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile', true)
- registry.set_value('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile',
- { :name => 'Flags', :type => :dword, :data => 3 })
-
- expect(recipe.reboot_pending?).to be_truthy
- end
-
- after do
- unless registry_unsafe?
- registry.delete_value('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile', { :name => 'Flags' })
- registry.delete_key('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile', false)
- end
+ describe "when there is nothing to indicate a reboot is pending" do
+ it "should return false" do
+ skip 'reboot pending' if @any_flag.any? { |_,v| v == true }
+ expect(recipe.reboot_pending?).to be_falsey
end
end
end
diff --git a/spec/unit/dsl/reboot_pending_spec.rb b/spec/unit/dsl/reboot_pending_spec.rb
index a55f91d5e6..6705820e17 100644
--- a/spec/unit/dsl/reboot_pending_spec.rb
+++ b/spec/unit/dsl/reboot_pending_spec.rb
@@ -50,11 +50,17 @@ describe Chef::DSL::RebootPending do
expect(recipe.reboot_pending?).to be_truthy
end
- it 'should return true if value "HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile" contains specific data' do
- allow(recipe).to receive(:registry_key_exists?).with('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').and_return(true)
- allow(recipe).to receive(:registry_get_values).with('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').and_return(
- [{:name => "Flags", :type => :dword, :data => 3}])
- expect(recipe.reboot_pending?).to be_truthy
+ context "version is server 2003" do
+ before do
+ allow(Chef::Platform).to receive(:windows_server_2003?).and_return(true)
+ end
+
+ it 'should return true if value "HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile" contains specific data on 2k3' do
+ allow(recipe).to receive(:registry_key_exists?).with('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').and_return(true)
+ allow(recipe).to receive(:registry_get_values).with('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').and_return(
+ [{:name => "Flags", :type => :dword, :data => 3}])
+ expect(recipe.reboot_pending?).to be_truthy
+ end
end
end