Skip to content

Commit

Permalink
fix windows with winrmv2
Browse files Browse the repository at this point in the history
  • Loading branch information
mwrock committed Sep 24, 2016
1 parent 6263478 commit a1f9bf7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ gem 'kitchen-docker'
gem 'berkshelf'
gem 'chef'
gem 'winrm-fs', '~> 1.0'
gem 'pry'
gem 'rb-readline'
7 changes: 2 additions & 5 deletions lib/kitchen/provisioner/finder/winrm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Winrm < Kitchen::Transport::Base
# that returns stdout
class Connection < Kitchen::Transport::Base::Connection
def node_execute(command, &block)
session.run_powershell_script(command, &block)
unelevated_session.run(command, &block)
end
end
end
Expand Down Expand Up @@ -41,10 +41,7 @@ def find_fqdn
% { \"{0}\" -f $_.Split(':')[1].Trim() }
EOS
data = ''
out[:data].each do |out_data|
stdout = out_data[:stdout]
data << stdout.chomp unless stdout.nil?
end
data = out.stdout.chomp unless out.stdout.nil?
data
end
end
Expand Down
12 changes: 5 additions & 7 deletions test/integration/node2/serverspec/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@
let(:connection) do
if RUBY_PLATFORM =~ /mingw/
require 'winrm'
::WinRM::WinRMWebService.new(
"http://#{ip}:5985/wsman",
:plaintext,
::WinRM::Connection.new(
endpoint: "http://#{ip}:5985/wsman",
user: 'vagrant',
pass: 'vagrant',
basic_auth_only: true
)
password: 'vagrant'
).shell(:cmd)
else
Net::SSH.start(
ip,
Expand Down Expand Up @@ -53,7 +51,7 @@

if RUBY_PLATFORM =~ /mingw/
it 'has a computername matching node fqdn' do
expect(connection.run_cmd('hostname').stdout.chomp).to eq(fqdn)
expect(connection.run('hostname').stdout.chomp).to eq(fqdn)
end
else
it 'has a computername matching node fqdn' do
Expand Down

0 comments on commit a1f9bf7

Please sign in to comment.