diff options
author | Matt Wrock <matt@mattwrock.com> | 2015-09-11 10:32:43 -0700 |
---|---|---|
committer | Matt Wrock <matt@mattwrock.com> | 2015-09-11 10:32:43 -0700 |
commit | 5d4dd15ced791b49ec571cfd21ad3ae2afe6b132 (patch) | |
tree | 312a6f08f3d2139186dc3831cf56a6419e6d2396 /spec/functional | |
parent | e6db5e83d8eb486042c48b2ce6e31f8b8b6b990f (diff) | |
parent | 716eb7679cd30cd0e371ea8699d5dbdb47a05169 (diff) | |
download | chef-5d4dd15ced791b49ec571cfd21ad3ae2afe6b132.tar.gz |
Merge pull request #3909 from chef/mwrock/reboot_pending
remove pending reboot check for HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile
Diffstat (limited to 'spec/functional')
-rw-r--r-- | spec/functional/dsl/reboot_pending_spec.rb | 76 |
1 files changed, 33 insertions, 43 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 |