summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Edwards <adamed@opscode.com>2015-12-22 08:15:49 -0800
committernimisha <nimisha.sharad@msystechnologies.com>2017-02-02 18:00:25 +0530
commit4044fdbe22d45e5f859f952cd5b2ae36f6e1115c (patch)
tree4e8573fc12808e9f241b7cca3e024688ac71faaf
parent8a68a2a8bd043ae0c75d2c21c0b75259942039e4 (diff)
downloadchef-4044fdbe22d45e5f859f952cd5b2ae36f6e1115c.tar.gz
Workaround on Windows execute tests for leaked user profiles
-rw-r--r--spec/support/shared/functional/execute_resource.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/spec/support/shared/functional/execute_resource.rb b/spec/support/shared/functional/execute_resource.rb
index 27813c71b6..8e402d3dbe 100644
--- a/spec/support/shared/functional/execute_resource.rb
+++ b/spec/support/shared/functional/execute_resource.rb
@@ -21,10 +21,15 @@ shared_context "a non-admin Windows user" do
let(:windows_nonadmin_user_domain) { ENV['COMPUTERNAME'] }
let(:windows_nonadmin_user_qualified) { "#{windows_nonadmin_user_domain}\\#{windows_nonadmin_user}" }
-
+ let(:temp_profile_path) { "#{ENV['USERPROFILE']}\\..\\cheftesttempuser" }
before do
shell_out!("net.exe user /delete #{windows_nonadmin_user}", returns: [0,2])
- shell_out!("net.exe user /add #{windows_nonadmin_user} \"#{windows_nonadmin_user_password}\"")
+
+ # Supply a profile path when creating a user to avoid an apparent Windows bug where deleting
+ # the user actually creates the profile when it did not immediately exist before executing
+ # net user /delete! For some reason, specifying an explicit path ensures that the path
+ # profile doesn't get created at deletion.
+ shell_out!("net.exe user /add #{windows_nonadmin_user} \"#{windows_nonadmin_user_password}\" /profilepath:#{temp_profile_path}")
end
after do