/usr/lib/ruby/vendor_ruby/specinfra/backend/winrm.rb is in ruby-specinfra 2.35.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | module Specinfra
module Backend
class Winrm < Base
include PowerShell::ScriptHelper
def os_info
{ :family => 'windows', :release => nil, :arch => nil }
end
def run_command(cmd, opts={})
script = create_script(cmd)
winrm = get_config(:winrm)
result = winrm.powershell(script)
stdout, stderr = [:stdout, :stderr].map do |s|
result[:data].select {|item| item.key? s}.map {|item| item[s]}.join
end
result[:exitcode] = 1 if result[:exitcode] == 0 and !stderr.empty?
if @example
@example.metadata[:command] = script
@example.metadata[:stdout] = stdout + stderr
end
CommandResult.new :stdout => stdout, :stderr => stderr, :exit_status => result[:exitcode]
end
end
end
end
|