diff options
author | Tim Smith <tsmith@chef.io> | 2020-11-12 08:42:58 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-12 08:42:58 -0800 |
commit | 560e3eaf8ec102ecb3176ab5cb522abde29321b4 (patch) | |
tree | 841823601e0a7f3e793ab3684752cab1498bd68d /spec | |
parent | 5725bca78e8d5187592952bbd92ffcd58d5b8d7e (diff) | |
parent | e2e9b4b827c13c35d078c341f32223ae89db34a2 (diff) | |
download | mixlib-shellout-560e3eaf8ec102ecb3176ab5cb522abde29321b4.tar.gz |
Merge pull request #224 from MsysTechnologiesllc/Kapil/MSYS-1131_Retrieves_the_environment_variables_for_the_specified_user
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/mixlib/shellout_spec.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb index 9e79fa8..867644e 100644 --- a/spec/mixlib/shellout_spec.rb +++ b/spec/mixlib/shellout_spec.rb @@ -658,6 +658,21 @@ describe Mixlib::ShellOut do expect(running_user).to eql("#{ENV["COMPUTERNAME"].downcase}\\#{user}") end + context "when an alternate user is passed" do + let(:env_list) { ["ALLUSERSPROFILE=C:\\ProgramData", "TEMP=C:\\Windows\\TEMP", "TMP=C:\\Windows\\TEMP", "USERDOMAIN=WIN-G06ENRTTKF9", "USERNAME=testuser", "USERPROFILE=C:\\Users\\Default", "windir=C:\\Windows"] } + let(:current_env) { ["ALLUSERSPROFILE=C:\\ProgramData", "TEMP=C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\2", "TMP=C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\2", "USER=Administrator", "USERDOMAIN=WIN-G06ENRTTKF9", "USERDOMAIN_ROAMINGPROFILE=WIN-G06ENRTTKF9", "USERNAME=Administrator", "USERPROFILE=C:\\Users\\Administrator", "windir=C:\\Windows"] } + let(:merged_env) { ["ALLUSERSPROFILE=C:\\ProgramData", "TEMP=C:\\Windows\\TEMP", "TMP=C:\\Windows\\TEMP", "USER=Administrator", "USERDOMAIN=WIN-G06ENRTTKF9", "USERDOMAIN_ROAMINGPROFILE=WIN-G06ENRTTKF9", "USERNAME=testuser", "USERPROFILE=C:\\Users\\Default", "windir=C:\\Windows"] } + let(:converted) { { "ALLUSERSPROFILE" => "C:\\ProgramData", "TEMP" => "C:\\Windows\\TEMP", "TMP" => "C:\\Windows\\TEMP", "USERDOMAIN" => "WIN-G06ENRTTKF9", "USERNAME" => "testuser", "USERPROFILE" => "C:\\Users\\Default", "windir" => "C:\\Windows" } } + + it "merge environment variables" do + expect(Process.merge_env_variables(env_list, current_env)).to eql(merged_env) + end + + it "Convert an array to a hash" do + expect(Process.environment_list_to_hash(env_list)).to eql(converted) + end + end + context "when :elevated => true" do context "when user and password are passed" do let(:options) { { user: user, password: password, elevated: true } } |