winrm 2.2.3 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +13 -1
- data/.travis.yml +10 -11
- data/Gemfile +2 -3
- data/README.md +1 -1
- data/Rakefile +3 -4
- data/appveyor.yml +1 -2
- data/bin/rwinrm +90 -97
- data/changelog.md +5 -0
- data/lib/winrm.rb +3 -5
- data/lib/winrm/connection.rb +84 -86
- data/lib/winrm/connection_opts.rb +90 -91
- data/lib/winrm/exceptions.rb +14 -2
- data/lib/winrm/http/response_handler.rb +127 -96
- data/lib/winrm/http/transport.rb +462 -427
- data/lib/winrm/http/transport_factory.rb +1 -5
- data/lib/winrm/output.rb +1 -2
- data/lib/winrm/psrp/fragment.rb +0 -2
- data/lib/winrm/psrp/message.rb +1 -3
- data/lib/winrm/psrp/message_data.rb +0 -2
- data/lib/winrm/psrp/message_data/base.rb +0 -2
- data/lib/winrm/psrp/message_data/error_record.rb +0 -2
- data/lib/winrm/psrp/message_data/pipeline_host_call.rb +0 -2
- data/lib/winrm/psrp/message_data/pipeline_output.rb +48 -54
- data/lib/winrm/psrp/message_data/pipeline_state.rb +0 -2
- data/lib/winrm/psrp/message_data/runspacepool_host_call.rb +0 -2
- data/lib/winrm/psrp/message_data/runspacepool_state.rb +0 -2
- data/lib/winrm/psrp/message_data/session_capability.rb +0 -2
- data/lib/winrm/psrp/message_defragmenter.rb +2 -2
- data/lib/winrm/psrp/message_factory.rb +2 -3
- data/lib/winrm/psrp/message_fragmenter.rb +1 -3
- data/lib/winrm/psrp/powershell_output_decoder.rb +0 -2
- data/lib/winrm/psrp/receive_response_reader.rb +3 -5
- data/lib/winrm/psrp/uuid.rb +1 -2
- data/lib/winrm/shells/base.rb +6 -4
- data/lib/winrm/shells/cmd.rb +63 -65
- data/lib/winrm/shells/power_shell.rb +207 -202
- data/lib/winrm/shells/retryable.rb +44 -45
- data/lib/winrm/shells/shell_factory.rb +0 -2
- data/lib/winrm/version.rb +1 -3
- data/lib/winrm/wsmv/base.rb +0 -2
- data/lib/winrm/wsmv/cleanup_command.rb +1 -2
- data/lib/winrm/wsmv/close_shell.rb +1 -2
- data/lib/winrm/wsmv/command.rb +2 -3
- data/lib/winrm/wsmv/command_output.rb +2 -3
- data/lib/winrm/wsmv/command_output_decoder.rb +1 -2
- data/lib/winrm/wsmv/configuration.rb +0 -2
- data/lib/winrm/wsmv/create_pipeline.rb +0 -2
- data/lib/winrm/wsmv/create_shell.rb +2 -6
- data/lib/winrm/wsmv/header.rb +213 -215
- data/lib/winrm/wsmv/init_runspace_pool.rb +96 -95
- data/lib/winrm/wsmv/iso8601_duration.rb +0 -2
- data/lib/winrm/wsmv/keep_alive.rb +0 -2
- data/lib/winrm/wsmv/receive_response_reader.rb +128 -126
- data/lib/winrm/wsmv/send_data.rb +0 -2
- data/lib/winrm/wsmv/soap.rb +0 -2
- data/lib/winrm/wsmv/wql_pull.rb +54 -56
- data/lib/winrm/wsmv/wql_query.rb +98 -99
- data/lib/winrm/wsmv/write_stdin.rb +0 -2
- data/tests/integration/auth_timeout_spec.rb +0 -1
- data/tests/integration/cmd_spec.rb +2 -3
- data/tests/integration/issue_59_spec.rb +0 -1
- data/tests/integration/powershell_spec.rb +4 -5
- data/tests/integration/spec_helper.rb +3 -6
- data/tests/integration/transport_spec.rb +0 -1
- data/tests/integration/wql_spec.rb +33 -34
- data/tests/matchers.rb +2 -3
- data/tests/spec/configuration_spec.rb +0 -1
- data/tests/spec/connection_spec.rb +0 -2
- data/tests/spec/exception_spec.rb +0 -1
- data/tests/spec/http/transport_factory_spec.rb +1 -3
- data/tests/spec/http/transport_spec.rb +0 -1
- data/tests/spec/output_spec.rb +4 -3
- data/tests/spec/psrp/fragment_spec.rb +0 -2
- data/tests/spec/psrp/message_data/base_spec.rb +0 -2
- data/tests/spec/psrp/message_data/error_record_spec.rb +0 -2
- data/tests/spec/psrp/message_data/pipeline_host_call_spec.rb +0 -2
- data/tests/spec/psrp/message_data/pipeline_output_spec.rb +0 -2
- data/tests/spec/psrp/message_data/pipeline_state_spec.rb +0 -2
- data/tests/spec/psrp/message_data/runspace_pool_host_call_spec.rb +0 -2
- data/tests/spec/psrp/message_data/runspacepool_state_spec.rb +0 -2
- data/tests/spec/psrp/message_data/session_capability_spec.rb +0 -2
- data/tests/spec/psrp/message_data_spec.rb +0 -2
- data/tests/spec/psrp/message_defragmenter_spec.rb +0 -2
- data/tests/spec/psrp/message_fragmenter_spec.rb +0 -2
- data/tests/spec/psrp/powershell_output_decoder_spec.rb +0 -2
- data/tests/spec/psrp/psrp_message_spec.rb +10 -7
- data/tests/spec/psrp/recieve_response_reader_spec.rb +0 -2
- data/tests/spec/psrp/uuid_spec.rb +2 -2
- data/tests/spec/response_handler_spec.rb +69 -61
- data/tests/spec/shells/base_spec.rb +7 -5
- data/tests/spec/shells/cmd_spec.rb +4 -4
- data/tests/spec/shells/powershell_spec.rb +221 -175
- data/tests/spec/spec_helper.rb +0 -1
- data/tests/spec/stubs/responses/get_omi_command_output_response.xml.erb +23 -0
- data/tests/spec/stubs/responses/get_omi_command_output_response_not_done.xml.erb +24 -0
- data/tests/spec/stubs/responses/get_omi_config_response.xml +45 -0
- data/tests/spec/stubs/responses/get_omi_powershell_keepalive_response.xml.erb +33 -0
- data/tests/spec/stubs/responses/open_shell_omi.xml +43 -0
- data/tests/spec/stubs/responses/soap_fault_omi.xml +31 -0
- data/tests/spec/wsmv/cleanup_command_spec.rb +0 -2
- data/tests/spec/wsmv/close_shell_spec.rb +0 -2
- data/tests/spec/wsmv/command_output_decoder_spec.rb +0 -2
- data/tests/spec/wsmv/command_output_spec.rb +1 -3
- data/tests/spec/wsmv/command_spec.rb +0 -2
- data/tests/spec/wsmv/configuration_spec.rb +0 -2
- data/tests/spec/wsmv/create_pipeline_spec.rb +2 -3
- data/tests/spec/wsmv/create_shell_spec.rb +6 -5
- data/tests/spec/wsmv/init_runspace_pool_spec.rb +38 -36
- data/tests/spec/wsmv/keep_alive_spec.rb +4 -4
- data/tests/spec/wsmv/receive_response_reader_spec.rb +124 -123
- data/tests/spec/wsmv/send_data_spec.rb +4 -4
- data/tests/spec/wsmv/wql_query_spec.rb +11 -13
- data/tests/spec/wsmv/write_stdin_spec.rb +0 -2
- data/winrm.gemspec +11 -12
- metadata +73 -67
@@ -0,0 +1,45 @@
|
|
1
|
+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
|
2
|
+
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
|
3
|
+
xmlns:wsen="http://schemas.xmlsoap.org/ws/2004/09/enumeration"
|
4
|
+
xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing"
|
5
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
6
|
+
xmlns:wsmb="http://schemas.dmtf.org/wbem/wsman/1/cimbinding.xsd"
|
7
|
+
xmlns:wsman="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"
|
8
|
+
xmlns:wxf="http://schemas.xmlsoap.org/ws/2004/09/transfer"
|
9
|
+
xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common"
|
10
|
+
xmlns:msftwinrm="http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd"
|
11
|
+
xmlns:wsmid="http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd">
|
12
|
+
<SOAP-ENV:Header>
|
13
|
+
<wsa:To>
|
14
|
+
http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
|
15
|
+
</wsa:To>
|
16
|
+
<wsa:Action>
|
17
|
+
http://schemas.dmtf.org/wbem/wsman/1/wsman/fault
|
18
|
+
</wsa:Action>
|
19
|
+
<wsa:MessageID>
|
20
|
+
uuid:5825BEA8-76AB-0005-0000-000001A80000
|
21
|
+
</wsa:MessageID>
|
22
|
+
<wsa:RelatesTo>
|
23
|
+
uuid:01022086-C0D6-45DA-85F2-21FA2B476FCA
|
24
|
+
</wsa:RelatesTo>
|
25
|
+
</SOAP-ENV:Header>
|
26
|
+
<SOAP-ENV:Body>
|
27
|
+
<SOAP-ENV:Fault>
|
28
|
+
<SOAP-ENV:Code>
|
29
|
+
<SOAP-ENV:Value>
|
30
|
+
SOAP-ENV:Receiver
|
31
|
+
</SOAP-ENV:Value>
|
32
|
+
<SOAP-ENV:Subcode>
|
33
|
+
<SOAP-ENV:Value>
|
34
|
+
wsman:InternalError
|
35
|
+
</SOAP-ENV:Value>
|
36
|
+
</SOAP-ENV:Subcode>
|
37
|
+
</SOAP-ENV:Code>
|
38
|
+
<SOAP-ENV:Reason>
|
39
|
+
<SOAP-ENV:Text xml:lang="en-US">
|
40
|
+
get-instance: instance name parameter is missing
|
41
|
+
</SOAP-ENV:Text>
|
42
|
+
</SOAP-ENV:Reason>
|
43
|
+
</SOAP-ENV:Fault>
|
44
|
+
</SOAP-ENV:Body>
|
45
|
+
</SOAP-ENV:Envelope>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
|
2
|
+
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
|
3
|
+
xmlns:wsen="http://schemas.xmlsoap.org/ws/2004/09/enumeration"
|
4
|
+
xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing"
|
5
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
6
|
+
xmlns:wsmb="http://schemas.dmtf.org/wbem/wsman/1/cimbinding.xsd"
|
7
|
+
xmlns:wsman="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"
|
8
|
+
xmlns:wxf="http://schemas.xmlsoap.org/ws/2004/09/transfer"
|
9
|
+
xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common"
|
10
|
+
xmlns:msftwinrm="http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd"
|
11
|
+
xmlns:wsmid="http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd">
|
12
|
+
<SOAP-ENV:Header>
|
13
|
+
<wsa:To>
|
14
|
+
http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
|
15
|
+
</wsa:To>
|
16
|
+
<wsa:Action>
|
17
|
+
http://schemas.microsoft.com/wbem/wsman/1/windows/shell/ReceiveResponse
|
18
|
+
</wsa:Action>
|
19
|
+
<wsa:MessageID>
|
20
|
+
uuid:5825BEA8-76AB-0005-0000-000000510000
|
21
|
+
</wsa:MessageID>
|
22
|
+
<wsa:RelatesTo>
|
23
|
+
uuid:28C42606-83D7-4948-A06A-47B75E7575D3
|
24
|
+
</wsa:RelatesTo>
|
25
|
+
</SOAP-ENV:Header>
|
26
|
+
<SOAP-ENV:Body>
|
27
|
+
<p:ReceiveResponse xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/windows/shell">
|
28
|
+
<p:Stream Name="stdout"><%= test_data_stdout2 %></p:Stream>
|
29
|
+
<p:CommandState State="http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Running">
|
30
|
+
</p:CommandState>
|
31
|
+
</p:ReceiveResponse>
|
32
|
+
</SOAP-ENV:Body>
|
33
|
+
</SOAP-ENV:Envelope>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
|
2
|
+
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
|
3
|
+
xmlns:wsen="http://schemas.xmlsoap.org/ws/2004/09/enumeration"
|
4
|
+
xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing"
|
5
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
6
|
+
xmlns:wsmb="http://schemas.dmtf.org/wbem/wsman/1/cimbinding.xsd"
|
7
|
+
xmlns:wsman="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"
|
8
|
+
xmlns:wxf="http://schemas.xmlsoap.org/ws/2004/09/transfer"
|
9
|
+
xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common"
|
10
|
+
xmlns:msftwinrm="http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd"
|
11
|
+
xmlns:wsmid="http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd">
|
12
|
+
<SOAP-ENV:Header>
|
13
|
+
<wsa:To>
|
14
|
+
http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
|
15
|
+
</wsa:To>
|
16
|
+
<wsa:Action>
|
17
|
+
http://schemas.xmlsoap.org/ws/2004/09/transfer/CreateResponse
|
18
|
+
</wsa:Action>
|
19
|
+
<wsa:MessageID>
|
20
|
+
uuid:5825BEA8-76AB-0005-0000-000001A90000
|
21
|
+
</wsa:MessageID>
|
22
|
+
<wsa:RelatesTo>
|
23
|
+
uuid:C872AD16-50F1-4CD3-908B-35AED7E485B7
|
24
|
+
</wsa:RelatesTo>
|
25
|
+
</SOAP-ENV:Header>
|
26
|
+
<SOAP-ENV:Body>
|
27
|
+
<wxf:ResourceCreated>
|
28
|
+
<wsa:Address>
|
29
|
+
http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
|
30
|
+
</wsa:Address>
|
31
|
+
<wsa:ReferenceParameters>
|
32
|
+
<wsman:ResourceURI>
|
33
|
+
http://schemas.microsoft.com/powershell/Microsoft.PowerShell
|
34
|
+
</wsman:ResourceURI>
|
35
|
+
<wsman:SelectorSet>
|
36
|
+
<wsman:Selector Name="ShellId">
|
37
|
+
74142DC5-E14D-4FCC-86ED-63DA3EE8407E
|
38
|
+
</wsman:Selector>
|
39
|
+
</wsman:SelectorSet>
|
40
|
+
</wsa:ReferenceParameters>
|
41
|
+
</wxf:ResourceCreated>
|
42
|
+
</SOAP-ENV:Body>
|
43
|
+
</SOAP-ENV:Envelope>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
|
2
|
+
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
|
3
|
+
xmlns:wsen="http://schemas.xmlsoap.org/ws/2004/09/enumeration"
|
4
|
+
xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing"
|
5
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
6
|
+
xmlns:wsmb="http://schemas.dmtf.org/wbem/wsman/1/cimbinding.xsd"
|
7
|
+
xmlns:wsman="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"
|
8
|
+
xmlns:wxf="http://schemas.xmlsoap.org/ws/2004/09/transfer"
|
9
|
+
xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common"
|
10
|
+
xmlns:msftwinrm="http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd"
|
11
|
+
xmlns:wsmid="http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd">
|
12
|
+
<SOAP-ENV:Header>
|
13
|
+
<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
|
14
|
+
<wsa:Action>http://schemas.dmtf.org/wbem/wsman/1/wsman/fault</wsa:Action>
|
15
|
+
<wsa:MessageID>uuid:F803101F-76B9-0005-0000-000000010000</wsa:MessageID>
|
16
|
+
<wsa:RelatesTo>uuid:AC61AF91-4AA9-428E-9294-670B4C5752A8</wsa:RelatesTo>
|
17
|
+
</SOAP-ENV:Header>
|
18
|
+
<SOAP-ENV:Body>
|
19
|
+
<SOAP-ENV:Fault>
|
20
|
+
<SOAP-ENV:Code>
|
21
|
+
<SOAP-ENV:Value>SOAP-ENV:Receiver</SOAP-ENV:Value>
|
22
|
+
<SOAP-ENV:Subcode>
|
23
|
+
<SOAP-ENV:Value>wsman:InternalError</SOAP-ENV:Value>
|
24
|
+
</SOAP-ENV:Subcode>
|
25
|
+
</SOAP-ENV:Code>
|
26
|
+
<SOAP-ENV:Reason>
|
27
|
+
<SOAP-ENV:Text xml:lang="en-US">get-instance: instance name parameter is missing</SOAP-ENV:Text>
|
28
|
+
</SOAP-ENV:Reason>
|
29
|
+
</SOAP-ENV:Fault>
|
30
|
+
</SOAP-ENV:Body>
|
31
|
+
</SOAP-ENV:Envelope>
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
require 'winrm/wsmv/command_output'
|
4
2
|
require 'winrm/wsmv/header'
|
5
3
|
|
@@ -28,7 +26,7 @@ describe WinRM::WSMV::CommandOutput do
|
|
28
26
|
shell_id: 'F4A2622B-B842-4EB8-8A78-0225C8A993DF',
|
29
27
|
command_id: 'A2A2622B-B842-4EB8-8A78-0225C8A993DF',
|
30
28
|
shell_uri: WinRM::WSMV::Header::RESOURCE_URI_POWERSHELL,
|
31
|
-
out_streams: %w
|
29
|
+
out_streams: %w[stdout]
|
32
30
|
}
|
33
31
|
end
|
34
32
|
subject { described_class.new(default_connection_opts, cmd_out_opts) }
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
require 'winrm/wsmv/create_pipeline'
|
4
2
|
|
5
3
|
describe WinRM::WSMV::CreatePipeline do
|
@@ -22,7 +20,8 @@ describe WinRM::WSMV::CreatePipeline do
|
|
22
20
|
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
23
21
|
expect(xml).to include(
|
24
22
|
'<w:SelectorSet><w:Selector Name="ShellId">' \
|
25
|
-
"#{shell_id}</w:Selector></w:SelectorSet>"
|
23
|
+
"#{shell_id}</w:Selector></w:SelectorSet>"
|
24
|
+
)
|
26
25
|
expect(xml).to include("<rsp:CommandLine CommandId=\"#{command_id}\">")
|
27
26
|
expect(xml).to include('<rsp:Command>Invoke-Expression</rsp:Command>')
|
28
27
|
expect(xml).to include("<rsp:Arguments>#{pipeline}</rsp:Arguments>")
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
require 'winrm/wsmv/create_shell'
|
4
2
|
|
5
3
|
describe WinRM::WSMV::CreateShell do
|
@@ -12,14 +10,16 @@ describe WinRM::WSMV::CreateShell do
|
|
12
10
|
expect(xml).to include('<p:DataLocale xml:lang="en-US" mustUnderstand="false"/>')
|
13
11
|
expect(xml).to include(
|
14
12
|
'<p:SessionId mustUnderstand="false">' \
|
15
|
-
'uuid:05A2622B-B842-4EB8-8A78-0225C8A993DF</p:SessionId>'
|
13
|
+
'uuid:05A2622B-B842-4EB8-8A78-0225C8A993DF</p:SessionId>'
|
14
|
+
)
|
16
15
|
expect(xml).to include('<w:MaxEnvelopeSize mustUnderstand="true">153600</w:MaxEnvelopeSize>')
|
17
16
|
expect(xml).to include('<a:To>http://localhost:5985/wsman</a:To>')
|
18
17
|
expect(xml).to include('<rsp:InputStreams>stdin</rsp:InputStreams>')
|
19
18
|
expect(xml).to include('<rsp:OutputStreams>stdout stderr</rsp:OutputStreams>')
|
20
19
|
expect(xml).to include(
|
21
20
|
'<w:ResourceURI mustUnderstand="true">' \
|
22
|
-
'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd</w:ResourceURI>'
|
21
|
+
'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd</w:ResourceURI>'
|
22
|
+
)
|
23
23
|
end
|
24
24
|
context 'shell options w/env vars' do
|
25
25
|
let(:shell_opts) do
|
@@ -31,7 +31,8 @@ describe WinRM::WSMV::CreateShell do
|
|
31
31
|
let(:xml) { subject.build }
|
32
32
|
it 'includes environemt vars' do
|
33
33
|
expect(xml).to include(
|
34
|
-
'<rsp:Environment><rsp:Variable Name="FOO">BAR</rsp:Variable></rsp:Environment>'
|
34
|
+
'<rsp:Environment><rsp:Variable Name="FOO">BAR</rsp:Variable></rsp:Environment>'
|
35
|
+
)
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|
@@ -1,36 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
xml =
|
14
|
-
expect(xml).to include('<
|
15
|
-
expect(xml).to include(
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
expect(xml).to include('<
|
21
|
-
expect(xml).to include(
|
22
|
-
|
23
|
-
'<w:
|
24
|
-
|
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
|
-
|
32
|
-
|
33
|
-
"
|
34
|
-
|
35
|
-
|
36
|
-
end
|
1
|
+
require 'winrm/wsmv/init_runspace_pool'
|
2
|
+
|
3
|
+
describe WinRM::WSMV::InitRunspacePool do
|
4
|
+
context 'default session options' do
|
5
|
+
let(:shell_id) { SecureRandom.uuid.to_s.upcase }
|
6
|
+
let(:payload) { 'blah'.bytes }
|
7
|
+
|
8
|
+
subject { described_class.new(default_connection_opts, shell_id, payload) }
|
9
|
+
|
10
|
+
it 'creates a well formed message' do
|
11
|
+
xml = subject.build
|
12
|
+
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
13
|
+
expect(xml).to include('<w:Locale xml:lang="en-US" mustUnderstand="false"/>')
|
14
|
+
expect(xml).to include('<p:DataLocale xml:lang="en-US" mustUnderstand="false"/>')
|
15
|
+
expect(xml).to include(
|
16
|
+
'<p:SessionId mustUnderstand="false">' \
|
17
|
+
'uuid:05A2622B-B842-4EB8-8A78-0225C8A993DF</p:SessionId>'
|
18
|
+
)
|
19
|
+
expect(xml).to include('<w:MaxEnvelopeSize mustUnderstand="true">153600</w:MaxEnvelopeSize>')
|
20
|
+
expect(xml).to include('<a:To>http://localhost:5985/wsman</a:To>')
|
21
|
+
expect(xml).to include(
|
22
|
+
'<w:OptionSet env:mustUnderstand="true">' \
|
23
|
+
'<w:Option Name="protocolversion" MustComply="true">2.3</w:Option></w:OptionSet>'
|
24
|
+
)
|
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}\" Name=\"Runspace\">")
|
28
|
+
expect(xml).to include(
|
29
|
+
'<w:ResourceURI mustUnderstand="true">' \
|
30
|
+
'http://schemas.microsoft.com/powershell/Microsoft.PowerShell'
|
31
|
+
)
|
32
|
+
expect(xml).to include(
|
33
|
+
'<creationXml xmlns="http://schemas.microsoft.com/powershell">' \
|
34
|
+
"#{Base64.strict_encode64(payload.pack('C*'))}</creationXml>"
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
require 'winrm/wsmv/keep_alive'
|
4
2
|
|
5
3
|
describe WinRM::WSMV::KeepAlive do
|
@@ -11,10 +9,12 @@ describe WinRM::WSMV::KeepAlive do
|
|
11
9
|
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
12
10
|
expect(xml).to include(
|
13
11
|
'<w:OptionSet><w:Option Name="WSMAN_CMDSHELL_OPTION_KEEPALIVE">' \
|
14
|
-
'TRUE</w:Option></w:OptionSet>'
|
12
|
+
'TRUE</w:Option></w:OptionSet>'
|
13
|
+
)
|
15
14
|
expect(xml).to include(
|
16
15
|
'<w:SelectorSet><w:Selector Name="ShellId">' \
|
17
|
-
"#{shell_id}</w:Selector></w:SelectorSet>"
|
16
|
+
"#{shell_id}</w:Selector></w:SelectorSet>"
|
17
|
+
)
|
18
18
|
expect(xml).to include('<rsp:DesiredStream>stdout</rsp:DesiredStream>')
|
19
19
|
end
|
20
20
|
end
|
@@ -1,123 +1,124 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
let(:
|
7
|
-
let(:
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
end
|
1
|
+
require 'winrm/wsmv/receive_response_reader'
|
2
|
+
|
3
|
+
describe WinRM::WSMV::ReceiveResponseReader do
|
4
|
+
let(:shell_id) { 'F4A2622B-B842-4EB8-8A78-0225C8A993DF' }
|
5
|
+
let(:command_id) { 'A2A2622B-B842-4EB8-8A78-0225C8A993DF' }
|
6
|
+
let(:output_message) { double('output_message', build: 'output_message') }
|
7
|
+
let(:transport) do
|
8
|
+
{}
|
9
|
+
end
|
10
|
+
|
11
|
+
subject do
|
12
|
+
described_class.new(
|
13
|
+
transport,
|
14
|
+
Logging.logger['test']
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Output from PowerShell endpoint and output from OMI Server endpoint
|
19
|
+
{
|
20
|
+
'get_command_output_response.xml.erb' => 'get_command_output_response_not_done.xml.erb',
|
21
|
+
'get_omi_command_output_response.xml.erb' => 'get_omi_command_output_response_not_done.xml.erb'
|
22
|
+
}.each_pair do |template, template_not_done|
|
23
|
+
describe "#read_output for #{template}" do
|
24
|
+
context 'response doc stdout with invalid UTF-8 characters, issue 184' do
|
25
|
+
let(:test_data_stdout) { 'ffff' } # Base64-decodes to '}\xF7\xDF', an invalid sequence
|
26
|
+
let(:test_data_stderr) { '' }
|
27
|
+
let(:test_data_xml) { ERB.new(stubbed_response(template)).result(binding) }
|
28
|
+
let(:test_data) { REXML::Document.new(test_data_xml) }
|
29
|
+
let(:stdout_xpath) { "//*[local-name() = 'Stream' and @Name = 'stdout']" }
|
30
|
+
|
31
|
+
before do
|
32
|
+
allow(transport).to receive(:send_request).and_return(test_data)
|
33
|
+
end
|
34
|
+
|
35
|
+
# OMI server messages do not appear to include stdout when CommandState/Done
|
36
|
+
it 'does not raise an ArgumentError: invalid byte sequence in UTF-8' do
|
37
|
+
begin
|
38
|
+
expect(
|
39
|
+
subject.read_output(output_message)
|
40
|
+
).not_to raise_error
|
41
|
+
rescue RSpec::Expectations::ExpectationNotMetError => e
|
42
|
+
expect(e.message).not_to include 'ArgumentError'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'does not have an empty stdout' do
|
47
|
+
skip('response has no stdout') if REXML::XPath.match(test_data, stdout_xpath).empty?
|
48
|
+
expect(
|
49
|
+
subject.read_output(output_message).stdout
|
50
|
+
).not_to be_empty
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'response doc stdout with valid UTF-8' do
|
55
|
+
let(:test_data_raw) { '✓1234-äöü' }
|
56
|
+
let(:test_data_stdout) { Base64.encode64(test_data_raw) }
|
57
|
+
let(:test_data_stderr) { '' }
|
58
|
+
let(:test_data_xml) { ERB.new(stubbed_response(template)).result(binding) }
|
59
|
+
let(:test_data) { REXML::Document.new(test_data_xml) }
|
60
|
+
let(:stdout_xpath) { "//*[local-name() = 'Stream' and @Name = 'stdout']" }
|
61
|
+
|
62
|
+
before do
|
63
|
+
allow(transport).to receive(:send_request).and_return(test_data)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'decodes to match input data' do
|
67
|
+
skip('response has no stdout') if REXML::XPath.match(test_data, stdout_xpath).empty?
|
68
|
+
expect(
|
69
|
+
subject.read_output(output_message).stdout
|
70
|
+
).to eq(test_data_raw)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "#read_response for #{template}" do
|
76
|
+
context 'do not wait for done state' do
|
77
|
+
let(:test_data_raw) { 'output text' }
|
78
|
+
let(:test_error_raw) { 'error text' }
|
79
|
+
let(:test_data_stdout) { Base64.encode64(test_data_raw) }
|
80
|
+
let(:test_data_stderr) { Base64.encode64(test_error_raw) }
|
81
|
+
let(:test_data_xml) { ERB.new(stubbed_response(template)).result(binding) }
|
82
|
+
|
83
|
+
before do
|
84
|
+
allow(transport).to receive(:send_request).and_return(
|
85
|
+
REXML::Document.new(test_data_xml)
|
86
|
+
).once
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'yields stream and document' do
|
90
|
+
subject.read_response(output_message) do |stream, doc|
|
91
|
+
expect(stream[:text]).to eq(test_data_stdout) if stream[:type] == :stdout
|
92
|
+
expect(stream[:text]).to eq(test_data_stderr) if stream[:type] == :stderr
|
93
|
+
expect(doc.to_s).to eq(REXML::Document.new(test_data_xml).to_s)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'wait for done state' do
|
99
|
+
let(:test_data_raw) { 'output text' }
|
100
|
+
let(:test_error_raw) { 'error text' }
|
101
|
+
let(:test_data_stdout) { Base64.encode64(test_data_raw) }
|
102
|
+
let(:test_data_stderr) { Base64.encode64(test_error_raw) }
|
103
|
+
let(:test_data_xml_notdone) { ERB.new(stubbed_response(template_not_done)).result(binding) }
|
104
|
+
let(:test_data_xml_done) { ERB.new(stubbed_response(template)).result(binding) }
|
105
|
+
|
106
|
+
it 'yields streams and both documents' do
|
107
|
+
allow(transport).to receive(:send_request).and_return(
|
108
|
+
REXML::Document.new(test_data_xml_notdone),
|
109
|
+
REXML::Document.new(test_data_xml_done)
|
110
|
+
)
|
111
|
+
times = 1
|
112
|
+
|
113
|
+
subject.read_response(output_message, true) do |stream, doc|
|
114
|
+
expect(stream[:text]).to eq(test_data_stdout) if stream[:type] == :stdout
|
115
|
+
expect(stream[:text]).to eq(test_data_stderr) if stream[:type] == :stderr
|
116
|
+
expect(doc.to_s).to eq(REXML::Document.new(test_data_xml_notdone).to_s) if times == 1
|
117
|
+
expect(doc.to_s).to eq(REXML::Document.new(test_data_xml_done).to_s) if times > 2
|
118
|
+
times += 1
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|