winrm 2.3.0 → 2.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/lib/winrm/http/response_handler.rb +1 -1
  3. data/lib/winrm/http/transport.rb +2 -2
  4. data/lib/winrm/psrp/message.rb +128 -128
  5. data/lib/winrm/psrp/message_data/error_record.rb +2 -0
  6. data/lib/winrm/psrp/message_data/pipeline_output.rb +1 -1
  7. data/lib/winrm/psrp/message_factory.rb +14 -2
  8. data/lib/winrm/psrp/powershell_output_decoder.rb +142 -142
  9. data/lib/winrm/shells/base.rb +1 -0
  10. data/lib/winrm/shells/power_shell.rb +4 -4
  11. data/lib/winrm/version.rb +1 -1
  12. metadata +16 -90
  13. data/.gitignore +0 -10
  14. data/.rubocop.yml +0 -38
  15. data/.travis.yml +0 -10
  16. data/Gemfile +0 -2
  17. data/Rakefile +0 -33
  18. data/Vagrantfile +0 -6
  19. data/WinrmAppveyor.psm1 +0 -32
  20. data/appveyor.yml +0 -50
  21. data/changelog.md +0 -133
  22. data/preamble +0 -17
  23. data/tests/integration/auth_timeout_spec.rb +0 -17
  24. data/tests/integration/cmd_spec.rb +0 -130
  25. data/tests/integration/config-example.yml +0 -16
  26. data/tests/integration/issue_59_spec.rb +0 -25
  27. data/tests/integration/powershell_spec.rb +0 -164
  28. data/tests/integration/spec_helper.rb +0 -62
  29. data/tests/integration/transport_spec.rb +0 -98
  30. data/tests/integration/wql_spec.rb +0 -33
  31. data/tests/matchers.rb +0 -59
  32. data/tests/spec/configuration_spec.rb +0 -183
  33. data/tests/spec/connection_spec.rb +0 -37
  34. data/tests/spec/exception_spec.rb +0 -49
  35. data/tests/spec/http/transport_factory_spec.rb +0 -66
  36. data/tests/spec/http/transport_spec.rb +0 -43
  37. data/tests/spec/output_spec.rb +0 -128
  38. data/tests/spec/psrp/fragment_spec.rb +0 -60
  39. data/tests/spec/psrp/message_data/base_spec.rb +0 -11
  40. data/tests/spec/psrp/message_data/error_record_spec.rb +0 -39
  41. data/tests/spec/psrp/message_data/pipeline_host_call_spec.rb +0 -23
  42. data/tests/spec/psrp/message_data/pipeline_output_spec.rb +0 -30
  43. data/tests/spec/psrp/message_data/pipeline_state_spec.rb +0 -38
  44. data/tests/spec/psrp/message_data/runspace_pool_host_call_spec.rb +0 -23
  45. data/tests/spec/psrp/message_data/runspacepool_state_spec.rb +0 -14
  46. data/tests/spec/psrp/message_data/session_capability_spec.rb +0 -28
  47. data/tests/spec/psrp/message_data_spec.rb +0 -33
  48. data/tests/spec/psrp/message_defragmenter_spec.rb +0 -45
  49. data/tests/spec/psrp/message_fragmenter_spec.rb +0 -103
  50. data/tests/spec/psrp/powershell_output_decoder_spec.rb +0 -98
  51. data/tests/spec/psrp/psrp_message_spec.rb +0 -73
  52. data/tests/spec/psrp/recieve_response_reader_spec.rb +0 -170
  53. data/tests/spec/psrp/uuid_spec.rb +0 -28
  54. data/tests/spec/response_handler_spec.rb +0 -69
  55. data/tests/spec/shells/base_spec.rb +0 -227
  56. data/tests/spec/shells/cmd_spec.rb +0 -75
  57. data/tests/spec/shells/powershell_spec.rb +0 -221
  58. data/tests/spec/spec_helper.rb +0 -46
  59. data/tests/spec/stubs/clixml/error_record.xml.erb +0 -84
  60. data/tests/spec/stubs/clixml/pipeline_state.xml.erb +0 -88
  61. data/tests/spec/stubs/responses/get_command_output_response.xml.erb +0 -13
  62. data/tests/spec/stubs/responses/get_command_output_response_not_done.xml.erb +0 -10
  63. data/tests/spec/stubs/responses/get_omi_command_output_response.xml.erb +0 -23
  64. data/tests/spec/stubs/responses/get_omi_command_output_response_not_done.xml.erb +0 -24
  65. data/tests/spec/stubs/responses/get_omi_config_response.xml +0 -45
  66. data/tests/spec/stubs/responses/get_omi_powershell_keepalive_response.xml.erb +0 -33
  67. data/tests/spec/stubs/responses/get_powershell_keepalive_response.xml.erb +0 -10
  68. data/tests/spec/stubs/responses/get_powershell_output_response.xml.erb +0 -12
  69. data/tests/spec/stubs/responses/get_powershell_output_response_not_done.xml.erb +0 -9
  70. data/tests/spec/stubs/responses/open_shell_omi.xml +0 -43
  71. data/tests/spec/stubs/responses/open_shell_v1.xml +0 -19
  72. data/tests/spec/stubs/responses/open_shell_v2.xml +0 -20
  73. data/tests/spec/stubs/responses/soap_fault_omi.xml +0 -31
  74. data/tests/spec/stubs/responses/soap_fault_v1.xml +0 -36
  75. data/tests/spec/stubs/responses/soap_fault_v2.xml +0 -42
  76. data/tests/spec/stubs/responses/wmi_error_v2.xml +0 -41
  77. data/tests/spec/wsmv/cleanup_command_spec.rb +0 -20
  78. data/tests/spec/wsmv/close_shell_spec.rb +0 -15
  79. data/tests/spec/wsmv/command_output_decoder_spec.rb +0 -35
  80. data/tests/spec/wsmv/command_output_spec.rb +0 -43
  81. data/tests/spec/wsmv/command_spec.rb +0 -17
  82. data/tests/spec/wsmv/configuration_spec.rb +0 -15
  83. data/tests/spec/wsmv/create_pipeline_spec.rb +0 -30
  84. data/tests/spec/wsmv/create_shell_spec.rb +0 -39
  85. data/tests/spec/wsmv/init_runspace_pool_spec.rb +0 -38
  86. data/tests/spec/wsmv/keep_alive_spec.rb +0 -21
  87. data/tests/spec/wsmv/receive_response_reader_spec.rb +0 -124
  88. data/tests/spec/wsmv/send_data_spec.rb +0 -30
  89. data/tests/spec/wsmv/wql_query_spec.rb +0 -11
  90. data/tests/spec/wsmv/write_stdin_spec.rb +0 -20
  91. data/winrm.gemspec +0 -46
@@ -1,21 +0,0 @@
1
- require 'winrm/wsmv/keep_alive'
2
-
3
- describe WinRM::WSMV::KeepAlive do
4
- context 'default session options' do
5
- let(:shell_id) { 'F4A2622B-B842-4EB8-8A78-0225C8A993DF' }
6
- subject { described_class.new(default_connection_opts, shell_id) }
7
- let(:xml) { subject.build }
8
- it 'creates a well formed message' do
9
- expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
10
- expect(xml).to include(
11
- '<w:OptionSet><w:Option Name="WSMAN_CMDSHELL_OPTION_KEEPALIVE">' \
12
- 'TRUE</w:Option></w:OptionSet>'
13
- )
14
- expect(xml).to include(
15
- '<w:SelectorSet><w:Selector Name="ShellId">' \
16
- "#{shell_id}</w:Selector></w:SelectorSet>"
17
- )
18
- expect(xml).to include('<rsp:DesiredStream>stdout</rsp:DesiredStream>')
19
- end
20
- end
21
- end
@@ -1,124 +0,0 @@
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
@@ -1,30 +0,0 @@
1
- require 'winrm/wsmv/send_data'
2
-
3
- describe WinRM::WSMV::SendData do
4
- context 'default session options' do
5
- let(:shell_id) { 'D5A2622B-B842-4EB8-8A78-0225C8A993DF' }
6
- let(:command_id) { 'D5A2622B-B842-4EB8-8A78-0225C8A993DF' }
7
- let(:fragment) { WinRM::PSRP::Fragment.new(1, [1, 2, 3]) }
8
- let(:pipeline) { Base64.strict_encode64(fragment.bytes.pack('C*')) }
9
-
10
- subject do
11
- described_class.new(
12
- default_connection_opts,
13
- shell_id,
14
- command_id,
15
- fragment
16
- )
17
- end
18
- let(:xml) { subject.build }
19
- it 'creates a well formed message' do
20
- expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
21
- expect(xml).to include(
22
- '<w:SelectorSet><w:Selector Name="ShellId">' \
23
- "#{shell_id}</w:Selector></w:SelectorSet>"
24
- )
25
- expect(xml).to include(
26
- "<rsp:Stream Name=\"stdin\" CommandId=\"#{command_id}\">#{pipeline}</rsp:Stream>"
27
- )
28
- end
29
- end
30
- end
@@ -1,11 +0,0 @@
1
- require 'winrm/wsmv/wql_query'
2
-
3
- describe WinRM::WSMV::WqlQuery do
4
- context 'default session options' do
5
- subject { described_class.new(nil, default_connection_opts, 'SELECT * FROM Win32') }
6
- let(:xml) { subject.build }
7
- it 'creates a well formed message' do
8
- expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
9
- end
10
- end
11
- end
@@ -1,20 +0,0 @@
1
- require 'base64'
2
- require 'winrm/wsmv/write_stdin'
3
-
4
- describe WinRM::WSMV::WriteStdin do
5
- context 'default session options' do
6
- stdin_opts = {
7
- shell_id: 'D5A2622B-B842-4EB8-8A78-0225C8A993DF',
8
- command_id: 'A2A2622B-B842-4EB8-8A78-0225C8A993DF',
9
- stdin: 'dir'
10
- }
11
- subject { described_class.new(default_connection_opts, stdin_opts) }
12
- let(:xml) { subject.build }
13
- it 'creates a well formed message' do
14
- b64_stdin = Base64.encode64(stdin_opts[:stdin])
15
- expect(xml).to include('<w:OperationTimeout>PT60S</w:OperationTimeout>')
16
- expect(xml).to include('<rsp:Stream Name="stdin" ' \
17
- "CommandId=\"A2A2622B-B842-4EB8-8A78-0225C8A993DF\">#{b64_stdin}</rsp:Stream>")
18
- end
19
- end
20
- end
@@ -1,46 +0,0 @@
1
- require 'date'
2
- require File.expand_path('lib/winrm/version', __dir__)
3
-
4
- Gem::Specification.new do |s|
5
- s.platform = Gem::Platform::RUBY
6
- s.name = 'winrm'
7
- s.version = WinRM::VERSION
8
- s.date = Date.today.to_s
9
-
10
- s.author = ['Dan Wanek', 'Paul Morton', 'Matt Wrock', 'Shawn Neal']
11
- s.email = [
12
- 'dan.wanek@gmail.com',
13
- 'paul@themortonsonline.com',
14
- 'matt@mattwrock.com',
15
- 'sneal@sneal.net'
16
- ]
17
- s.homepage = 'https://github.com/WinRb/WinRM'
18
-
19
- s.summary = 'Ruby library for Windows Remote Management'
20
- s.description = <<-EOF
21
- Ruby library for Windows Remote Management
22
- EOF
23
- s.license = 'Apache-2.0'
24
-
25
- s.files = `git ls-files`.split(/\n/)
26
- s.require_path = 'lib'
27
- s.rdoc_options = %w[-x test/ -x examples/]
28
- s.extra_rdoc_files = %w[README.md LICENSE]
29
-
30
- s.bindir = 'bin'
31
- s.executables = ['rwinrm']
32
- s.required_ruby_version = '>= 2.2.0'
33
- s.add_runtime_dependency 'builder', '>= 2.1.2'
34
- s.add_runtime_dependency 'erubis', '~> 2.7'
35
- s.add_runtime_dependency 'gssapi', '~> 1.2'
36
- s.add_runtime_dependency 'gyoku', '~> 1.0'
37
- s.add_runtime_dependency 'httpclient', '~> 2.2', '>= 2.2.0.2'
38
- s.add_runtime_dependency 'logging', ['>= 1.6.1', '< 3.0']
39
- s.add_runtime_dependency 'nori', '~> 2.0'
40
- s.add_development_dependency 'pry'
41
- s.add_development_dependency 'rake', '~> 10.3'
42
- s.add_development_dependency 'rb-readline'
43
- s.add_development_dependency 'rspec', '~> 3.2'
44
- s.add_development_dependency 'rubocop', '~> 0.51'
45
- s.add_runtime_dependency 'rubyntlm', '~> 0.6.0', '>= 0.6.1'
46
- end