winrm 1.7.3 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +10 -10
- data/.rspec +3 -3
- data/.travis.yml +12 -12
- data/Gemfile +9 -9
- data/LICENSE +202 -202
- data/README.md +213 -194
- data/Rakefile +36 -36
- data/Vagrantfile +9 -9
- data/WinrmAppveyor.psm1 +32 -0
- data/appveyor.yml +51 -42
- data/bin/rwinrm +97 -97
- data/changelog.md +3 -0
- data/lib/winrm.rb +42 -42
- data/lib/winrm/command_executor.rb +6 -2
- data/lib/winrm/command_output_decoder.rb +53 -53
- data/lib/winrm/exceptions/exceptions.rb +57 -57
- data/lib/winrm/helpers/iso8601_duration.rb +58 -58
- data/lib/winrm/helpers/powershell_script.rb +42 -42
- data/lib/winrm/http/response_handler.rb +82 -82
- data/lib/winrm/http/transport.rb +17 -0
- data/lib/winrm/output.rb +43 -43
- data/lib/winrm/soap_provider.rb +39 -39
- data/lib/winrm/version.rb +1 -1
- data/lib/winrm/winrm_service.rb +550 -547
- data/preamble +17 -17
- data/spec/auth_timeout_spec.rb +16 -16
- data/spec/cmd_spec.rb +102 -102
- data/spec/command_executor_spec.rb +27 -10
- data/spec/command_output_decoder_spec.rb +37 -37
- data/spec/config-example.yml +19 -19
- data/spec/exception_spec.rb +50 -50
- data/spec/issue_184_spec.rb +67 -67
- data/spec/issue_59_spec.rb +23 -23
- data/spec/matchers.rb +74 -74
- data/spec/output_spec.rb +110 -110
- data/spec/powershell_spec.rb +97 -97
- data/spec/response_handler_spec.rb +59 -59
- data/spec/spec_helper.rb +73 -73
- data/spec/stubs/responses/get_command_output_response.xml.erb +13 -13
- data/spec/stubs/responses/open_shell_v1.xml +19 -19
- data/spec/stubs/responses/open_shell_v2.xml +20 -20
- data/spec/stubs/responses/soap_fault_v1.xml +36 -36
- data/spec/stubs/responses/soap_fault_v2.xml +42 -42
- data/spec/stubs/responses/wmi_error_v2.xml +41 -41
- data/spec/transport_spec.rb +139 -124
- data/spec/winrm_options_spec.rb +76 -76
- data/spec/winrm_primitives_spec.rb +51 -51
- data/spec/wql_spec.rb +14 -14
- data/winrm.gemspec +40 -40
- metadata +4 -3
data/preamble
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
=begin
|
2
|
-
This file is part of WinRM; the Ruby library for Microsoft WinRM.
|
3
|
-
|
4
|
-
Copyright © 2010 Dan Wanek <dan.wanek@gmail.com>
|
5
|
-
|
6
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
you may not use this file except in compliance with the License.
|
8
|
-
You may obtain a copy of the License at
|
9
|
-
|
10
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
|
12
|
-
Unless required by applicable law or agreed to in writing, software
|
13
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
See the License for the specific language governing permissions and
|
16
|
-
limitations under the License.
|
17
|
-
=end
|
1
|
+
=begin
|
2
|
+
This file is part of WinRM; the Ruby library for Microsoft WinRM.
|
3
|
+
|
4
|
+
Copyright © 2010 Dan Wanek <dan.wanek@gmail.com>
|
5
|
+
|
6
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
you may not use this file except in compliance with the License.
|
8
|
+
You may obtain a copy of the License at
|
9
|
+
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
|
12
|
+
Unless required by applicable law or agreed to in writing, software
|
13
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
See the License for the specific language governing permissions and
|
16
|
+
limitations under the License.
|
17
|
+
=end
|
data/spec/auth_timeout_spec.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# This test may only be meaningful with kerberos auth
|
3
|
-
# Against server 2012, a kerberos connection will require reauth (get a 401)
|
4
|
-
# if there are no requests for >= 15 seconds
|
5
|
-
|
6
|
-
describe 'Verify kerberos will reauth when necessary', kerberos: true do
|
7
|
-
before(:all) do
|
8
|
-
@winrm = winrm_connection
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'work with a 18 second sleep' do
|
12
|
-
ps_command = 'Start-Sleep -s 18'
|
13
|
-
output = @winrm.run_powershell_script(ps_command)
|
14
|
-
output[:exitcode].should == 0
|
15
|
-
end
|
16
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This test may only be meaningful with kerberos auth
|
3
|
+
# Against server 2012, a kerberos connection will require reauth (get a 401)
|
4
|
+
# if there are no requests for >= 15 seconds
|
5
|
+
|
6
|
+
describe 'Verify kerberos will reauth when necessary', kerberos: true do
|
7
|
+
before(:all) do
|
8
|
+
@winrm = winrm_connection
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'work with a 18 second sleep' do
|
12
|
+
ps_command = 'Start-Sleep -s 18'
|
13
|
+
output = @winrm.run_powershell_script(ps_command)
|
14
|
+
output[:exitcode].should == 0
|
15
|
+
end
|
16
|
+
end
|
data/spec/cmd_spec.rb
CHANGED
@@ -1,102 +1,102 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
describe 'winrm client cmd', integration: true do
|
3
|
-
before(:all) do
|
4
|
-
@winrm = winrm_connection
|
5
|
-
end
|
6
|
-
|
7
|
-
describe 'empty string' do
|
8
|
-
subject(:output) { @winrm.cmd('') }
|
9
|
-
it { should have_exit_code 0 }
|
10
|
-
it { should have_no_stdout }
|
11
|
-
it { should have_no_stderr }
|
12
|
-
end
|
13
|
-
|
14
|
-
describe 'ipconfig' do
|
15
|
-
subject(:output) { @winrm.cmd('ipconfig') }
|
16
|
-
it { should have_exit_code 0 }
|
17
|
-
it { should have_stdout_match(/Windows IP Configuration/) }
|
18
|
-
it { should have_no_stderr }
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'echo \'hello world\' using apostrophes' do
|
22
|
-
subject(:output) { @winrm.cmd("echo 'hello world'") }
|
23
|
-
it { should have_exit_code 0 }
|
24
|
-
it { should have_stdout_match(/'hello world'/) }
|
25
|
-
it { should have_no_stderr }
|
26
|
-
end
|
27
|
-
|
28
|
-
describe 'echo "string with trailing \\" using double quotes' do
|
29
|
-
# This is a regression test for #131. " is converted to " when serializing
|
30
|
-
# the command to SOAP/XML. Any naive substitution performed on such a serialized
|
31
|
-
# string can result in any \& sequence being interpreted as a back-substitution.
|
32
|
-
subject(:output) { @winrm.cmd('echo "string with trailing \\"') }
|
33
|
-
it { should have_exit_code 0 }
|
34
|
-
it { should have_stdout_match(/string with trailing \\/) }
|
35
|
-
it { should have_no_stderr }
|
36
|
-
end
|
37
|
-
|
38
|
-
describe 'capturing output from stdout and stderr' do
|
39
|
-
subject(:output) do
|
40
|
-
# Note: Multiple lines doesn't work:
|
41
|
-
# script = <<-eos
|
42
|
-
# echo Hello
|
43
|
-
# echo , world! 1>&2
|
44
|
-
# eos
|
45
|
-
|
46
|
-
script = 'echo Hello & echo , world! 1>&2'
|
47
|
-
|
48
|
-
@captured_stdout = ''
|
49
|
-
@captured_stderr = ''
|
50
|
-
@winrm.cmd(script) do |stdout, stderr|
|
51
|
-
@captured_stdout << stdout if stdout
|
52
|
-
@captured_stderr << stderr if stderr
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'should have stdout' do
|
57
|
-
expect(output.stdout).to eq("Hello \r\n")
|
58
|
-
expect(output.stdout).to eq(@captured_stdout)
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'should have stderr' do
|
62
|
-
expect(output.stderr).to eq(", world! \r\n")
|
63
|
-
expect(output.stderr).to eq(@captured_stderr)
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'should have output' do
|
67
|
-
expect(output.output).to eq("Hello \r\n, world! \r\n")
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe 'ipconfig with /all argument' do
|
72
|
-
subject(:output) { @winrm.cmd('ipconfig', %w(/all)) }
|
73
|
-
it { should have_exit_code 0 }
|
74
|
-
it { should have_stdout_match(/Windows IP Configuration/) }
|
75
|
-
it { should have_no_stderr }
|
76
|
-
end
|
77
|
-
|
78
|
-
describe 'dir with incorrect argument /z' do
|
79
|
-
subject(:output) { @winrm.cmd('dir /z') }
|
80
|
-
it { should have_exit_code 1 }
|
81
|
-
it { should have_no_stdout }
|
82
|
-
it { should have_stderr_match(/Invalid switch/) }
|
83
|
-
end
|
84
|
-
|
85
|
-
describe 'ipconfig && echo error 1>&2' do
|
86
|
-
subject(:output) { @winrm.cmd('ipconfig && echo error 1>&2') }
|
87
|
-
it { should have_exit_code 0 }
|
88
|
-
it { should have_stdout_match(/Windows IP Configuration/) }
|
89
|
-
it { should have_stderr_match(/error/) }
|
90
|
-
end
|
91
|
-
|
92
|
-
describe 'ipconfig with a block' do
|
93
|
-
subject(:stdout) do
|
94
|
-
outvar = ''
|
95
|
-
@winrm.cmd('ipconfig') do |stdout, _stderr|
|
96
|
-
outvar << stdout
|
97
|
-
end
|
98
|
-
outvar
|
99
|
-
end
|
100
|
-
it { should match(/Windows IP Configuration/) }
|
101
|
-
end
|
102
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
describe 'winrm client cmd', integration: true do
|
3
|
+
before(:all) do
|
4
|
+
@winrm = winrm_connection
|
5
|
+
end
|
6
|
+
|
7
|
+
describe 'empty string' do
|
8
|
+
subject(:output) { @winrm.cmd('') }
|
9
|
+
it { should have_exit_code 0 }
|
10
|
+
it { should have_no_stdout }
|
11
|
+
it { should have_no_stderr }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'ipconfig' do
|
15
|
+
subject(:output) { @winrm.cmd('ipconfig') }
|
16
|
+
it { should have_exit_code 0 }
|
17
|
+
it { should have_stdout_match(/Windows IP Configuration/) }
|
18
|
+
it { should have_no_stderr }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'echo \'hello world\' using apostrophes' do
|
22
|
+
subject(:output) { @winrm.cmd("echo 'hello world'") }
|
23
|
+
it { should have_exit_code 0 }
|
24
|
+
it { should have_stdout_match(/'hello world'/) }
|
25
|
+
it { should have_no_stderr }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'echo "string with trailing \\" using double quotes' do
|
29
|
+
# This is a regression test for #131. " is converted to " when serializing
|
30
|
+
# the command to SOAP/XML. Any naive substitution performed on such a serialized
|
31
|
+
# string can result in any \& sequence being interpreted as a back-substitution.
|
32
|
+
subject(:output) { @winrm.cmd('echo "string with trailing \\"') }
|
33
|
+
it { should have_exit_code 0 }
|
34
|
+
it { should have_stdout_match(/string with trailing \\/) }
|
35
|
+
it { should have_no_stderr }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'capturing output from stdout and stderr' do
|
39
|
+
subject(:output) do
|
40
|
+
# Note: Multiple lines doesn't work:
|
41
|
+
# script = <<-eos
|
42
|
+
# echo Hello
|
43
|
+
# echo , world! 1>&2
|
44
|
+
# eos
|
45
|
+
|
46
|
+
script = 'echo Hello & echo , world! 1>&2'
|
47
|
+
|
48
|
+
@captured_stdout = ''
|
49
|
+
@captured_stderr = ''
|
50
|
+
@winrm.cmd(script) do |stdout, stderr|
|
51
|
+
@captured_stdout << stdout if stdout
|
52
|
+
@captured_stderr << stderr if stderr
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should have stdout' do
|
57
|
+
expect(output.stdout).to eq("Hello \r\n")
|
58
|
+
expect(output.stdout).to eq(@captured_stdout)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should have stderr' do
|
62
|
+
expect(output.stderr).to eq(", world! \r\n")
|
63
|
+
expect(output.stderr).to eq(@captured_stderr)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should have output' do
|
67
|
+
expect(output.output).to eq("Hello \r\n, world! \r\n")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe 'ipconfig with /all argument' do
|
72
|
+
subject(:output) { @winrm.cmd('ipconfig', %w(/all)) }
|
73
|
+
it { should have_exit_code 0 }
|
74
|
+
it { should have_stdout_match(/Windows IP Configuration/) }
|
75
|
+
it { should have_no_stderr }
|
76
|
+
end
|
77
|
+
|
78
|
+
describe 'dir with incorrect argument /z' do
|
79
|
+
subject(:output) { @winrm.cmd('dir /z') }
|
80
|
+
it { should have_exit_code 1 }
|
81
|
+
it { should have_no_stdout }
|
82
|
+
it { should have_stderr_match(/Invalid switch/) }
|
83
|
+
end
|
84
|
+
|
85
|
+
describe 'ipconfig && echo error 1>&2' do
|
86
|
+
subject(:output) { @winrm.cmd('ipconfig && echo error 1>&2') }
|
87
|
+
it { should have_exit_code 0 }
|
88
|
+
it { should have_stdout_match(/Windows IP Configuration/) }
|
89
|
+
it { should have_stderr_match(/error/) }
|
90
|
+
end
|
91
|
+
|
92
|
+
describe 'ipconfig with a block' do
|
93
|
+
subject(:stdout) do
|
94
|
+
outvar = ''
|
95
|
+
@winrm.cmd('ipconfig') do |stdout, _stderr|
|
96
|
+
outvar << stdout
|
97
|
+
end
|
98
|
+
outvar
|
99
|
+
end
|
100
|
+
it { should match(/Windows IP Configuration/) }
|
101
|
+
end
|
102
|
+
end
|
@@ -233,16 +233,7 @@ describe WinRM::CommandExecutor, unit: true do
|
|
233
233
|
expect(output).to eq echo_output
|
234
234
|
end
|
235
235
|
|
236
|
-
|
237
|
-
before do
|
238
|
-
@times_called = 0
|
239
|
-
|
240
|
-
allow(service).to receive(:run_command) do
|
241
|
-
@times_called += 1
|
242
|
-
fail WinRM::WinRMWSManFault.new('oops', '2150858843') if @times_called == 1
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
236
|
+
shared_examples 'retry shell command' do
|
246
237
|
it 'does not close the current shell' do
|
247
238
|
expect(service).not_to receive(:close_shell)
|
248
239
|
|
@@ -261,6 +252,32 @@ describe WinRM::CommandExecutor, unit: true do
|
|
261
252
|
executor.run_cmd('echo', ['Hello'])
|
262
253
|
end
|
263
254
|
end
|
255
|
+
|
256
|
+
describe 'when shell is closed on server' do
|
257
|
+
before do
|
258
|
+
@times_called = 0
|
259
|
+
|
260
|
+
allow(service).to receive(:run_command) do
|
261
|
+
@times_called += 1
|
262
|
+
fail WinRM::WinRMWSManFault.new('oops', '2150858843') if @times_called == 1
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
include_examples 'retry shell command'
|
267
|
+
end
|
268
|
+
|
269
|
+
describe 'when shell accesses a deleted registry key' do
|
270
|
+
before do
|
271
|
+
@times_called = 0
|
272
|
+
|
273
|
+
allow(service).to receive(:run_command) do
|
274
|
+
@times_called += 1
|
275
|
+
fail WinRM::WinRMWSManFault.new('oops', '2147943418') if @times_called == 1
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
include_examples 'retry shell command'
|
280
|
+
end
|
264
281
|
end
|
265
282
|
|
266
283
|
describe 'when called many times over time' do
|
@@ -1,37 +1,37 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'winrm/command_output_decoder'
|
4
|
-
|
5
|
-
describe WinRM::CommandOutputDecoder, unit: true do
|
6
|
-
let(:raw_output_with_bom) do
|
7
|
-
'77u/' \
|
8
|
-
'ICAgQ29ubmVjdGlvbi1zcGVjaWZpYyBETlMgU3VmZml4ICAuIDogDQogICBMaW5rLWxvY2FsIElQdjYgQWRkcmVzcyA' \
|
9
|
-
'uIC4gLiAuIC4gOiBmZTgwOjo5MTFkOjE2OTQ6NTcwNDo1YjI5JTEyDQogICBJUHY0IEFkZHJlc3MuIC4gLiAuIC4gLi' \
|
10
|
-
'AuIC4gLiAuIC4gOiAxMC4wLjIuMTUNCiAgIFN1Ym5ldCBNYXNrIC4gLiAuIC4gLiAuIC4gLiAuIC4gLiA6IDI1NS4yN' \
|
11
|
-
'TUuMjU1LjANCiAgIERlZmF1bHQgR2F0ZXdheSAuIC4gLiAuIC4gLiAuIC4gLiA6IDEwLjAuMi4yDQoNClR1bm5lbCBh' \
|
12
|
-
'ZGFwdGVyIGlzYXRhcC57RjBENTY2RDgtNzlCMS00QUYwLUJENUQtMkM5RkVEOEI3MTE3fToNCg0KICAgTWVkaWEgU3R' \
|
13
|
-
'hdGUgLiAuIC4gLiAuIC4gLiAuIC4gLiAuIDogTWVkaWEgZGlzY29ubmVjdGVkDQogICBDb25uZWN0aW9uLXNwZWNpZm' \
|
14
|
-
'ljIEROUyBTdWZmaXggIC4gOiANCg0KVHVubmVsIGFkYXB0ZXIgVGVyZWRvIFR1bm5lbGluZyBQc2V1ZG8tSW50ZXJmY' \
|
15
|
-
'WNlOg0KDQogICBDb25uZWN0aW9uLXNwZWNpZmljIEROUyBTdWZmaXggIC4gOiANCiAgIElQdjYgQWRkcmVzcy4gLiAu' \
|
16
|
-
'IC4gLiAuIC4gLiAuIC4gLiA6IDIwMDE6MDo5ZDM4OjZhYmQ6NGJiOjI4YjU6ZjVmZjpmZGYwDQogICBMaW5rLWxvY2F' \
|
17
|
-
'sIElQdjYgQWRkcmVzcyAuIC4gLiAuIC4gOiBmZTgwOjo0YmI6MjhiNTpmNWZmOmZkZjAlMTQNCiAgIERlZmF1bHQgR2' \
|
18
|
-
'F0ZXdheSAuIC4gLiAuIC4gLiAuIC4gLiA6IDo6DQo='
|
19
|
-
end
|
20
|
-
let(:expected) do
|
21
|
-
" Connection-specific DNS Suffix . : \r\n Link-local IPv6 Address . . . . . : fe80::911" \
|
22
|
-
"d:1694:5704:5b29%12\r\n IPv4 Address. . . . . . . . . . . : 10.0.2.15\r\n Subnet Mask ." \
|
23
|
-
" . . . . . . . . . . : 255.255.255.0\r\n Default Gateway . . . . . . . . . : 10.0.2.2\r\n" \
|
24
|
-
"\r\nTunnel adapter isatap.{F0D566D8-79B1-4AF0-BD5D-2C9FED8B7117}:\r\n\r\n Media State . ." \
|
25
|
-
" . . . . . . . . . : Media disconnected\r\n Connection-specific DNS Suffix . : \r\n\r\nT" \
|
26
|
-
"unnel adapter Teredo Tunneling Pseudo-Interface:\r\n\r\n Connection-specific DNS Suffix " \
|
27
|
-
". : \r\n IPv6 Address. . . . . . . . . . . : 2001:0:9d38:6abd:4bb:28b5:f5ff:fdf0\r\n Li" \
|
28
|
-
"nk-local IPv6 Address . . . . . : fe80::4bb:28b5:f5ff:fdf0%14\r\n Default Gateway . . . ." \
|
29
|
-
" . . . . . : ::\r\n"
|
30
|
-
end
|
31
|
-
subject { described_class.new }
|
32
|
-
context 'valid UTF-8 raw output' do
|
33
|
-
it 'decodes' do
|
34
|
-
expect(subject.decode(raw_output_with_bom)).to eq(expected)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'winrm/command_output_decoder'
|
4
|
+
|
5
|
+
describe WinRM::CommandOutputDecoder, unit: true do
|
6
|
+
let(:raw_output_with_bom) do
|
7
|
+
'77u/' \
|
8
|
+
'ICAgQ29ubmVjdGlvbi1zcGVjaWZpYyBETlMgU3VmZml4ICAuIDogDQogICBMaW5rLWxvY2FsIElQdjYgQWRkcmVzcyA' \
|
9
|
+
'uIC4gLiAuIC4gOiBmZTgwOjo5MTFkOjE2OTQ6NTcwNDo1YjI5JTEyDQogICBJUHY0IEFkZHJlc3MuIC4gLiAuIC4gLi' \
|
10
|
+
'AuIC4gLiAuIC4gOiAxMC4wLjIuMTUNCiAgIFN1Ym5ldCBNYXNrIC4gLiAuIC4gLiAuIC4gLiAuIC4gLiA6IDI1NS4yN' \
|
11
|
+
'TUuMjU1LjANCiAgIERlZmF1bHQgR2F0ZXdheSAuIC4gLiAuIC4gLiAuIC4gLiA6IDEwLjAuMi4yDQoNClR1bm5lbCBh' \
|
12
|
+
'ZGFwdGVyIGlzYXRhcC57RjBENTY2RDgtNzlCMS00QUYwLUJENUQtMkM5RkVEOEI3MTE3fToNCg0KICAgTWVkaWEgU3R' \
|
13
|
+
'hdGUgLiAuIC4gLiAuIC4gLiAuIC4gLiAuIDogTWVkaWEgZGlzY29ubmVjdGVkDQogICBDb25uZWN0aW9uLXNwZWNpZm' \
|
14
|
+
'ljIEROUyBTdWZmaXggIC4gOiANCg0KVHVubmVsIGFkYXB0ZXIgVGVyZWRvIFR1bm5lbGluZyBQc2V1ZG8tSW50ZXJmY' \
|
15
|
+
'WNlOg0KDQogICBDb25uZWN0aW9uLXNwZWNpZmljIEROUyBTdWZmaXggIC4gOiANCiAgIElQdjYgQWRkcmVzcy4gLiAu' \
|
16
|
+
'IC4gLiAuIC4gLiAuIC4gLiA6IDIwMDE6MDo5ZDM4OjZhYmQ6NGJiOjI4YjU6ZjVmZjpmZGYwDQogICBMaW5rLWxvY2F' \
|
17
|
+
'sIElQdjYgQWRkcmVzcyAuIC4gLiAuIC4gOiBmZTgwOjo0YmI6MjhiNTpmNWZmOmZkZjAlMTQNCiAgIERlZmF1bHQgR2' \
|
18
|
+
'F0ZXdheSAuIC4gLiAuIC4gLiAuIC4gLiA6IDo6DQo='
|
19
|
+
end
|
20
|
+
let(:expected) do
|
21
|
+
" Connection-specific DNS Suffix . : \r\n Link-local IPv6 Address . . . . . : fe80::911" \
|
22
|
+
"d:1694:5704:5b29%12\r\n IPv4 Address. . . . . . . . . . . : 10.0.2.15\r\n Subnet Mask ." \
|
23
|
+
" . . . . . . . . . . : 255.255.255.0\r\n Default Gateway . . . . . . . . . : 10.0.2.2\r\n" \
|
24
|
+
"\r\nTunnel adapter isatap.{F0D566D8-79B1-4AF0-BD5D-2C9FED8B7117}:\r\n\r\n Media State . ." \
|
25
|
+
" . . . . . . . . . : Media disconnected\r\n Connection-specific DNS Suffix . : \r\n\r\nT" \
|
26
|
+
"unnel adapter Teredo Tunneling Pseudo-Interface:\r\n\r\n Connection-specific DNS Suffix " \
|
27
|
+
". : \r\n IPv6 Address. . . . . . . . . . . : 2001:0:9d38:6abd:4bb:28b5:f5ff:fdf0\r\n Li" \
|
28
|
+
"nk-local IPv6 Address . . . . . : fe80::4bb:28b5:f5ff:fdf0%14\r\n Default Gateway . . . ." \
|
29
|
+
" . . . . . : ::\r\n"
|
30
|
+
end
|
31
|
+
subject { described_class.new }
|
32
|
+
context 'valid UTF-8 raw output' do
|
33
|
+
it 'decodes' do
|
34
|
+
expect(subject.decode(raw_output_with_bom)).to eq(expected)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/spec/config-example.yml
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
# Copy this file to config.yml and edit the settings below.
|
2
|
-
# This should work out of the box for vagrant provisioned boxes.
|
3
|
-
|
4
|
-
## Kerberos
|
5
|
-
#auth_type: kerberos
|
6
|
-
#endpoint: "http://<yourserver>:5985/wsman"
|
7
|
-
#options:
|
8
|
-
# realm: "your.realm"
|
9
|
-
|
10
|
-
## Plain Text
|
11
|
-
auth_type: plaintext
|
12
|
-
# If you are running this in a vagrant provisioned box using NAT,
|
13
|
-
# this will be the forwarded WinRM HTTP port to your VM.
|
14
|
-
# If you are running this on the VM, the default HTTP port is 5985.
|
15
|
-
# See README.md#Troubleshooting.
|
16
|
-
endpoint: "http://localhost:55985/wsman"
|
17
|
-
options:
|
18
|
-
user: vagrant
|
19
|
-
pass: vagrant
|
1
|
+
# Copy this file to config.yml and edit the settings below.
|
2
|
+
# This should work out of the box for vagrant provisioned boxes.
|
3
|
+
|
4
|
+
## Kerberos
|
5
|
+
#auth_type: kerberos
|
6
|
+
#endpoint: "http://<yourserver>:5985/wsman"
|
7
|
+
#options:
|
8
|
+
# realm: "your.realm"
|
9
|
+
|
10
|
+
## Plain Text
|
11
|
+
auth_type: plaintext
|
12
|
+
# If you are running this in a vagrant provisioned box using NAT,
|
13
|
+
# this will be the forwarded WinRM HTTP port to your VM.
|
14
|
+
# If you are running this on the VM, the default HTTP port is 5985.
|
15
|
+
# See README.md#Troubleshooting.
|
16
|
+
endpoint: "http://localhost:55985/wsman"
|
17
|
+
options:
|
18
|
+
user: vagrant
|
19
|
+
pass: vagrant
|
data/spec/exception_spec.rb
CHANGED
@@ -1,50 +1,50 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
describe 'Exceptions', unit: true do
|
3
|
-
describe WinRM::WinRMAuthorizationError do
|
4
|
-
let(:error) { WinRM::WinRMHTTPTransportError.new('Foo happened', 500) }
|
5
|
-
|
6
|
-
it 'adds the response code to the message' do
|
7
|
-
expect(error.message).to eq('Foo happened (500).')
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'exposes the response code as an attribute' do
|
11
|
-
expect(error.status_code).to eq 500
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'is a winrm error' do
|
15
|
-
expect(error).to be_kind_of(WinRM::WinRMError)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe WinRM::WinRMWSManFault do
|
20
|
-
let(:error) { WinRM::WinRMWSManFault.new('fault text', 42) }
|
21
|
-
|
22
|
-
it 'exposes the fault text as an attribute' do
|
23
|
-
expect(error.fault_description).to eq('fault text')
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'exposes the fault code as an attribute' do
|
27
|
-
expect(error.fault_code).to eq 42
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'is a winrm error' do
|
31
|
-
expect(error).to be_kind_of(WinRM::WinRMError)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe WinRM::WinRMWMIError do
|
36
|
-
let(:error) { WinRM::WinRMWMIError.new('message text', 77_777) }
|
37
|
-
|
38
|
-
it 'exposes the error text as an attribute' do
|
39
|
-
expect(error.error).to eq('message text')
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'exposes the error code as an attribute' do
|
43
|
-
expect(error.error_code).to eq 77_777
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'is a winrm error' do
|
47
|
-
expect(error).to be_kind_of(WinRM::WinRMError)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
describe 'Exceptions', unit: true do
|
3
|
+
describe WinRM::WinRMAuthorizationError do
|
4
|
+
let(:error) { WinRM::WinRMHTTPTransportError.new('Foo happened', 500) }
|
5
|
+
|
6
|
+
it 'adds the response code to the message' do
|
7
|
+
expect(error.message).to eq('Foo happened (500).')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'exposes the response code as an attribute' do
|
11
|
+
expect(error.status_code).to eq 500
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'is a winrm error' do
|
15
|
+
expect(error).to be_kind_of(WinRM::WinRMError)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe WinRM::WinRMWSManFault do
|
20
|
+
let(:error) { WinRM::WinRMWSManFault.new('fault text', 42) }
|
21
|
+
|
22
|
+
it 'exposes the fault text as an attribute' do
|
23
|
+
expect(error.fault_description).to eq('fault text')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'exposes the fault code as an attribute' do
|
27
|
+
expect(error.fault_code).to eq 42
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'is a winrm error' do
|
31
|
+
expect(error).to be_kind_of(WinRM::WinRMError)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe WinRM::WinRMWMIError do
|
36
|
+
let(:error) { WinRM::WinRMWMIError.new('message text', 77_777) }
|
37
|
+
|
38
|
+
it 'exposes the error text as an attribute' do
|
39
|
+
expect(error.error).to eq('message text')
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'exposes the error code as an attribute' do
|
43
|
+
expect(error.error_code).to eq 77_777
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'is a winrm error' do
|
47
|
+
expect(error).to be_kind_of(WinRM::WinRMError)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|