winrm 2.2.3 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +13 -1
  3. data/.travis.yml +10 -11
  4. data/Gemfile +2 -3
  5. data/README.md +1 -1
  6. data/Rakefile +3 -4
  7. data/appveyor.yml +1 -2
  8. data/bin/rwinrm +90 -97
  9. data/changelog.md +5 -0
  10. data/lib/winrm.rb +3 -5
  11. data/lib/winrm/connection.rb +84 -86
  12. data/lib/winrm/connection_opts.rb +90 -91
  13. data/lib/winrm/exceptions.rb +14 -2
  14. data/lib/winrm/http/response_handler.rb +127 -96
  15. data/lib/winrm/http/transport.rb +462 -427
  16. data/lib/winrm/http/transport_factory.rb +1 -5
  17. data/lib/winrm/output.rb +1 -2
  18. data/lib/winrm/psrp/fragment.rb +0 -2
  19. data/lib/winrm/psrp/message.rb +1 -3
  20. data/lib/winrm/psrp/message_data.rb +0 -2
  21. data/lib/winrm/psrp/message_data/base.rb +0 -2
  22. data/lib/winrm/psrp/message_data/error_record.rb +0 -2
  23. data/lib/winrm/psrp/message_data/pipeline_host_call.rb +0 -2
  24. data/lib/winrm/psrp/message_data/pipeline_output.rb +48 -54
  25. data/lib/winrm/psrp/message_data/pipeline_state.rb +0 -2
  26. data/lib/winrm/psrp/message_data/runspacepool_host_call.rb +0 -2
  27. data/lib/winrm/psrp/message_data/runspacepool_state.rb +0 -2
  28. data/lib/winrm/psrp/message_data/session_capability.rb +0 -2
  29. data/lib/winrm/psrp/message_defragmenter.rb +2 -2
  30. data/lib/winrm/psrp/message_factory.rb +2 -3
  31. data/lib/winrm/psrp/message_fragmenter.rb +1 -3
  32. data/lib/winrm/psrp/powershell_output_decoder.rb +0 -2
  33. data/lib/winrm/psrp/receive_response_reader.rb +3 -5
  34. data/lib/winrm/psrp/uuid.rb +1 -2
  35. data/lib/winrm/shells/base.rb +6 -4
  36. data/lib/winrm/shells/cmd.rb +63 -65
  37. data/lib/winrm/shells/power_shell.rb +207 -202
  38. data/lib/winrm/shells/retryable.rb +44 -45
  39. data/lib/winrm/shells/shell_factory.rb +0 -2
  40. data/lib/winrm/version.rb +1 -3
  41. data/lib/winrm/wsmv/base.rb +0 -2
  42. data/lib/winrm/wsmv/cleanup_command.rb +1 -2
  43. data/lib/winrm/wsmv/close_shell.rb +1 -2
  44. data/lib/winrm/wsmv/command.rb +2 -3
  45. data/lib/winrm/wsmv/command_output.rb +2 -3
  46. data/lib/winrm/wsmv/command_output_decoder.rb +1 -2
  47. data/lib/winrm/wsmv/configuration.rb +0 -2
  48. data/lib/winrm/wsmv/create_pipeline.rb +0 -2
  49. data/lib/winrm/wsmv/create_shell.rb +2 -6
  50. data/lib/winrm/wsmv/header.rb +213 -215
  51. data/lib/winrm/wsmv/init_runspace_pool.rb +96 -95
  52. data/lib/winrm/wsmv/iso8601_duration.rb +0 -2
  53. data/lib/winrm/wsmv/keep_alive.rb +0 -2
  54. data/lib/winrm/wsmv/receive_response_reader.rb +128 -126
  55. data/lib/winrm/wsmv/send_data.rb +0 -2
  56. data/lib/winrm/wsmv/soap.rb +0 -2
  57. data/lib/winrm/wsmv/wql_pull.rb +54 -56
  58. data/lib/winrm/wsmv/wql_query.rb +98 -99
  59. data/lib/winrm/wsmv/write_stdin.rb +0 -2
  60. data/tests/integration/auth_timeout_spec.rb +0 -1
  61. data/tests/integration/cmd_spec.rb +2 -3
  62. data/tests/integration/issue_59_spec.rb +0 -1
  63. data/tests/integration/powershell_spec.rb +4 -5
  64. data/tests/integration/spec_helper.rb +3 -6
  65. data/tests/integration/transport_spec.rb +0 -1
  66. data/tests/integration/wql_spec.rb +33 -34
  67. data/tests/matchers.rb +2 -3
  68. data/tests/spec/configuration_spec.rb +0 -1
  69. data/tests/spec/connection_spec.rb +0 -2
  70. data/tests/spec/exception_spec.rb +0 -1
  71. data/tests/spec/http/transport_factory_spec.rb +1 -3
  72. data/tests/spec/http/transport_spec.rb +0 -1
  73. data/tests/spec/output_spec.rb +4 -3
  74. data/tests/spec/psrp/fragment_spec.rb +0 -2
  75. data/tests/spec/psrp/message_data/base_spec.rb +0 -2
  76. data/tests/spec/psrp/message_data/error_record_spec.rb +0 -2
  77. data/tests/spec/psrp/message_data/pipeline_host_call_spec.rb +0 -2
  78. data/tests/spec/psrp/message_data/pipeline_output_spec.rb +0 -2
  79. data/tests/spec/psrp/message_data/pipeline_state_spec.rb +0 -2
  80. data/tests/spec/psrp/message_data/runspace_pool_host_call_spec.rb +0 -2
  81. data/tests/spec/psrp/message_data/runspacepool_state_spec.rb +0 -2
  82. data/tests/spec/psrp/message_data/session_capability_spec.rb +0 -2
  83. data/tests/spec/psrp/message_data_spec.rb +0 -2
  84. data/tests/spec/psrp/message_defragmenter_spec.rb +0 -2
  85. data/tests/spec/psrp/message_fragmenter_spec.rb +0 -2
  86. data/tests/spec/psrp/powershell_output_decoder_spec.rb +0 -2
  87. data/tests/spec/psrp/psrp_message_spec.rb +10 -7
  88. data/tests/spec/psrp/recieve_response_reader_spec.rb +0 -2
  89. data/tests/spec/psrp/uuid_spec.rb +2 -2
  90. data/tests/spec/response_handler_spec.rb +69 -61
  91. data/tests/spec/shells/base_spec.rb +7 -5
  92. data/tests/spec/shells/cmd_spec.rb +4 -4
  93. data/tests/spec/shells/powershell_spec.rb +221 -175
  94. data/tests/spec/spec_helper.rb +0 -1
  95. data/tests/spec/stubs/responses/get_omi_command_output_response.xml.erb +23 -0
  96. data/tests/spec/stubs/responses/get_omi_command_output_response_not_done.xml.erb +24 -0
  97. data/tests/spec/stubs/responses/get_omi_config_response.xml +45 -0
  98. data/tests/spec/stubs/responses/get_omi_powershell_keepalive_response.xml.erb +33 -0
  99. data/tests/spec/stubs/responses/open_shell_omi.xml +43 -0
  100. data/tests/spec/stubs/responses/soap_fault_omi.xml +31 -0
  101. data/tests/spec/wsmv/cleanup_command_spec.rb +0 -2
  102. data/tests/spec/wsmv/close_shell_spec.rb +0 -2
  103. data/tests/spec/wsmv/command_output_decoder_spec.rb +0 -2
  104. data/tests/spec/wsmv/command_output_spec.rb +1 -3
  105. data/tests/spec/wsmv/command_spec.rb +0 -2
  106. data/tests/spec/wsmv/configuration_spec.rb +0 -2
  107. data/tests/spec/wsmv/create_pipeline_spec.rb +2 -3
  108. data/tests/spec/wsmv/create_shell_spec.rb +6 -5
  109. data/tests/spec/wsmv/init_runspace_pool_spec.rb +38 -36
  110. data/tests/spec/wsmv/keep_alive_spec.rb +4 -4
  111. data/tests/spec/wsmv/receive_response_reader_spec.rb +124 -123
  112. data/tests/spec/wsmv/send_data_spec.rb +4 -4
  113. data/tests/spec/wsmv/wql_query_spec.rb +11 -13
  114. data/tests/spec/wsmv/write_stdin_spec.rb +0 -2
  115. data/winrm.gemspec +11 -12
  116. metadata +73 -67
data/tests/matchers.rb CHANGED
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'rspec/expectations'
3
2
 
4
3
  # rspec matchers
@@ -23,7 +22,7 @@ end
23
22
  RSpec::Matchers.define :have_no_stdout do
24
23
  match do |actual_output|
25
24
  stdout = actual_output.stdout
26
- stdout == '\r\n' || stdout == ''
25
+ ['\r\n', ''].include?(stdout)
27
26
  end
28
27
  failure_message do |actual_output|
29
28
  "expected that '#{actual_output.stdout}' would have no stdout"
@@ -33,7 +32,7 @@ end
33
32
  RSpec::Matchers.define :have_no_stderr do
34
33
  match do |actual_output|
35
34
  stderr = actual_output.stderr
36
- stderr == '\r\n' || stderr == ''
35
+ ['\r\n', ''].include?(stderr)
37
36
  end
38
37
  failure_message do |actual_output|
39
38
  "expected that '#{actual_output.stderr}' would have no stderr"
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'winrm/connection_opts'
3
2
 
4
3
  describe WinRM::ConnectionOpts do
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'winrm'
4
2
  require 'winrm/shells/cmd'
5
3
  require 'winrm/shells/power_shell'
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  describe 'Exceptions' do
3
2
  describe WinRM::WinRMAuthorizationError do
4
3
  let(:error) { WinRM::WinRMHTTPTransportError.new('Foo happened', 500) }
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'winrm/exceptions'
3
2
  require 'winrm/http/transport_factory'
4
3
 
@@ -6,8 +5,7 @@ module WinRM
6
5
  module HTTP
7
6
  # Remove the gssapi stuff in kerberos init for tests
8
7
  class HttpGSSAPI < HttpTransport
9
- def initialize(endpoint, realm, opts, service = nil)
10
- end
8
+ def initialize(endpoint, realm, opts, service = nil) end
11
9
  end
12
10
  end
13
11
  end
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'rubyntlm'
3
2
  require 'winrm/http/transport'
4
3
 
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  describe WinRM::Output do
3
2
  subject { WinRM::Output.new }
4
3
 
@@ -87,7 +86,8 @@ describe WinRM::Output do
87
86
  describe '#stdout' do
88
87
  it 'is equal to that line' do
89
88
  expect(subject.stdout).to eq(
90
- 'I can have a newline\nanywhere, or stdout or nothing! (above)')
89
+ 'I can have a newline\nanywhere, or stdout or nothing! (above)'
90
+ )
91
91
  end
92
92
  end
93
93
 
@@ -101,7 +101,8 @@ describe WinRM::Output do
101
101
  it 'is equal to stdout + stderr' do
102
102
  expect(subject.output).to eq(
103
103
  'I can have a newline\nanywhere, I can also have stderror stdout ' \
104
- 'and stderr or nothing! (above)')
104
+ 'and stderr or nothing! (above)'
105
+ )
105
106
  end
106
107
  end
107
108
  end
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'winrm/psrp/fragment'
4
2
 
5
3
  describe WinRM::PSRP::Fragment do
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'winrm/psrp/message_data/base'
4
2
 
5
3
  describe WinRM::PSRP::MessageData::Base do
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'winrm/psrp/message_data/base'
4
2
  require 'winrm/psrp/message_data/error_record'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'winrm/psrp/message_data/base'
4
2
  require 'winrm/psrp/message_data/pipeline_host_call'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'winrm/psrp/message_data/base'
4
2
  require 'winrm/psrp/message_data/pipeline_output'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'winrm/psrp/message_data/base'
4
2
  require 'winrm/psrp/message_data/pipeline_state'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'winrm/psrp/message_data/base'
4
2
  require 'winrm/psrp/message_data/runspacepool_host_call'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'winrm/psrp/message_data/base'
4
2
  require 'winrm/psrp/message_data/runspacepool_state'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'winrm/psrp/message_data/base'
4
2
  require 'winrm/psrp/message_data/session_capability'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'winrm/psrp/message'
4
2
  require 'winrm/psrp/message_data'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'winrm/psrp/message_defragmenter'
4
2
 
5
3
  describe WinRM::PSRP::MessageDefragmenter do
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'winrm/psrp/message'
4
2
  require 'winrm/psrp/message_fragmenter'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'winrm/psrp/powershell_output_decoder'
4
2
 
5
3
  describe WinRM::PSRP::PowershellOutputDecoder do
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'winrm/psrp/message'
4
2
 
5
3
  describe WinRM::PSRP::Message do
@@ -10,7 +8,8 @@ describe WinRM::PSRP::Message do
10
8
  'bc1bfbba-8215-4a04-b2df-7a3ac0310e16',
11
9
  WinRM::PSRP::Message::MESSAGE_TYPES[:pipeline_output],
12
10
  payload,
13
- '4218a578-0f18-4b19-82c3-46b433319126')
11
+ '4218a578-0f18-4b19-82c3-46b433319126'
12
+ )
14
13
  end
15
14
 
16
15
  it 'sets the destination to server LE' do
@@ -21,11 +20,13 @@ describe WinRM::PSRP::Message do
21
20
  end
22
21
  it 'sets the runspace pool id' do
23
22
  expect(subject.bytes[8..23]).to eq(
24
- [186, 251, 27, 188, 21, 130, 4, 74, 178, 223, 122, 58, 192, 49, 14, 22])
23
+ [186, 251, 27, 188, 21, 130, 4, 74, 178, 223, 122, 58, 192, 49, 14, 22]
24
+ )
25
25
  end
26
26
  it 'sets the pipeline id' do
27
27
  expect(subject.bytes[24..39]).to eq(
28
- [120, 165, 24, 66, 24, 15, 25, 75, 130, 195, 70, 180, 51, 49, 145, 38])
28
+ [120, 165, 24, 66, 24, 15, 25, 75, 130, 195, 70, 180, 51, 49, 145, 38]
29
+ )
29
30
  end
30
31
  it 'prefixes the blob with BOM' do
31
32
  expect(subject.bytes[40..42]).to eq([239, 187, 191])
@@ -45,7 +46,8 @@ describe WinRM::PSRP::Message do
45
46
  'bc1bfbba-8215-4a04-b2df-7a3ac0310e16',
46
47
  0x00000000,
47
48
  %(<Obj RefId="0"/>),
48
- '4218a578-0f18-4b19-82c3-46b433319126')
49
+ '4218a578-0f18-4b19-82c3-46b433319126'
50
+ )
49
51
  end.to raise_error(RuntimeError)
50
52
  end
51
53
  end
@@ -60,7 +62,8 @@ describe WinRM::PSRP::Message do
60
62
  WinRM::PSRP::Message.new(
61
63
  'bc1bfbba-8215-4a04-b2df-7a3ac0310e16',
62
64
  WinRM::PSRP::Message::MESSAGE_TYPES[:session_capability],
63
- payload)
65
+ payload
66
+ )
64
67
  end
65
68
 
66
69
  it 'sets the pipeline id to empty' do
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'winrm/psrp/receive_response_reader'
4
2
 
5
3
  describe WinRM::PSRP::ReceiveResponseReader do
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  describe WinRM::PSRP::UUID do
3
2
  subject(:uuid_helper) do
4
3
  Object.new.extend(WinRM::PSRP::UUID)
@@ -22,7 +21,8 @@ describe WinRM::PSRP::UUID do
22
21
  it 'should return a Windows GUID struct compatible little endian byte array' do
23
22
  bytes = uuid_helper.uuid_to_windows_guid_bytes(uuid)
24
23
  expect(bytes).to eq(
25
- [157, 225, 249, 69, 119, 139, 148, 67, 171, 12, 25, 116, 151, 102, 22, 104])
24
+ [157, 225, 249, 69, 119, 139, 148, 67, 171, 12, 25, 116, 151, 102, 22, 104]
25
+ )
26
26
  end
27
27
  end
28
28
  end
@@ -1,61 +1,69 @@
1
- # encoding: UTF-8
2
- require 'winrm/http/response_handler'
3
-
4
- describe 'response handler', unit: true do
5
- %w(v1 v2).each do |winrm_version|
6
- context "winrm_version #{winrm_version}" do
7
- let(:soap_fault) { stubbed_response("soap_fault_#{winrm_version}.xml") }
8
- let(:open_shell) { stubbed_response("open_shell_#{winrm_version}.xml") }
9
-
10
- describe "successful 200 #{winrm_version} response" do
11
- it 'returns an xml doc' do
12
- handler = WinRM::ResponseHandler.new(open_shell, 200)
13
- xml_doc = handler.parse_to_xml
14
- expect(xml_doc).to be_instance_of(REXML::Document)
15
- expect(xml_doc.to_s).to eq(REXML::Document.new(open_shell).to_s)
16
- end
17
- end
18
-
19
- describe "failed 500 #{winrm_version} response" do
20
- it 'raises a WinRMHTTPTransportError' do
21
- handler = WinRM::ResponseHandler.new('', 500)
22
- expect { handler.parse_to_xml }.to raise_error(WinRM::WinRMHTTPTransportError)
23
- end
24
- end
25
-
26
- describe "failed 401 #{winrm_version} response" do
27
- it 'raises a WinRMAuthorizationError' do
28
- handler = WinRM::ResponseHandler.new('', 401)
29
- expect { handler.parse_to_xml }.to raise_error(WinRM::WinRMAuthorizationError)
30
- end
31
- end
32
-
33
- describe "failed 400 #{winrm_version} response" do
34
- it 'raises a WinRMWSManFault' do
35
- handler = WinRM::ResponseHandler.new(soap_fault, 400)
36
- begin
37
- handler.parse_to_xml
38
- rescue WinRM::WinRMWSManFault => e
39
- expect(e.fault_code).to eq('2150858778')
40
- expect(e.fault_description).to include(
41
- 'The specified class does not exist in the given namespace')
42
- end
43
- end
44
- end
45
- end
46
- end
47
-
48
- describe 'failed 500 WMI error response' do
49
- let(:wmi_error) { stubbed_response('wmi_error_v2.xml') }
50
-
51
- it 'raises a WinRMWMIError' do
52
- handler = WinRM::ResponseHandler.new(wmi_error, 500)
53
- begin
54
- handler.parse_to_xml
55
- rescue WinRM::WinRMWMIError => e
56
- expect(e.error_code).to eq('2150859173')
57
- expect(e.error).to include('The WS-Management service cannot process the request.')
58
- end
59
- end
60
- end
61
- end
1
+ require 'winrm/http/response_handler'
2
+
3
+ describe 'response handler', unit: true do
4
+ %w[v1 v2 omi].each do |winrm_version|
5
+ context "winrm_version #{winrm_version}" do
6
+ let(:soap_fault) { stubbed_response("soap_fault_#{winrm_version}.xml") }
7
+ let(:open_shell) { stubbed_response("open_shell_#{winrm_version}.xml") }
8
+
9
+ describe "successful 200 #{winrm_version} response" do
10
+ it 'returns an xml doc' do
11
+ handler = WinRM::ResponseHandler.new(open_shell, 200)
12
+ xml_doc = handler.parse_to_xml
13
+ expect(xml_doc).to be_instance_of(REXML::Document)
14
+ expect(xml_doc.to_s).to eq(REXML::Document.new(open_shell).to_s)
15
+ end
16
+ end
17
+
18
+ describe "failed 500 #{winrm_version} response" do
19
+ it 'raises a WinRMHTTPTransportError' do
20
+ handler = WinRM::ResponseHandler.new('', 500)
21
+ expect { handler.parse_to_xml }.to raise_error(WinRM::WinRMHTTPTransportError)
22
+ end
23
+ end
24
+
25
+ describe "failed 401 #{winrm_version} response" do
26
+ it 'raises a WinRMAuthorizationError' do
27
+ handler = WinRM::ResponseHandler.new('', 401)
28
+ expect { handler.parse_to_xml }.to raise_error(WinRM::WinRMAuthorizationError)
29
+ end
30
+ end
31
+
32
+ describe "failed 400 #{winrm_version} response" do
33
+ it 'raises a WinRMWSManFault' do
34
+ handler = WinRM::ResponseHandler.new(soap_fault, 400)
35
+ begin
36
+ handler.parse_to_xml
37
+ # PowerShell
38
+ rescue WinRM::WinRMWSManFault => e
39
+ expect(e.fault_code).to eq('2150858778')
40
+ expect(e.fault_description).to include(
41
+ 'The specified class does not exist in the given namespace'
42
+ )
43
+ # OMI
44
+ rescue WinRM::WinRMSoapFault => e
45
+ expect(e.code).to eq('SOAP-ENV:Receiver')
46
+ expect(e.subcode).to eq('wsman:InternalError')
47
+ expect(e.reason).to eq(
48
+ 'get-instance: instance name parameter is missing'
49
+ )
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ describe 'failed 500 WMI error response' do
57
+ let(:wmi_error) { stubbed_response('wmi_error_v2.xml') }
58
+
59
+ it 'raises a WinRMWMIError' do
60
+ handler = WinRM::ResponseHandler.new(wmi_error, 500)
61
+ begin
62
+ handler.parse_to_xml
63
+ rescue WinRM::WinRMWMIError => e
64
+ expect(e.error_code).to eq('2150859173')
65
+ expect(e.error).to include('The WS-Management service cannot process the request.')
66
+ end
67
+ end
68
+ end
69
+ end
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'winrm/shells/base'
4
2
 
5
3
  # Dummy shell class
@@ -28,7 +26,7 @@ class DummyShell < WinRM::Shells::Base
28
26
  end
29
27
 
30
28
  def out_streams
31
- %w(std)
29
+ %w[std]
32
30
  end
33
31
  end
34
32
 
@@ -47,7 +45,8 @@ describe DummyShell do
47
45
 
48
46
  before do
49
47
  allow(subject).to receive(:response_reader).and_return(reader)
50
- allow(subject).to receive(:command_output_message).with(shell_id, command_id)
48
+ allow(subject).to receive(:command_output_message)
49
+ .with(shell_id, command_id)
51
50
  .and_return(output_message)
52
51
  allow(reader).to receive(:read_output).with(output_message).and_return(output)
53
52
  allow(transport).to receive(:send_request)
@@ -144,6 +143,7 @@ describe DummyShell do
144
143
  allow(subject).to receive(:send_command) do
145
144
  @times_called += 1
146
145
  raise WinRM::WinRMWSManFault.new('oops', fault) if @times_called == 1
146
+
147
147
  command_id
148
148
  end
149
149
  end
@@ -179,13 +179,15 @@ describe DummyShell do
179
179
 
180
180
  it 'retries and returns shell on success' do
181
181
  @times = 0
182
- allow(subject).to receive(:command_output_message).with('shell_id 2', command_id)
182
+ allow(subject).to receive(:command_output_message)
183
+ .with('shell_id 2', command_id)
183
184
  .and_return(output_message2)
184
185
  allow(reader).to receive(:read_output)
185
186
  .with(output_message2).and_return(output)
186
187
  allow(subject).to receive(:open_shell) do
187
188
  @times += 1
188
189
  raise(Errno::ECONNREFUSED) if @times == 1
190
+
189
191
  "shell_id #{@times}"
190
192
  end
191
193
 
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'winrm/shells/cmd'
4
2
 
5
3
  describe WinRM::Shells::Cmd do
@@ -24,9 +22,11 @@ describe WinRM::Shells::Cmd do
24
22
  .and_return(cleanup_payload)
25
23
  allow_any_instance_of(WinRM::WSMV::ReceiveResponseReader).to receive(:read_output)
26
24
  .and_return(output)
27
- allow(transport).to receive(:send_request).with(create_shell_payload)
25
+ allow(transport).to receive(:send_request)
26
+ .with(create_shell_payload)
28
27
  .and_return(REXML::Document.new("<blah Name='ShellId'>#{shell_id}</blah>"))
29
- allow(transport).to receive(:send_request).with(/#{command}/)
28
+ allow(transport).to receive(:send_request)
29
+ .with(/#{command}/)
30
30
  .and_return(REXML::Document.new(command_response))
31
31
  end
32
32