winrm 2.1.0 → 2.1.1
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 +263 -260
- data/Rakefile +34 -34
- data/Vagrantfile +6 -6
- data/WinrmAppveyor.psm1 +31 -31
- data/appveyor.yml +51 -51
- data/changelog.md +107 -104
- data/lib/winrm.rb +39 -39
- data/lib/winrm/connection.rb +83 -83
- 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 +54 -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 +144 -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 -180
- 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 -58
- 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 -131
- 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 +47 -42
- metadata +7 -3
@@ -1,21 +1,21 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'winrm/wsmv/keep_alive'
|
4
|
-
|
5
|
-
describe WinRM::WSMV::KeepAlive do
|
6
|
-
context 'default session options' do
|
7
|
-
let(:shell_id) { 'F4A2622B-B842-4EB8-8A78-0225C8A993DF' }
|
8
|
-
subject { described_class.new(default_connection_opts, shell_id) }
|
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(
|
13
|
-
'<w:OptionSet><w:Option Name="WSMAN_CMDSHELL_OPTION_KEEPALIVE">' \
|
14
|
-
'TRUE</w:Option></w:OptionSet>')
|
15
|
-
expect(xml).to include(
|
16
|
-
'<w:SelectorSet><w:Selector Name="ShellId">' \
|
17
|
-
"#{shell_id}</w:Selector></w:SelectorSet>")
|
18
|
-
expect(xml).to include('<rsp:DesiredStream>stdout</rsp:DesiredStream>')
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'winrm/wsmv/keep_alive'
|
4
|
+
|
5
|
+
describe WinRM::WSMV::KeepAlive do
|
6
|
+
context 'default session options' do
|
7
|
+
let(:shell_id) { 'F4A2622B-B842-4EB8-8A78-0225C8A993DF' }
|
8
|
+
subject { described_class.new(default_connection_opts, shell_id) }
|
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(
|
13
|
+
'<w:OptionSet><w:Option Name="WSMAN_CMDSHELL_OPTION_KEEPALIVE">' \
|
14
|
+
'TRUE</w:Option></w:OptionSet>')
|
15
|
+
expect(xml).to include(
|
16
|
+
'<w:SelectorSet><w:Selector Name="ShellId">' \
|
17
|
+
"#{shell_id}</w:Selector></w:SelectorSet>")
|
18
|
+
expect(xml).to include('<rsp:DesiredStream>stdout</rsp:DesiredStream>')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,123 +1,123 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'winrm/wsmv/receive_response_reader'
|
4
|
-
|
5
|
-
describe WinRM::WSMV::ReceiveResponseReader do
|
6
|
-
let(:shell_id) { 'F4A2622B-B842-4EB8-8A78-0225C8A993DF' }
|
7
|
-
let(:command_id) { 'A2A2622B-B842-4EB8-8A78-0225C8A993DF' }
|
8
|
-
let(:output_message) { double('output_message', build: 'output_message') }
|
9
|
-
let(:test_data_xml_template) do
|
10
|
-
ERB.new(stubbed_response('get_command_output_response.xml.erb'))
|
11
|
-
end
|
12
|
-
let(:test_data_xml_template_not_done) do
|
13
|
-
ERB.new(stubbed_response('get_command_output_response_not_done.xml.erb'))
|
14
|
-
end
|
15
|
-
let(:transport) do
|
16
|
-
{}
|
17
|
-
end
|
18
|
-
|
19
|
-
subject do
|
20
|
-
described_class.new(
|
21
|
-
transport,
|
22
|
-
Logging.logger['test']
|
23
|
-
)
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '#read_output' do
|
27
|
-
context 'response doc stdout with invalid UTF-8 characters, issue 184' do
|
28
|
-
let(:test_data_stdout) { 'ffff' } # Base64-decodes to '}\xF7\xDF', an invalid sequence
|
29
|
-
let(:test_data_stderr) { '' }
|
30
|
-
let(:test_data_xml) { test_data_xml_template.result(binding) }
|
31
|
-
|
32
|
-
before do
|
33
|
-
allow(transport).to receive(:send_request).and_return(
|
34
|
-
REXML::Document.new(test_data_xml)
|
35
|
-
)
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'does not raise an ArgumentError: invalid byte sequence in UTF-8' do
|
39
|
-
begin
|
40
|
-
expect(
|
41
|
-
subject.read_output(output_message)
|
42
|
-
).not_to raise_error
|
43
|
-
rescue RSpec::Expectations::ExpectationNotMetError => e
|
44
|
-
expect(e.message).not_to include 'ArgumentError'
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'does not have an empty stdout' do
|
49
|
-
expect(
|
50
|
-
subject.read_output(output_message).stdout
|
51
|
-
).not_to be_empty
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context 'response doc stdout with valid UTF-8' do
|
56
|
-
let(:test_data_raw) { '✓1234-äöü' }
|
57
|
-
let(:test_data_stdout) { Base64.encode64(test_data_raw) }
|
58
|
-
let(:test_data_stderr) { '' }
|
59
|
-
let(:test_data_xml) { test_data_xml_template.result(binding) }
|
60
|
-
|
61
|
-
before do
|
62
|
-
allow(transport).to receive(:send_request).and_return(
|
63
|
-
REXML::Document.new(test_data_xml)
|
64
|
-
)
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'decodes to match input data' do
|
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' 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) { test_data_xml_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_not_done) { test_data_xml_template_not_done.result(binding) }
|
104
|
-
let(:test_data_xml_done) { test_data_xml_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_not_done),
|
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_not_done).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
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'winrm/wsmv/receive_response_reader'
|
4
|
+
|
5
|
+
describe WinRM::WSMV::ReceiveResponseReader do
|
6
|
+
let(:shell_id) { 'F4A2622B-B842-4EB8-8A78-0225C8A993DF' }
|
7
|
+
let(:command_id) { 'A2A2622B-B842-4EB8-8A78-0225C8A993DF' }
|
8
|
+
let(:output_message) { double('output_message', build: 'output_message') }
|
9
|
+
let(:test_data_xml_template) do
|
10
|
+
ERB.new(stubbed_response('get_command_output_response.xml.erb'))
|
11
|
+
end
|
12
|
+
let(:test_data_xml_template_not_done) do
|
13
|
+
ERB.new(stubbed_response('get_command_output_response_not_done.xml.erb'))
|
14
|
+
end
|
15
|
+
let(:transport) do
|
16
|
+
{}
|
17
|
+
end
|
18
|
+
|
19
|
+
subject do
|
20
|
+
described_class.new(
|
21
|
+
transport,
|
22
|
+
Logging.logger['test']
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#read_output' do
|
27
|
+
context 'response doc stdout with invalid UTF-8 characters, issue 184' do
|
28
|
+
let(:test_data_stdout) { 'ffff' } # Base64-decodes to '}\xF7\xDF', an invalid sequence
|
29
|
+
let(:test_data_stderr) { '' }
|
30
|
+
let(:test_data_xml) { test_data_xml_template.result(binding) }
|
31
|
+
|
32
|
+
before do
|
33
|
+
allow(transport).to receive(:send_request).and_return(
|
34
|
+
REXML::Document.new(test_data_xml)
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'does not raise an ArgumentError: invalid byte sequence in UTF-8' do
|
39
|
+
begin
|
40
|
+
expect(
|
41
|
+
subject.read_output(output_message)
|
42
|
+
).not_to raise_error
|
43
|
+
rescue RSpec::Expectations::ExpectationNotMetError => e
|
44
|
+
expect(e.message).not_to include 'ArgumentError'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'does not have an empty stdout' do
|
49
|
+
expect(
|
50
|
+
subject.read_output(output_message).stdout
|
51
|
+
).not_to be_empty
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'response doc stdout with valid UTF-8' do
|
56
|
+
let(:test_data_raw) { '✓1234-äöü' }
|
57
|
+
let(:test_data_stdout) { Base64.encode64(test_data_raw) }
|
58
|
+
let(:test_data_stderr) { '' }
|
59
|
+
let(:test_data_xml) { test_data_xml_template.result(binding) }
|
60
|
+
|
61
|
+
before do
|
62
|
+
allow(transport).to receive(:send_request).and_return(
|
63
|
+
REXML::Document.new(test_data_xml)
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'decodes to match input data' do
|
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' 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) { test_data_xml_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_not_done) { test_data_xml_template_not_done.result(binding) }
|
104
|
+
let(:test_data_xml_done) { test_data_xml_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_not_done),
|
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_not_done).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
|
@@ -1,30 +1,30 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'winrm/wsmv/send_data'
|
4
|
-
|
5
|
-
describe WinRM::WSMV::SendData 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(1, [1, 2, 3]) }
|
10
|
-
let(:pipeline) { Base64.strict_encode64(fragment.bytes.pack('C*')) }
|
11
|
-
|
12
|
-
subject do
|
13
|
-
described_class.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(
|
27
|
-
"<rsp:Stream Name=\"stdin\" CommandId=\"#{command_id}\">#{pipeline}</rsp:Stream>")
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'winrm/wsmv/send_data'
|
4
|
+
|
5
|
+
describe WinRM::WSMV::SendData 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(1, [1, 2, 3]) }
|
10
|
+
let(:pipeline) { Base64.strict_encode64(fragment.bytes.pack('C*')) }
|
11
|
+
|
12
|
+
subject do
|
13
|
+
described_class.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(
|
27
|
+
"<rsp:Stream Name=\"stdin\" CommandId=\"#{command_id}\">#{pipeline}</rsp:Stream>")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'winrm/wsmv/wql_query'
|
4
|
-
|
5
|
-
describe WinRM::WSMV::WqlQuery do
|
6
|
-
context 'default session options' do
|
7
|
-
subject { described_class.new(default_connection_opts, 'SELECT * FROM Win32') }
|
8
|
-
let(:xml) { subject.build }
|
9
|
-
it 'creates a well formed message' do
|
10
|
-
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'winrm/wsmv/wql_query'
|
4
|
+
|
5
|
+
describe WinRM::WSMV::WqlQuery do
|
6
|
+
context 'default session options' do
|
7
|
+
subject { described_class.new(default_connection_opts, 'SELECT * FROM Win32') }
|
8
|
+
let(:xml) { subject.build }
|
9
|
+
it 'creates a well formed message' do
|
10
|
+
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,22 +1,22 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'base64'
|
4
|
-
require 'winrm/wsmv/write_stdin'
|
5
|
-
|
6
|
-
describe WinRM::WSMV::WriteStdin do
|
7
|
-
context 'default session options' do
|
8
|
-
stdin_opts = {
|
9
|
-
shell_id: 'D5A2622B-B842-4EB8-8A78-0225C8A993DF',
|
10
|
-
command_id: 'A2A2622B-B842-4EB8-8A78-0225C8A993DF',
|
11
|
-
stdin: 'dir'
|
12
|
-
}
|
13
|
-
subject { described_class.new(default_connection_opts, stdin_opts) }
|
14
|
-
let(:xml) { subject.build }
|
15
|
-
it 'creates a well formed message' do
|
16
|
-
b64_stdin = Base64.encode64(stdin_opts[:stdin])
|
17
|
-
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
18
|
-
expect(xml).to include('<rsp:Stream Name="stdin" ' \
|
19
|
-
"CommandId=\"A2A2622B-B842-4EB8-8A78-0225C8A993DF\">#{b64_stdin}</rsp:Stream>")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'base64'
|
4
|
+
require 'winrm/wsmv/write_stdin'
|
5
|
+
|
6
|
+
describe WinRM::WSMV::WriteStdin do
|
7
|
+
context 'default session options' do
|
8
|
+
stdin_opts = {
|
9
|
+
shell_id: 'D5A2622B-B842-4EB8-8A78-0225C8A993DF',
|
10
|
+
command_id: 'A2A2622B-B842-4EB8-8A78-0225C8A993DF',
|
11
|
+
stdin: 'dir'
|
12
|
+
}
|
13
|
+
subject { described_class.new(default_connection_opts, stdin_opts) }
|
14
|
+
let(:xml) { subject.build }
|
15
|
+
it 'creates a well formed message' do
|
16
|
+
b64_stdin = Base64.encode64(stdin_opts[:stdin])
|
17
|
+
expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
|
18
|
+
expect(xml).to include('<rsp:Stream Name="stdin" ' \
|
19
|
+
"CommandId=\"A2A2622B-B842-4EB8-8A78-0225C8A993DF\">#{b64_stdin}</rsp:Stream>")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/winrm.gemspec
CHANGED
@@ -1,42 +1,47 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'date'
|
3
|
-
require File.expand_path('../lib/winrm/version', __FILE__)
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.platform = Gem::Platform::RUBY
|
7
|
-
s.name = 'winrm'
|
8
|
-
s.version = WinRM::VERSION
|
9
|
-
s.date = Date.today.to_s
|
10
|
-
|
11
|
-
s.author = ['Dan Wanek', 'Paul Morton']
|
12
|
-
s.email = [
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
s.
|
22
|
-
|
23
|
-
|
24
|
-
s.
|
25
|
-
|
26
|
-
s.
|
27
|
-
s.
|
28
|
-
s.
|
29
|
-
s.
|
30
|
-
|
31
|
-
s.
|
32
|
-
s.
|
33
|
-
s.
|
34
|
-
s.add_runtime_dependency '
|
35
|
-
s.add_runtime_dependency '
|
36
|
-
s.add_runtime_dependency '
|
37
|
-
s.
|
38
|
-
s.
|
39
|
-
s.
|
40
|
-
s.
|
41
|
-
s.
|
42
|
-
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'date'
|
3
|
+
require File.expand_path('../lib/winrm/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.platform = Gem::Platform::RUBY
|
7
|
+
s.name = 'winrm'
|
8
|
+
s.version = WinRM::VERSION
|
9
|
+
s.date = Date.today.to_s
|
10
|
+
|
11
|
+
s.author = ['Dan Wanek', 'Paul Morton', 'Matt Wrock', 'Shawn Neal']
|
12
|
+
s.email = [
|
13
|
+
'dan.wanek@gmail.com',
|
14
|
+
'paul@themortonsonline.com',
|
15
|
+
'matt@mattwrock.com',
|
16
|
+
'sneal@sneal.net'
|
17
|
+
]
|
18
|
+
s.homepage = 'https://github.com/WinRb/WinRM'
|
19
|
+
|
20
|
+
s.summary = 'Ruby library for Windows Remote Management'
|
21
|
+
s.description = <<-EOF
|
22
|
+
Ruby library for Windows Remote Management
|
23
|
+
EOF
|
24
|
+
s.license = 'Apache-2.0'
|
25
|
+
|
26
|
+
s.files = `git ls-files`.split(/\n/)
|
27
|
+
s.require_path = 'lib'
|
28
|
+
s.rdoc_options = %w(-x test/ -x examples/)
|
29
|
+
s.extra_rdoc_files = %w(README.md LICENSE)
|
30
|
+
|
31
|
+
s.bindir = 'bin'
|
32
|
+
s.executables = ['rwinrm']
|
33
|
+
s.required_ruby_version = '>= 2.0'
|
34
|
+
s.add_runtime_dependency 'gssapi', '~> 1.2'
|
35
|
+
s.add_runtime_dependency 'httpclient', '~> 2.2', '>= 2.2.0.2'
|
36
|
+
s.add_runtime_dependency 'rubyntlm', '~> 0.6.0', '>= 0.6.1'
|
37
|
+
s.add_runtime_dependency 'logging', ['>= 1.6.1', '< 3.0']
|
38
|
+
s.add_runtime_dependency 'nori', '~> 2.0'
|
39
|
+
s.add_runtime_dependency 'gyoku', '~> 1.0'
|
40
|
+
s.add_runtime_dependency 'builder', '>= 2.1.2'
|
41
|
+
s.add_runtime_dependency 'erubis', '~> 2.7'
|
42
|
+
s.add_development_dependency 'rspec', '~> 3.2'
|
43
|
+
s.add_development_dependency 'rake', '~> 10.3'
|
44
|
+
s.add_development_dependency 'rubocop', '~> 0.39.0'
|
45
|
+
s.add_development_dependency 'pry'
|
46
|
+
s.add_development_dependency 'rb-readline'
|
47
|
+
end
|