summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@opscode.com>2021-01-25 10:50:15 -0800
committerGitHub <noreply@github.com>2021-01-25 10:50:15 -0800
commit9581c707deb83babdd3995a24a51bf1e30d605d3 (patch)
tree4bdc22eee78eee5bede6c73e977d8a66ea15d873
parent131ae2f1f1b78d430f7d78138b5765b57fe2c994 (diff)
parent57968d656aee21c91fe19fe7ffaf292279a648f0 (diff)
downloadmixlib-shellout-9581c707deb83babdd3995a24a51bf1e30d605d3.tar.gz
Merge pull request #227 from chef/tests
fix broken windows tests
-rw-r--r--.expeditor/verify.pipeline.yml1
-rw-r--r--spec/mixlib/shellout_spec.rb19
2 files changed, 11 insertions, 9 deletions
diff --git a/.expeditor/verify.pipeline.yml b/.expeditor/verify.pipeline.yml
index ba3874e..5a69b50 100644
--- a/.expeditor/verify.pipeline.yml
+++ b/.expeditor/verify.pipeline.yml
@@ -52,3 +52,4 @@ steps:
executor:
docker:
host_os: windows
+ user: 'NT AUTHORITY\SYSTEM'
diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb
index 867644e..dce47dd 100644
--- a/spec/mixlib/shellout_spec.rb
+++ b/spec/mixlib/shellout_spec.rb
@@ -637,7 +637,12 @@ describe Mixlib::ShellOut do
# to match how whoami returns the information
it "should run as current user" do
- expect(running_user).to eql("#{ENV["USERDOMAIN"].downcase}\\#{ENV["USERNAME"].downcase}")
+ if ENV["USERNAME"] == "#{ENV["COMPUTERNAME"]}$"
+ expected_user = "nt authority\\system"
+ else
+ expected_user = "#{ENV["USERDOMAIN"].downcase}\\#{ENV["USERNAME"].downcase}"
+ end
+ expect(running_user).to eql(expected_user)
end
end
@@ -787,16 +792,12 @@ describe Mixlib::ShellOut do
end
context "when not using a batch file" do
- let(:cmd) { "#{executable_file_name} #{script_name}" }
-
- let(:executable_file_name) { "\"#{dir}/Ruby Parser.exe\"".tap(&make_executable!) }
- let(:make_executable!) { lambda { |filename| Mixlib::ShellOut.new("copy \"#{full_path_to_ruby}\" #{filename}").run_command } }
- let(:script_content) { "print \"#{expected_output}\"" }
+ let(:cmd) { "#{executable_file_name} -command #{script_content}" }
+ let(:executable_file_name) { "\"#{dir}/Powershell Parser.exe\"".tap(&make_executable!) }
+ let(:make_executable!) { lambda { |filename| Mixlib::ShellOut.new("copy \"c:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe\" #{filename}").run_command } }
+ let(:script_content) { "Write-Host \"#{expected_output}\"" }
let(:expected_output) { "Random #{rand(10000)}" }
- let(:full_path_to_ruby) { ENV["PATH"].split(";").map(&try_ruby).reject(&:nil?).first }
- let(:try_ruby) { lambda { |path| "#{path}\\ruby.exe" if File.executable? "#{path}\\ruby.exe" } }
-
it "should execute" do
is_expected.to eql(expected_output)
end