diff options
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/chef_helpers.rb | 16 | ||||
-rw-r--r-- | spec/support/shared/functional/execute_resource.rb | 4 | ||||
-rw-r--r-- | spec/support/shared/functional/win32_service.rb | 57 | ||||
-rw-r--r-- | spec/support/shared/functional/windows_script.rb | 4 |
4 files changed, 4 insertions, 77 deletions
diff --git a/spec/support/chef_helpers.rb b/spec/support/chef_helpers.rb index 6a0ca878cd..3738c4a41e 100644 --- a/spec/support/chef_helpers.rb +++ b/spec/support/chef_helpers.rb @@ -40,22 +40,6 @@ def make_tmpname(prefix_suffix, n = nil) path << suffix end -# This is a helper to determine if the ruby in the PATH contains -# win32/service gem. windows_service_manager tests create a windows -# service that starts with the system ruby and requires this gem. -def system_windows_service_gem? - windows_service_gem_check_command = %{ruby -r "win32/daemon" -e ":noop" > #{File::NULL} 2>&1} - if defined?(Bundler) - Bundler.with_unbundled_env do - # This returns true if the gem can be loaded - system(windows_service_gem_check_command) - end - else - # This returns true if the gem can be loaded - system(windows_service_gem_check_command) - end -end - # This is a helper to canonicalize paths that we're using in the file # tests. def canonicalize_path(path) diff --git a/spec/support/shared/functional/execute_resource.rb b/spec/support/shared/functional/execute_resource.rb index 9d1c29dfac..3f870d0fb6 100644 --- a/spec/support/shared/functional/execute_resource.rb +++ b/spec/support/shared/functional/execute_resource.rb @@ -68,7 +68,7 @@ shared_context "a command that can be executed as an alternate user" do end shared_examples_for "an execute resource that supports alternate user identity" do - context "when running on Windows", :windows_only, :windows_service_requires_assign_token do + context "when running on Windows", :windows_only do include_context "a command that can be executed as an alternate user" @@ -102,7 +102,7 @@ shared_examples_for "an execute resource that supports alternate user identity" end shared_examples_for "a resource with a guard specifying an alternate user identity" do - context "when running on Windows", :windows_only, :windows_service_requires_assign_token do + context "when running on Windows", :windows_only do include_context "alternate user identity" let(:resource_command_property) { :command } diff --git a/spec/support/shared/functional/win32_service.rb b/spec/support/shared/functional/win32_service.rb deleted file mode 100644 index 890c28de2c..0000000000 --- a/spec/support/shared/functional/win32_service.rb +++ /dev/null @@ -1,57 +0,0 @@ - -require "chef/application/windows_service_manager" - -shared_context "using Win32::Service" do - # Some helper methods. - - def test_service_exists? - ::Win32::Service.exists?("spec-service") - end - - def test_service_state - ::Win32::Service.status("spec-service").current_state - end - - def service_manager - Chef::Application::WindowsServiceManager.new(test_service) - end - - def cleanup - # Uninstall if the test service is installed. - if test_service_exists? - - # We can only uninstall when the service is stopped. - if test_service_state != "stopped" - ::Win32::Service.send("stop", "spec-service") - sleep 1 while test_service_state != "stopped" - end - - ::Win32::Service.delete("spec-service") - end - - # Delete the test_service_file if it exists - if File.exist?(test_service_file) - File.delete(test_service_file) - end - end - - # Definition for the test-service - - let(:test_service) do - { - service_name: "spec-service", - service_display_name: "Spec Test Service", - service_description: "Service for testing Chef::Application::WindowsServiceManager.", - service_file_path: File.expand_path(File.join(__dir__, "../../platforms/win32/spec_service.rb")), - delayed_start: true, - } - end - - # Test service creates a file for us to verify that it is running. - # Since our test service is running as Local System we should look - # for the file it creates under SYSTEM temp directory - - let(:test_service_file) do - "#{ENV["SystemDrive"]}\\windows\\temp\\spec_service_file" - end -end diff --git a/spec/support/shared/functional/windows_script.rb b/spec/support/shared/functional/windows_script.rb index 151ad2387c..9f328f0b92 100644 --- a/spec/support/shared/functional/windows_script.rb +++ b/spec/support/shared/functional/windows_script.rb @@ -168,11 +168,11 @@ shared_context Chef::Resource::WindowsScript do resource.run_action(:run) end - context "the script is executed with the identity of the current user", :windows_service_requires_assign_token do + context "the script is executed with the identity of the current user" do it_behaves_like "a script that cannot be accessed by other users if they are not administrators" end - context "the script is executed with an alternate non-admin identity", :windows_service_requires_assign_token do + context "the script is executed with an alternate non-admin identity" do include_context "alternate user identity" before do |