winrm 2.0.3 → 2.1.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/.rubocop.yml +26 -26
- data/.travis.yml +11 -11
- data/Gemfile +3 -3
- data/README.md +260 -233
- data/Rakefile +34 -34
- data/Vagrantfile +6 -6
- data/WinrmAppveyor.psm1 +31 -31
- data/appveyor.yml +51 -51
- data/changelog.md +104 -101
- data/lib/winrm.rb +39 -39
- data/lib/winrm/connection.rb +83 -82
- data/lib/winrm/connection_opts.rb +91 -91
- data/lib/winrm/exceptions.rb +76 -76
- data/lib/winrm/http/response_handler.rb +96 -96
- data/lib/winrm/http/transport.rb +424 -424
- data/lib/winrm/http/transport_factory.rb +68 -68
- data/lib/winrm/output.rb +59 -59
- data/lib/winrm/psrp/create_pipeline.xml.erb +167 -167
- data/lib/winrm/psrp/fragment.rb +70 -70
- data/lib/winrm/psrp/init_runspace_pool.xml.erb +224 -224
- data/lib/winrm/psrp/message.rb +130 -130
- data/lib/winrm/psrp/message_data.rb +42 -42
- data/lib/winrm/psrp/message_data/base.rb +49 -49
- data/lib/winrm/psrp/message_data/error_record.rb +68 -68
- data/lib/winrm/psrp/message_data/pipeline_host_call.rb +32 -32
- data/lib/winrm/psrp/message_data/pipeline_output.rb +49 -49
- data/lib/winrm/psrp/message_data/pipeline_state.rb +40 -40
- data/lib/winrm/psrp/message_data/runspacepool_host_call.rb +32 -32
- data/lib/winrm/psrp/message_data/runspacepool_state.rb +39 -39
- data/lib/winrm/psrp/message_data/session_capability.rb +36 -36
- data/lib/winrm/psrp/message_defragmenter.rb +62 -62
- data/lib/winrm/psrp/message_factory.rb +75 -75
- data/lib/winrm/psrp/message_fragmenter.rb +60 -60
- data/lib/winrm/psrp/powershell_output_decoder.rb +139 -139
- data/lib/winrm/psrp/receive_response_reader.rb +97 -97
- data/lib/winrm/psrp/session_capability.xml.erb +7 -7
- data/lib/winrm/psrp/uuid.rb +40 -40
- data/lib/winrm/shells/base.rb +180 -175
- data/lib/winrm/shells/cmd.rb +65 -65
- data/lib/winrm/shells/power_shell.rb +202 -202
- data/lib/winrm/shells/retryable.rb +45 -45
- data/lib/winrm/shells/shell_factory.rb +58 -50
- data/lib/winrm/version.rb +7 -7
- data/lib/winrm/wsmv/base.rb +59 -59
- data/lib/winrm/wsmv/cleanup_command.rb +61 -61
- data/lib/winrm/wsmv/close_shell.rb +50 -50
- data/lib/winrm/wsmv/command.rb +101 -101
- data/lib/winrm/wsmv/command_output.rb +76 -76
- data/lib/winrm/wsmv/command_output_decoder.rb +55 -55
- data/lib/winrm/wsmv/configuration.rb +46 -46
- data/lib/winrm/wsmv/create_pipeline.rb +66 -66
- data/lib/winrm/wsmv/create_shell.rb +119 -119
- data/lib/winrm/wsmv/header.rb +203 -203
- data/lib/winrm/wsmv/init_runspace_pool.rb +95 -95
- data/lib/winrm/wsmv/iso8601_duration.rb +60 -60
- data/lib/winrm/wsmv/keep_alive.rb +68 -68
- data/lib/winrm/wsmv/receive_response_reader.rb +126 -126
- data/lib/winrm/wsmv/send_data.rb +68 -68
- data/lib/winrm/wsmv/soap.rb +51 -51
- data/lib/winrm/wsmv/wql_query.rb +79 -79
- data/lib/winrm/wsmv/write_stdin.rb +88 -88
- data/tests/integration/auth_timeout_spec.rb +18 -18
- data/tests/integration/cmd_spec.rb +131 -110
- data/tests/integration/config-example.yml +16 -16
- data/tests/integration/issue_59_spec.rb +26 -26
- data/tests/integration/powershell_spec.rb +165 -165
- data/tests/integration/spec_helper.rb +65 -65
- data/tests/integration/transport_spec.rb +99 -99
- data/tests/integration/wql_spec.rb +16 -16
- data/tests/matchers.rb +60 -60
- data/tests/spec/configuration_spec.rb +184 -184
- data/tests/spec/connection_spec.rb +39 -39
- data/tests/spec/exception_spec.rb +50 -50
- data/tests/spec/http/transport_factory_spec.rb +68 -68
- data/tests/spec/http/transport_spec.rb +44 -44
- data/tests/spec/output_spec.rb +127 -127
- data/tests/spec/psrp/fragment_spec.rb +62 -62
- data/tests/spec/psrp/message_data/base_spec.rb +13 -13
- data/tests/spec/psrp/message_data/error_record_spec.rb +41 -41
- data/tests/spec/psrp/message_data/pipeline_host_call_spec.rb +25 -25
- data/tests/spec/psrp/message_data/pipeline_output_spec.rb +32 -32
- data/tests/spec/psrp/message_data/pipeline_state_spec.rb +40 -40
- data/tests/spec/psrp/message_data/runspace_pool_host_call_spec.rb +25 -25
- data/tests/spec/psrp/message_data/runspacepool_state_spec.rb +16 -16
- data/tests/spec/psrp/message_data/session_capability_spec.rb +30 -30
- data/tests/spec/psrp/message_data_spec.rb +35 -35
- data/tests/spec/psrp/message_defragmenter_spec.rb +47 -47
- data/tests/spec/psrp/message_fragmenter_spec.rb +105 -105
- data/tests/spec/psrp/powershell_output_decoder_spec.rb +100 -100
- data/tests/spec/psrp/psrp_message_spec.rb +70 -70
- data/tests/spec/psrp/recieve_response_reader_spec.rb +172 -172
- data/tests/spec/psrp/uuid_spec.rb +28 -28
- data/tests/spec/response_handler_spec.rb +61 -61
- data/tests/spec/shells/base_spec.rb +202 -202
- data/tests/spec/shells/cmd_spec.rb +75 -75
- data/tests/spec/shells/powershell_spec.rb +175 -175
- data/tests/spec/spec_helper.rb +47 -47
- data/tests/spec/stubs/clixml/error_record.xml.erb +84 -84
- data/tests/spec/stubs/clixml/pipeline_state.xml.erb +88 -88
- data/tests/spec/stubs/responses/get_command_output_response.xml.erb +13 -13
- data/tests/spec/stubs/responses/get_command_output_response_not_done.xml.erb +10 -10
- data/tests/spec/stubs/responses/get_powershell_keepalive_response.xml.erb +10 -10
- data/tests/spec/stubs/responses/get_powershell_output_response.xml.erb +12 -12
- data/tests/spec/stubs/responses/get_powershell_output_response_not_done.xml.erb +9 -9
- data/tests/spec/stubs/responses/open_shell_v1.xml +19 -19
- data/tests/spec/stubs/responses/open_shell_v2.xml +20 -20
- data/tests/spec/stubs/responses/soap_fault_v1.xml +36 -36
- data/tests/spec/stubs/responses/soap_fault_v2.xml +42 -42
- data/tests/spec/stubs/responses/wmi_error_v2.xml +41 -41
- data/tests/spec/wsmv/cleanup_command_spec.rb +22 -22
- data/tests/spec/wsmv/close_shell_spec.rb +17 -17
- data/tests/spec/wsmv/command_output_decoder_spec.rb +37 -37
- data/tests/spec/wsmv/command_output_spec.rb +45 -45
- data/tests/spec/wsmv/command_spec.rb +19 -19
- data/tests/spec/wsmv/configuration_spec.rb +17 -17
- data/tests/spec/wsmv/create_pipeline_spec.rb +31 -31
- data/tests/spec/wsmv/create_shell_spec.rb +38 -38
- data/tests/spec/wsmv/init_runspace_pool_spec.rb +36 -36
- data/tests/spec/wsmv/keep_alive_spec.rb +21 -21
- data/tests/spec/wsmv/receive_response_reader_spec.rb +123 -123
- data/tests/spec/wsmv/send_data_spec.rb +30 -30
- data/tests/spec/wsmv/wql_query_spec.rb +13 -13
- data/tests/spec/wsmv/write_stdin_spec.rb +22 -22
- data/winrm.gemspec +42 -42
- metadata +2 -2
@@ -1,17 +1,17 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'winrm/wsmv/close_shell'
|
4
|
-
|
5
|
-
describe WinRM::WSMV::CloseShell do
|
6
|
-
context 'default session options' do
|
7
|
-
subject do
|
8
|
-
described_class.new(default_connection_opts, shell_id: 'F4A2622B-B842-4EB8-8A78-0225C8A993DF')
|
9
|
-
end
|
10
|
-
let(:xml) { subject.build }
|
11
|
-
it 'creates a well formed message' do
|
12
|
-
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
13
|
-
expect(xml).to include('<a:Action mustUnderstand="true">' \
|
14
|
-
'http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete</a:Action>')
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'winrm/wsmv/close_shell'
|
4
|
+
|
5
|
+
describe WinRM::WSMV::CloseShell do
|
6
|
+
context 'default session options' do
|
7
|
+
subject do
|
8
|
+
described_class.new(default_connection_opts, shell_id: 'F4A2622B-B842-4EB8-8A78-0225C8A993DF')
|
9
|
+
end
|
10
|
+
let(:xml) { subject.build }
|
11
|
+
it 'creates a well formed message' do
|
12
|
+
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
13
|
+
expect(xml).to include('<a:Action mustUnderstand="true">' \
|
14
|
+
'http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete</a:Action>')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,37 +1,37 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'winrm/wsmv/command_output_decoder'
|
4
|
-
|
5
|
-
describe WinRM::WSMV::CommandOutputDecoder 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/wsmv/command_output_decoder'
|
4
|
+
|
5
|
+
describe WinRM::WSMV::CommandOutputDecoder 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,45 +1,45 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'winrm/wsmv/command_output'
|
4
|
-
require 'winrm/wsmv/header'
|
5
|
-
|
6
|
-
describe WinRM::WSMV::CommandOutput do
|
7
|
-
context 'default session options' do
|
8
|
-
let(:cmd_out_opts) do
|
9
|
-
{
|
10
|
-
shell_id: 'F4A2622B-B842-4EB8-8A78-0225C8A993DF',
|
11
|
-
command_id: 'A2A2622B-B842-4EB8-8A78-0225C8A993DF'
|
12
|
-
}
|
13
|
-
end
|
14
|
-
subject { described_class.new(default_connection_opts, cmd_out_opts) }
|
15
|
-
let(:xml) { subject.build }
|
16
|
-
it 'creates a well formed message' do
|
17
|
-
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
18
|
-
expect(xml).to include('<w:Option Name="WSMAN_CMDSHELL_OPTION_KEEPALIVE">TRUE</w:Option>')
|
19
|
-
expect(xml).to include('w:ResourceURI mustUnderstand="true">' \
|
20
|
-
'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd</w:ResourceURI>')
|
21
|
-
expect(xml).to include('<rsp:DesiredStream ' \
|
22
|
-
'CommandId="A2A2622B-B842-4EB8-8A78-0225C8A993DF">stdout stderr</rsp:DesiredStream>')
|
23
|
-
end
|
24
|
-
end
|
25
|
-
context 'powershell' do
|
26
|
-
let(:cmd_out_opts) do
|
27
|
-
{
|
28
|
-
shell_id: 'F4A2622B-B842-4EB8-8A78-0225C8A993DF',
|
29
|
-
command_id: 'A2A2622B-B842-4EB8-8A78-0225C8A993DF',
|
30
|
-
shell_uri: WinRM::WSMV::Header::RESOURCE_URI_POWERSHELL,
|
31
|
-
out_streams: %w(stdout)
|
32
|
-
}
|
33
|
-
end
|
34
|
-
subject { described_class.new(default_connection_opts, cmd_out_opts) }
|
35
|
-
let(:xml) { subject.build }
|
36
|
-
it 'creates a well formed message' do
|
37
|
-
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
38
|
-
expect(xml).to include('<w:Option Name="WSMAN_CMDSHELL_OPTION_KEEPALIVE">TRUE</w:Option>')
|
39
|
-
expect(xml).to include('w:ResourceURI mustUnderstand="true">' \
|
40
|
-
'http://schemas.microsoft.com/powershell/Microsoft.PowerShell</w:ResourceURI>')
|
41
|
-
expect(xml).to include('<rsp:DesiredStream ' \
|
42
|
-
'CommandId="A2A2622B-B842-4EB8-8A78-0225C8A993DF">stdout</rsp:DesiredStream>')
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'winrm/wsmv/command_output'
|
4
|
+
require 'winrm/wsmv/header'
|
5
|
+
|
6
|
+
describe WinRM::WSMV::CommandOutput do
|
7
|
+
context 'default session options' do
|
8
|
+
let(:cmd_out_opts) do
|
9
|
+
{
|
10
|
+
shell_id: 'F4A2622B-B842-4EB8-8A78-0225C8A993DF',
|
11
|
+
command_id: 'A2A2622B-B842-4EB8-8A78-0225C8A993DF'
|
12
|
+
}
|
13
|
+
end
|
14
|
+
subject { described_class.new(default_connection_opts, cmd_out_opts) }
|
15
|
+
let(:xml) { subject.build }
|
16
|
+
it 'creates a well formed message' do
|
17
|
+
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
18
|
+
expect(xml).to include('<w:Option Name="WSMAN_CMDSHELL_OPTION_KEEPALIVE">TRUE</w:Option>')
|
19
|
+
expect(xml).to include('w:ResourceURI mustUnderstand="true">' \
|
20
|
+
'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd</w:ResourceURI>')
|
21
|
+
expect(xml).to include('<rsp:DesiredStream ' \
|
22
|
+
'CommandId="A2A2622B-B842-4EB8-8A78-0225C8A993DF">stdout stderr</rsp:DesiredStream>')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
context 'powershell' do
|
26
|
+
let(:cmd_out_opts) do
|
27
|
+
{
|
28
|
+
shell_id: 'F4A2622B-B842-4EB8-8A78-0225C8A993DF',
|
29
|
+
command_id: 'A2A2622B-B842-4EB8-8A78-0225C8A993DF',
|
30
|
+
shell_uri: WinRM::WSMV::Header::RESOURCE_URI_POWERSHELL,
|
31
|
+
out_streams: %w(stdout)
|
32
|
+
}
|
33
|
+
end
|
34
|
+
subject { described_class.new(default_connection_opts, cmd_out_opts) }
|
35
|
+
let(:xml) { subject.build }
|
36
|
+
it 'creates a well formed message' do
|
37
|
+
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
38
|
+
expect(xml).to include('<w:Option Name="WSMAN_CMDSHELL_OPTION_KEEPALIVE">TRUE</w:Option>')
|
39
|
+
expect(xml).to include('w:ResourceURI mustUnderstand="true">' \
|
40
|
+
'http://schemas.microsoft.com/powershell/Microsoft.PowerShell</w:ResourceURI>')
|
41
|
+
expect(xml).to include('<rsp:DesiredStream ' \
|
42
|
+
'CommandId="A2A2622B-B842-4EB8-8A78-0225C8A993DF">stdout</rsp:DesiredStream>')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -1,19 +1,19 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'winrm/wsmv/command'
|
4
|
-
|
5
|
-
describe WinRM::WSMV::Command do
|
6
|
-
context 'default session options' do
|
7
|
-
let(:cmd_opts) do
|
8
|
-
{
|
9
|
-
shell_id: 'D5A2622B-B842-4EB8-8A78-0225C8A993DF',
|
10
|
-
command: 'ipconfig'
|
11
|
-
}
|
12
|
-
end
|
13
|
-
subject { described_class.new(default_connection_opts, cmd_opts) }
|
14
|
-
let(:xml) { subject.build }
|
15
|
-
it 'creates a well formed message' do
|
16
|
-
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'winrm/wsmv/command'
|
4
|
+
|
5
|
+
describe WinRM::WSMV::Command do
|
6
|
+
context 'default session options' do
|
7
|
+
let(:cmd_opts) do
|
8
|
+
{
|
9
|
+
shell_id: 'D5A2622B-B842-4EB8-8A78-0225C8A993DF',
|
10
|
+
command: 'ipconfig'
|
11
|
+
}
|
12
|
+
end
|
13
|
+
subject { described_class.new(default_connection_opts, cmd_opts) }
|
14
|
+
let(:xml) { subject.build }
|
15
|
+
it 'creates a well formed message' do
|
16
|
+
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,17 +1,17 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'winrm/wsmv/configuration'
|
4
|
-
|
5
|
-
describe WinRM::WSMV::Configuration do
|
6
|
-
subject do
|
7
|
-
described_class.new(default_connection_opts)
|
8
|
-
end
|
9
|
-
let(:xml) { subject.build }
|
10
|
-
it 'creates a well formed message' do
|
11
|
-
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
12
|
-
expect(xml).to include('<a:Action mustUnderstand="true">' \
|
13
|
-
'http://schemas.xmlsoap.org/ws/2004/09/transfer/Get</a:Action>')
|
14
|
-
expect(xml).to include('w:ResourceURI mustUnderstand="true">' \
|
15
|
-
'http://schemas.microsoft.com/wbem/wsman/1/config</w:ResourceURI>')
|
16
|
-
end
|
17
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'winrm/wsmv/configuration'
|
4
|
+
|
5
|
+
describe WinRM::WSMV::Configuration do
|
6
|
+
subject do
|
7
|
+
described_class.new(default_connection_opts)
|
8
|
+
end
|
9
|
+
let(:xml) { subject.build }
|
10
|
+
it 'creates a well formed message' do
|
11
|
+
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
12
|
+
expect(xml).to include('<a:Action mustUnderstand="true">' \
|
13
|
+
'http://schemas.xmlsoap.org/ws/2004/09/transfer/Get</a:Action>')
|
14
|
+
expect(xml).to include('w:ResourceURI mustUnderstand="true">' \
|
15
|
+
'http://schemas.microsoft.com/wbem/wsman/1/config</w:ResourceURI>')
|
16
|
+
end
|
17
|
+
end
|
@@ -1,31 +1,31 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'winrm/wsmv/create_pipeline'
|
4
|
-
|
5
|
-
describe WinRM::WSMV::CreatePipeline do
|
6
|
-
context 'default session options' do
|
7
|
-
let(:shell_id) { 'D5A2622B-B842-4EB8-8A78-0225C8A993DF' }
|
8
|
-
let(:command_id) { 'D5A2622B-B842-4EB8-8A78-0225C8A993DF' }
|
9
|
-
let(:fragment) { WinRM::PSRP::Fragment.new(0, [1, 2, 3]) }
|
10
|
-
let(:pipeline) { Base64.strict_encode64(fragment.bytes.pack('C*')) }
|
11
|
-
|
12
|
-
subject do
|
13
|
-
WinRM::WSMV::CreatePipeline.new(
|
14
|
-
default_connection_opts,
|
15
|
-
shell_id,
|
16
|
-
command_id,
|
17
|
-
fragment
|
18
|
-
)
|
19
|
-
end
|
20
|
-
let(:xml) { subject.build }
|
21
|
-
it 'creates a well formed message' do
|
22
|
-
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
23
|
-
expect(xml).to include(
|
24
|
-
'<w:SelectorSet><w:Selector Name="ShellId">' \
|
25
|
-
"#{shell_id}</w:Selector></w:SelectorSet>")
|
26
|
-
expect(xml).to include("<rsp:CommandLine CommandId=\"#{command_id}\">")
|
27
|
-
expect(xml).to include('<rsp:Command>Invoke-Expression</rsp:Command>')
|
28
|
-
expect(xml).to include("<rsp:Arguments>#{pipeline}</rsp:Arguments>")
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'winrm/wsmv/create_pipeline'
|
4
|
+
|
5
|
+
describe WinRM::WSMV::CreatePipeline do
|
6
|
+
context 'default session options' do
|
7
|
+
let(:shell_id) { 'D5A2622B-B842-4EB8-8A78-0225C8A993DF' }
|
8
|
+
let(:command_id) { 'D5A2622B-B842-4EB8-8A78-0225C8A993DF' }
|
9
|
+
let(:fragment) { WinRM::PSRP::Fragment.new(0, [1, 2, 3]) }
|
10
|
+
let(:pipeline) { Base64.strict_encode64(fragment.bytes.pack('C*')) }
|
11
|
+
|
12
|
+
subject do
|
13
|
+
WinRM::WSMV::CreatePipeline.new(
|
14
|
+
default_connection_opts,
|
15
|
+
shell_id,
|
16
|
+
command_id,
|
17
|
+
fragment
|
18
|
+
)
|
19
|
+
end
|
20
|
+
let(:xml) { subject.build }
|
21
|
+
it 'creates a well formed message' do
|
22
|
+
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
23
|
+
expect(xml).to include(
|
24
|
+
'<w:SelectorSet><w:Selector Name="ShellId">' \
|
25
|
+
"#{shell_id}</w:Selector></w:SelectorSet>")
|
26
|
+
expect(xml).to include("<rsp:CommandLine CommandId=\"#{command_id}\">")
|
27
|
+
expect(xml).to include('<rsp:Command>Invoke-Expression</rsp:Command>')
|
28
|
+
expect(xml).to include("<rsp:Arguments>#{pipeline}</rsp:Arguments>")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,38 +1,38 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'winrm/wsmv/create_shell'
|
4
|
-
|
5
|
-
describe WinRM::WSMV::CreateShell do
|
6
|
-
context 'default session options' do
|
7
|
-
subject { described_class.new(default_connection_opts) }
|
8
|
-
let(:xml) { subject.build }
|
9
|
-
it 'creates a well formed message' do
|
10
|
-
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
11
|
-
expect(xml).to include('<w:Locale xml:lang="en-US" mustUnderstand="false"/>')
|
12
|
-
expect(xml).to include('<p:DataLocale xml:lang="en-US" mustUnderstand="false"/>')
|
13
|
-
expect(xml).to include(
|
14
|
-
'<p:SessionId mustUnderstand="false">' \
|
15
|
-
'uuid:05A2622B-B842-4EB8-8A78-0225C8A993DF</p:SessionId>')
|
16
|
-
expect(xml).to include('<w:MaxEnvelopeSize mustUnderstand="true">153600</w:MaxEnvelopeSize>')
|
17
|
-
expect(xml).to include('<a:To>http://localhost:5985/wsman</a:To>')
|
18
|
-
expect(xml).to include('<rsp:InputStreams>stdin</rsp:InputStreams>')
|
19
|
-
expect(xml).to include('<rsp:OutputStreams>stdout stderr</rsp:OutputStreams>')
|
20
|
-
expect(xml).to include(
|
21
|
-
'<w:ResourceURI mustUnderstand="true">' \
|
22
|
-
'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd</w:ResourceURI>')
|
23
|
-
end
|
24
|
-
context 'shell options w/env vars' do
|
25
|
-
let(:shell_opts) do
|
26
|
-
{
|
27
|
-
env_vars: { 'FOO' => 'BAR' }
|
28
|
-
}
|
29
|
-
end
|
30
|
-
subject { described_class.new(default_connection_opts, shell_opts) }
|
31
|
-
let(:xml) { subject.build }
|
32
|
-
it 'includes environemt vars' do
|
33
|
-
expect(xml).to include(
|
34
|
-
'<rsp:Environment><rsp:Variable Name="FOO">BAR</rsp:Variable></rsp:Environment>')
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'winrm/wsmv/create_shell'
|
4
|
+
|
5
|
+
describe WinRM::WSMV::CreateShell do
|
6
|
+
context 'default session options' do
|
7
|
+
subject { described_class.new(default_connection_opts) }
|
8
|
+
let(:xml) { subject.build }
|
9
|
+
it 'creates a well formed message' do
|
10
|
+
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
11
|
+
expect(xml).to include('<w:Locale xml:lang="en-US" mustUnderstand="false"/>')
|
12
|
+
expect(xml).to include('<p:DataLocale xml:lang="en-US" mustUnderstand="false"/>')
|
13
|
+
expect(xml).to include(
|
14
|
+
'<p:SessionId mustUnderstand="false">' \
|
15
|
+
'uuid:05A2622B-B842-4EB8-8A78-0225C8A993DF</p:SessionId>')
|
16
|
+
expect(xml).to include('<w:MaxEnvelopeSize mustUnderstand="true">153600</w:MaxEnvelopeSize>')
|
17
|
+
expect(xml).to include('<a:To>http://localhost:5985/wsman</a:To>')
|
18
|
+
expect(xml).to include('<rsp:InputStreams>stdin</rsp:InputStreams>')
|
19
|
+
expect(xml).to include('<rsp:OutputStreams>stdout stderr</rsp:OutputStreams>')
|
20
|
+
expect(xml).to include(
|
21
|
+
'<w:ResourceURI mustUnderstand="true">' \
|
22
|
+
'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd</w:ResourceURI>')
|
23
|
+
end
|
24
|
+
context 'shell options w/env vars' do
|
25
|
+
let(:shell_opts) do
|
26
|
+
{
|
27
|
+
env_vars: { 'FOO' => 'BAR' }
|
28
|
+
}
|
29
|
+
end
|
30
|
+
subject { described_class.new(default_connection_opts, shell_opts) }
|
31
|
+
let(:xml) { subject.build }
|
32
|
+
it 'includes environemt vars' do
|
33
|
+
expect(xml).to include(
|
34
|
+
'<rsp:Environment><rsp:Variable Name="FOO">BAR</rsp:Variable></rsp:Environment>')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,36 +1,36 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'winrm/wsmv/init_runspace_pool'
|
4
|
-
|
5
|
-
describe WinRM::WSMV::InitRunspacePool do
|
6
|
-
context 'default session options' do
|
7
|
-
let(:shell_id) { SecureRandom.uuid.to_s.upcase }
|
8
|
-
let(:payload) { 'blah'.bytes }
|
9
|
-
|
10
|
-
subject { described_class.new(default_connection_opts, shell_id, payload) }
|
11
|
-
|
12
|
-
it 'creates a well formed message' do
|
13
|
-
xml = subject.build
|
14
|
-
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
15
|
-
expect(xml).to include('<w:Locale xml:lang="en-US" mustUnderstand="false"/>')
|
16
|
-
expect(xml).to include('<p:DataLocale xml:lang="en-US" mustUnderstand="false"/>')
|
17
|
-
expect(xml).to include(
|
18
|
-
'<p:SessionId mustUnderstand="false">' \
|
19
|
-
'uuid:05A2622B-B842-4EB8-8A78-0225C8A993DF</p:SessionId>')
|
20
|
-
expect(xml).to include('<w:MaxEnvelopeSize mustUnderstand="true">153600</w:MaxEnvelopeSize>')
|
21
|
-
expect(xml).to include('<a:To>http://localhost:5985/wsman</a:To>')
|
22
|
-
expect(xml).to include(
|
23
|
-
'<w:OptionSet env:mustUnderstand="true">' \
|
24
|
-
'<w:Option Name="protocolversion" MustComply="true">2.3</w:Option></w:OptionSet>')
|
25
|
-
expect(xml).to include('<rsp:InputStreams>stdin pr</rsp:InputStreams>')
|
26
|
-
expect(xml).to include('<rsp:OutputStreams>stdout</rsp:OutputStreams>')
|
27
|
-
expect(xml).to include("<rsp:Shell ShellId=\"#{subject.shell_id}\">")
|
28
|
-
expect(xml).to include(
|
29
|
-
'<w:ResourceURI mustUnderstand="true">' \
|
30
|
-
'http://schemas.microsoft.com/powershell/Microsoft.PowerShell')
|
31
|
-
expect(xml).to include(
|
32
|
-
'<creationXml xmlns="http://schemas.microsoft.com/powershell">' \
|
33
|
-
"#{Base64.strict_encode64(payload.pack('C*'))}</creationXml>")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'winrm/wsmv/init_runspace_pool'
|
4
|
+
|
5
|
+
describe WinRM::WSMV::InitRunspacePool do
|
6
|
+
context 'default session options' do
|
7
|
+
let(:shell_id) { SecureRandom.uuid.to_s.upcase }
|
8
|
+
let(:payload) { 'blah'.bytes }
|
9
|
+
|
10
|
+
subject { described_class.new(default_connection_opts, shell_id, payload) }
|
11
|
+
|
12
|
+
it 'creates a well formed message' do
|
13
|
+
xml = subject.build
|
14
|
+
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
15
|
+
expect(xml).to include('<w:Locale xml:lang="en-US" mustUnderstand="false"/>')
|
16
|
+
expect(xml).to include('<p:DataLocale xml:lang="en-US" mustUnderstand="false"/>')
|
17
|
+
expect(xml).to include(
|
18
|
+
'<p:SessionId mustUnderstand="false">' \
|
19
|
+
'uuid:05A2622B-B842-4EB8-8A78-0225C8A993DF</p:SessionId>')
|
20
|
+
expect(xml).to include('<w:MaxEnvelopeSize mustUnderstand="true">153600</w:MaxEnvelopeSize>')
|
21
|
+
expect(xml).to include('<a:To>http://localhost:5985/wsman</a:To>')
|
22
|
+
expect(xml).to include(
|
23
|
+
'<w:OptionSet env:mustUnderstand="true">' \
|
24
|
+
'<w:Option Name="protocolversion" MustComply="true">2.3</w:Option></w:OptionSet>')
|
25
|
+
expect(xml).to include('<rsp:InputStreams>stdin pr</rsp:InputStreams>')
|
26
|
+
expect(xml).to include('<rsp:OutputStreams>stdout</rsp:OutputStreams>')
|
27
|
+
expect(xml).to include("<rsp:Shell ShellId=\"#{subject.shell_id}\">")
|
28
|
+
expect(xml).to include(
|
29
|
+
'<w:ResourceURI mustUnderstand="true">' \
|
30
|
+
'http://schemas.microsoft.com/powershell/Microsoft.PowerShell')
|
31
|
+
expect(xml).to include(
|
32
|
+
'<creationXml xmlns="http://schemas.microsoft.com/powershell">' \
|
33
|
+
"#{Base64.strict_encode64(payload.pack('C*'))}</creationXml>")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|