Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix broken windows tests #227

Merged
merged 1 commit into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .expeditor/verify.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ steps:
executor:
docker:
host_os: windows
user: 'NT AUTHORITY\SYSTEM'
19 changes: 10 additions & 9 deletions spec/mixlib/shellout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,12 @@
# 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

Expand Down Expand Up @@ -787,16 +792,12 @@
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
Expand Down