summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorKapil Chouhan <kapil.chouhan@msystechnologies.com>2020-09-09 10:32:56 +0000
committerKapil Chouhan <kapil.chouhan@msystechnologies.com>2020-09-09 12:56:04 +0000
commit1cd71f5ca3e84f307bd01e6624819976436e32be (patch)
treeab122336435969759a7acf6cbd141297521812c1 /spec
parent7ca0b99b56022ec04ef4a8f61fc7702ffaa8a765 (diff)
downloadmixlib-shellout-1cd71f5ca3e84f307bd01e6624819976436e32be.tar.gz
Added Dependency of ffi-win31-extensions gem and added test cases
Signed-off-by: Kapil Chouhan <kapil.chouhan@msystechnologies.com>
Diffstat (limited to 'spec')
-rw-r--r--spec/mixlib/shellout_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb
index 0d444a3..7f52084 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.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 } }