winrm 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +10 -10
  3. data/.rubocop.yml +26 -26
  4. data/.travis.yml +11 -11
  5. data/Gemfile +3 -3
  6. data/README.md +263 -260
  7. data/Rakefile +34 -34
  8. data/Vagrantfile +6 -6
  9. data/WinrmAppveyor.psm1 +31 -31
  10. data/appveyor.yml +51 -51
  11. data/changelog.md +107 -104
  12. data/lib/winrm.rb +39 -39
  13. data/lib/winrm/connection.rb +83 -83
  14. data/lib/winrm/connection_opts.rb +91 -91
  15. data/lib/winrm/exceptions.rb +76 -76
  16. data/lib/winrm/http/response_handler.rb +96 -96
  17. data/lib/winrm/http/transport.rb +424 -424
  18. data/lib/winrm/http/transport_factory.rb +68 -68
  19. data/lib/winrm/output.rb +59 -59
  20. data/lib/winrm/psrp/create_pipeline.xml.erb +167 -167
  21. data/lib/winrm/psrp/fragment.rb +70 -70
  22. data/lib/winrm/psrp/init_runspace_pool.xml.erb +224 -224
  23. data/lib/winrm/psrp/message.rb +130 -130
  24. data/lib/winrm/psrp/message_data.rb +42 -42
  25. data/lib/winrm/psrp/message_data/base.rb +49 -49
  26. data/lib/winrm/psrp/message_data/error_record.rb +68 -68
  27. data/lib/winrm/psrp/message_data/pipeline_host_call.rb +32 -32
  28. data/lib/winrm/psrp/message_data/pipeline_output.rb +54 -49
  29. data/lib/winrm/psrp/message_data/pipeline_state.rb +40 -40
  30. data/lib/winrm/psrp/message_data/runspacepool_host_call.rb +32 -32
  31. data/lib/winrm/psrp/message_data/runspacepool_state.rb +39 -39
  32. data/lib/winrm/psrp/message_data/session_capability.rb +36 -36
  33. data/lib/winrm/psrp/message_defragmenter.rb +62 -62
  34. data/lib/winrm/psrp/message_factory.rb +75 -75
  35. data/lib/winrm/psrp/message_fragmenter.rb +60 -60
  36. data/lib/winrm/psrp/powershell_output_decoder.rb +144 -139
  37. data/lib/winrm/psrp/receive_response_reader.rb +97 -97
  38. data/lib/winrm/psrp/session_capability.xml.erb +7 -7
  39. data/lib/winrm/psrp/uuid.rb +40 -40
  40. data/lib/winrm/shells/base.rb +180 -180
  41. data/lib/winrm/shells/cmd.rb +65 -65
  42. data/lib/winrm/shells/power_shell.rb +202 -202
  43. data/lib/winrm/shells/retryable.rb +45 -45
  44. data/lib/winrm/shells/shell_factory.rb +58 -58
  45. data/lib/winrm/version.rb +7 -7
  46. data/lib/winrm/wsmv/base.rb +59 -59
  47. data/lib/winrm/wsmv/cleanup_command.rb +61 -61
  48. data/lib/winrm/wsmv/close_shell.rb +50 -50
  49. data/lib/winrm/wsmv/command.rb +101 -101
  50. data/lib/winrm/wsmv/command_output.rb +76 -76
  51. data/lib/winrm/wsmv/command_output_decoder.rb +55 -55
  52. data/lib/winrm/wsmv/configuration.rb +46 -46
  53. data/lib/winrm/wsmv/create_pipeline.rb +66 -66
  54. data/lib/winrm/wsmv/create_shell.rb +119 -119
  55. data/lib/winrm/wsmv/header.rb +203 -203
  56. data/lib/winrm/wsmv/init_runspace_pool.rb +95 -95
  57. data/lib/winrm/wsmv/iso8601_duration.rb +60 -60
  58. data/lib/winrm/wsmv/keep_alive.rb +68 -68
  59. data/lib/winrm/wsmv/receive_response_reader.rb +126 -126
  60. data/lib/winrm/wsmv/send_data.rb +68 -68
  61. data/lib/winrm/wsmv/soap.rb +51 -51
  62. data/lib/winrm/wsmv/wql_query.rb +79 -79
  63. data/lib/winrm/wsmv/write_stdin.rb +88 -88
  64. data/tests/integration/auth_timeout_spec.rb +18 -18
  65. data/tests/integration/cmd_spec.rb +131 -131
  66. data/tests/integration/config-example.yml +16 -16
  67. data/tests/integration/issue_59_spec.rb +26 -26
  68. data/tests/integration/powershell_spec.rb +165 -165
  69. data/tests/integration/spec_helper.rb +65 -65
  70. data/tests/integration/transport_spec.rb +99 -99
  71. data/tests/integration/wql_spec.rb +16 -16
  72. data/tests/matchers.rb +60 -60
  73. data/tests/spec/configuration_spec.rb +184 -184
  74. data/tests/spec/connection_spec.rb +39 -39
  75. data/tests/spec/exception_spec.rb +50 -50
  76. data/tests/spec/http/transport_factory_spec.rb +68 -68
  77. data/tests/spec/http/transport_spec.rb +44 -44
  78. data/tests/spec/output_spec.rb +127 -127
  79. data/tests/spec/psrp/fragment_spec.rb +62 -62
  80. data/tests/spec/psrp/message_data/base_spec.rb +13 -13
  81. data/tests/spec/psrp/message_data/error_record_spec.rb +41 -41
  82. data/tests/spec/psrp/message_data/pipeline_host_call_spec.rb +25 -25
  83. data/tests/spec/psrp/message_data/pipeline_output_spec.rb +32 -32
  84. data/tests/spec/psrp/message_data/pipeline_state_spec.rb +40 -40
  85. data/tests/spec/psrp/message_data/runspace_pool_host_call_spec.rb +25 -25
  86. data/tests/spec/psrp/message_data/runspacepool_state_spec.rb +16 -16
  87. data/tests/spec/psrp/message_data/session_capability_spec.rb +30 -30
  88. data/tests/spec/psrp/message_data_spec.rb +35 -35
  89. data/tests/spec/psrp/message_defragmenter_spec.rb +47 -47
  90. data/tests/spec/psrp/message_fragmenter_spec.rb +105 -105
  91. data/tests/spec/psrp/powershell_output_decoder_spec.rb +100 -100
  92. data/tests/spec/psrp/psrp_message_spec.rb +70 -70
  93. data/tests/spec/psrp/recieve_response_reader_spec.rb +172 -172
  94. data/tests/spec/psrp/uuid_spec.rb +28 -28
  95. data/tests/spec/response_handler_spec.rb +61 -61
  96. data/tests/spec/shells/base_spec.rb +202 -202
  97. data/tests/spec/shells/cmd_spec.rb +75 -75
  98. data/tests/spec/shells/powershell_spec.rb +175 -175
  99. data/tests/spec/spec_helper.rb +47 -47
  100. data/tests/spec/stubs/clixml/error_record.xml.erb +84 -84
  101. data/tests/spec/stubs/clixml/pipeline_state.xml.erb +88 -88
  102. data/tests/spec/stubs/responses/get_command_output_response.xml.erb +13 -13
  103. data/tests/spec/stubs/responses/get_command_output_response_not_done.xml.erb +10 -10
  104. data/tests/spec/stubs/responses/get_powershell_keepalive_response.xml.erb +10 -10
  105. data/tests/spec/stubs/responses/get_powershell_output_response.xml.erb +12 -12
  106. data/tests/spec/stubs/responses/get_powershell_output_response_not_done.xml.erb +9 -9
  107. data/tests/spec/stubs/responses/open_shell_v1.xml +19 -19
  108. data/tests/spec/stubs/responses/open_shell_v2.xml +20 -20
  109. data/tests/spec/stubs/responses/soap_fault_v1.xml +36 -36
  110. data/tests/spec/stubs/responses/soap_fault_v2.xml +42 -42
  111. data/tests/spec/stubs/responses/wmi_error_v2.xml +41 -41
  112. data/tests/spec/wsmv/cleanup_command_spec.rb +22 -22
  113. data/tests/spec/wsmv/close_shell_spec.rb +17 -17
  114. data/tests/spec/wsmv/command_output_decoder_spec.rb +37 -37
  115. data/tests/spec/wsmv/command_output_spec.rb +45 -45
  116. data/tests/spec/wsmv/command_spec.rb +19 -19
  117. data/tests/spec/wsmv/configuration_spec.rb +17 -17
  118. data/tests/spec/wsmv/create_pipeline_spec.rb +31 -31
  119. data/tests/spec/wsmv/create_shell_spec.rb +38 -38
  120. data/tests/spec/wsmv/init_runspace_pool_spec.rb +36 -36
  121. data/tests/spec/wsmv/keep_alive_spec.rb +21 -21
  122. data/tests/spec/wsmv/receive_response_reader_spec.rb +123 -123
  123. data/tests/spec/wsmv/send_data_spec.rb +30 -30
  124. data/tests/spec/wsmv/wql_query_spec.rb +13 -13
  125. data/tests/spec/wsmv/write_stdin_spec.rb +22 -22
  126. data/winrm.gemspec +47 -42
  127. metadata +7 -3
@@ -1,62 +1,62 @@
1
- # encoding: UTF-8
2
-
3
- require 'winrm/psrp/fragment'
4
-
5
- describe WinRM::PSRP::Fragment do
6
- let(:id) { 1 }
7
- let(:message) { 'blah blah blah' }
8
-
9
- context 'called with just id and blob' do
10
- subject { described_class.new(id, message.bytes) }
11
-
12
- it 'sets the message id to 1' do
13
- expect(subject.bytes[0..7]).to eq([0, 0, 0, 0, 0, 0, 0, id])
14
- end
15
- it 'sets the fragment id to 0' do
16
- expect(subject.bytes[8..15]).to eq([0, 0, 0, 0, 0, 0, 0, 0])
17
- end
18
- it 'sets the last 2 bits of the end/start fragment' do
19
- expect(subject.bytes[16]).to eq(3)
20
- end
21
- it 'sets message blob length to 3640' do
22
- expect(subject.bytes[17..20]).to eq([0, 0, 0, message.bytes.length])
23
- end
24
- it 'sets message blob' do
25
- expect(subject.bytes[21..-1]).to eq(message.bytes)
26
- end
27
- end
28
-
29
- context 'specifying a fragment id' do
30
- let(:fragment_id) { 1 }
31
-
32
- subject { described_class.new(id, message.bytes, fragment_id) }
33
-
34
- it 'sets the fragment id' do
35
- expect(subject.bytes[8..15]).to eq([0, 0, 0, 0, 0, 0, 0, fragment_id])
36
- end
37
- end
38
-
39
- context 'middle fragment' do
40
- subject { described_class.new(id, message.bytes, 1, false, false) }
41
-
42
- it 'sets the last 2 bits of the end/start fragment to 0' do
43
- expect(subject.bytes[16]).to eq(0)
44
- end
45
- end
46
-
47
- context 'end fragment' do
48
- subject { described_class.new(id, message.bytes, 1, true, false) }
49
-
50
- it 'sets the end fragment bit' do
51
- expect(subject.bytes[16]).to eq(1)
52
- end
53
- end
54
-
55
- context 'start fragment' do
56
- subject { described_class.new(id, message.bytes, 1, false, true) }
57
-
58
- it 'sets the start fragment bit' do
59
- expect(subject.bytes[16]).to eq(2)
60
- end
61
- end
62
- end
1
+ # encoding: UTF-8
2
+
3
+ require 'winrm/psrp/fragment'
4
+
5
+ describe WinRM::PSRP::Fragment do
6
+ let(:id) { 1 }
7
+ let(:message) { 'blah blah blah' }
8
+
9
+ context 'called with just id and blob' do
10
+ subject { described_class.new(id, message.bytes) }
11
+
12
+ it 'sets the message id to 1' do
13
+ expect(subject.bytes[0..7]).to eq([0, 0, 0, 0, 0, 0, 0, id])
14
+ end
15
+ it 'sets the fragment id to 0' do
16
+ expect(subject.bytes[8..15]).to eq([0, 0, 0, 0, 0, 0, 0, 0])
17
+ end
18
+ it 'sets the last 2 bits of the end/start fragment' do
19
+ expect(subject.bytes[16]).to eq(3)
20
+ end
21
+ it 'sets message blob length to 3640' do
22
+ expect(subject.bytes[17..20]).to eq([0, 0, 0, message.bytes.length])
23
+ end
24
+ it 'sets message blob' do
25
+ expect(subject.bytes[21..-1]).to eq(message.bytes)
26
+ end
27
+ end
28
+
29
+ context 'specifying a fragment id' do
30
+ let(:fragment_id) { 1 }
31
+
32
+ subject { described_class.new(id, message.bytes, fragment_id) }
33
+
34
+ it 'sets the fragment id' do
35
+ expect(subject.bytes[8..15]).to eq([0, 0, 0, 0, 0, 0, 0, fragment_id])
36
+ end
37
+ end
38
+
39
+ context 'middle fragment' do
40
+ subject { described_class.new(id, message.bytes, 1, false, false) }
41
+
42
+ it 'sets the last 2 bits of the end/start fragment to 0' do
43
+ expect(subject.bytes[16]).to eq(0)
44
+ end
45
+ end
46
+
47
+ context 'end fragment' do
48
+ subject { described_class.new(id, message.bytes, 1, true, false) }
49
+
50
+ it 'sets the end fragment bit' do
51
+ expect(subject.bytes[16]).to eq(1)
52
+ end
53
+ end
54
+
55
+ context 'start fragment' do
56
+ subject { described_class.new(id, message.bytes, 1, false, true) }
57
+
58
+ it 'sets the start fragment bit' do
59
+ expect(subject.bytes[16]).to eq(2)
60
+ end
61
+ end
62
+ end
@@ -1,13 +1,13 @@
1
- # encoding: UTF-8
2
-
3
- require 'winrm/psrp/message_data/base'
4
-
5
- describe WinRM::PSRP::MessageData::Base do
6
- let(:raw_data) { 'raw_data' }
7
-
8
- subject { WinRM::PSRP::MessageData::Base.new(raw_data) }
9
-
10
- it 'holds raw message data' do
11
- expect(subject.raw).to eq(raw_data)
12
- end
13
- end
1
+ # encoding: UTF-8
2
+
3
+ require 'winrm/psrp/message_data/base'
4
+
5
+ describe WinRM::PSRP::MessageData::Base do
6
+ let(:raw_data) { 'raw_data' }
7
+
8
+ subject { WinRM::PSRP::MessageData::Base.new(raw_data) }
9
+
10
+ it 'holds raw message data' do
11
+ expect(subject.raw).to eq(raw_data)
12
+ end
13
+ end
@@ -1,41 +1,41 @@
1
- # encoding: UTF-8
2
-
3
- require 'winrm/psrp/message_data/base'
4
- require 'winrm/psrp/message_data/error_record'
5
-
6
- describe WinRM::PSRP::MessageData::ErrorRecord do
7
- let(:test_data_xml_template) do
8
- ERB.new(stubbed_clixml('error_record.xml.erb'))
9
- end
10
- let(:error_message) { 'an error' }
11
- let(:script_root) { 'script_root' }
12
- let(:category_message) { 'category message' }
13
- let(:stack_trace) { 'stack trace' }
14
- let(:error_id) { 'Microsoft.PowerShell.Commands.WriteErrorException' }
15
- let(:raw_data) { test_data_xml_template.result(binding) }
16
- subject { described_class.new(raw_data) }
17
-
18
- it 'returns the exception' do
19
- expect(subject.exception[:message]).to eq(error_message)
20
- end
21
-
22
- it 'returns the FullyQualifiedErrorId' do
23
- expect(subject.fully_qualified_error_id).to eq(error_id)
24
- end
25
-
26
- it 'returns the invocation info' do
27
- expect(subject.invocation_info[:line]).to eq("write-error '#{error_message}'")
28
- end
29
-
30
- it 'converts camel case properties to underscore' do
31
- expect(subject.invocation_info[:ps_script_root]).to eq(script_root)
32
- end
33
-
34
- it 'returns the error category message' do
35
- expect(subject.error_category_message).to eq(category_message)
36
- end
37
-
38
- it 'returns the script stack trace' do
39
- expect(subject.error_details_script_stack_trace).to eq(stack_trace)
40
- end
41
- end
1
+ # encoding: UTF-8
2
+
3
+ require 'winrm/psrp/message_data/base'
4
+ require 'winrm/psrp/message_data/error_record'
5
+
6
+ describe WinRM::PSRP::MessageData::ErrorRecord do
7
+ let(:test_data_xml_template) do
8
+ ERB.new(stubbed_clixml('error_record.xml.erb'))
9
+ end
10
+ let(:error_message) { 'an error' }
11
+ let(:script_root) { 'script_root' }
12
+ let(:category_message) { 'category message' }
13
+ let(:stack_trace) { 'stack trace' }
14
+ let(:error_id) { 'Microsoft.PowerShell.Commands.WriteErrorException' }
15
+ let(:raw_data) { test_data_xml_template.result(binding) }
16
+ subject { described_class.new(raw_data) }
17
+
18
+ it 'returns the exception' do
19
+ expect(subject.exception[:message]).to eq(error_message)
20
+ end
21
+
22
+ it 'returns the FullyQualifiedErrorId' do
23
+ expect(subject.fully_qualified_error_id).to eq(error_id)
24
+ end
25
+
26
+ it 'returns the invocation info' do
27
+ expect(subject.invocation_info[:line]).to eq("write-error '#{error_message}'")
28
+ end
29
+
30
+ it 'converts camel case properties to underscore' do
31
+ expect(subject.invocation_info[:ps_script_root]).to eq(script_root)
32
+ end
33
+
34
+ it 'returns the error category message' do
35
+ expect(subject.error_category_message).to eq(category_message)
36
+ end
37
+
38
+ it 'returns the script stack trace' do
39
+ expect(subject.error_details_script_stack_trace).to eq(stack_trace)
40
+ end
41
+ end
@@ -1,25 +1,25 @@
1
- # encoding: UTF-8
2
-
3
- require 'winrm/psrp/message_data/base'
4
- require 'winrm/psrp/message_data/pipeline_host_call'
5
-
6
- describe WinRM::PSRP::MessageData::PipelineHostCall do
7
- let(:raw_data) do
8
- "\xEF\xBB\xBF<Obj RefId=\"0\"><MS><I64 N=\"ci\">-100</I64><Obj N=\"mi\" RefId=\"1\">"\
9
- '<TN RefId="0"><T>System.Management.Automation.Remoting.RemoteHostMethodId</T>'\
10
- '<T>System.Enum</T><T>System.ValueType</T><T>System.Object</T></TN>'\
11
- '<ToString>WriteLine3</ToString><I32>17</I32></Obj><Obj N="mp" RefId="2">'\
12
- '<TN RefId="1"><T>System.Collections.ArrayList</T><T>System.Object</T></TN><LST>'\
13
- '<I32>7</I32><I32>0</I32><S>hello</S></LST></Obj></MS></Obj>'
14
- end
15
-
16
- subject { described_class.new(raw_data) }
17
-
18
- it 'parses method identifier' do
19
- expect(subject.method_identifier).to eq('WriteLine3')
20
- end
21
-
22
- it 'parses method parameters' do
23
- expect(subject.method_parameters[:s]).to eq('hello')
24
- end
25
- end
1
+ # encoding: UTF-8
2
+
3
+ require 'winrm/psrp/message_data/base'
4
+ require 'winrm/psrp/message_data/pipeline_host_call'
5
+
6
+ describe WinRM::PSRP::MessageData::PipelineHostCall do
7
+ let(:raw_data) do
8
+ "\xEF\xBB\xBF<Obj RefId=\"0\"><MS><I64 N=\"ci\">-100</I64><Obj N=\"mi\" RefId=\"1\">"\
9
+ '<TN RefId="0"><T>System.Management.Automation.Remoting.RemoteHostMethodId</T>'\
10
+ '<T>System.Enum</T><T>System.ValueType</T><T>System.Object</T></TN>'\
11
+ '<ToString>WriteLine3</ToString><I32>17</I32></Obj><Obj N="mp" RefId="2">'\
12
+ '<TN RefId="1"><T>System.Collections.ArrayList</T><T>System.Object</T></TN><LST>'\
13
+ '<I32>7</I32><I32>0</I32><S>hello</S></LST></Obj></MS></Obj>'
14
+ end
15
+
16
+ subject { described_class.new(raw_data) }
17
+
18
+ it 'parses method identifier' do
19
+ expect(subject.method_identifier).to eq('WriteLine3')
20
+ end
21
+
22
+ it 'parses method parameters' do
23
+ expect(subject.method_parameters[:s]).to eq('hello')
24
+ end
25
+ end
@@ -1,32 +1,32 @@
1
- # encoding: UTF-8
2
-
3
- require 'winrm/psrp/message_data/base'
4
- require 'winrm/psrp/message_data/pipeline_output'
5
-
6
- describe WinRM::PSRP::MessageData::PipelineOutput do
7
- subject { described_class.new(raw_data) }
8
-
9
- context 'receiving output with BOM and no new line' do
10
- let(:raw_data) { "\xEF\xBB\xBF<obj><S>some data</S></obj>" }
11
-
12
- it 'output removes BOM and adds newline' do
13
- expect(subject.output).to eq("some data\r\n")
14
- end
15
- end
16
-
17
- context 'receiving output with encoded new line' do
18
- let(:raw_data) { '<obj><S>some data_x000D__x000A_</S></obj>' }
19
-
20
- it 'decodes without double newline' do
21
- expect(subject.output).to eq("some data\r\n")
22
- end
23
- end
24
-
25
- context 'receiving output with new line in middle' do
26
- let(:raw_data) { '<obj><S>some_x000D__x000A_data</S></obj>' }
27
-
28
- it 'decodes and replaces newline' do
29
- expect(subject.output).to eq("some\r\ndata\r\n")
30
- end
31
- end
32
- end
1
+ # encoding: UTF-8
2
+
3
+ require 'winrm/psrp/message_data/base'
4
+ require 'winrm/psrp/message_data/pipeline_output'
5
+
6
+ describe WinRM::PSRP::MessageData::PipelineOutput do
7
+ subject { described_class.new(raw_data) }
8
+
9
+ context 'receiving output with BOM and no new line' do
10
+ let(:raw_data) { "\xEF\xBB\xBF<obj><S>some data</S></obj>" }
11
+
12
+ it 'output removes BOM and adds newline' do
13
+ expect(subject.output).to eq("some data\r\n")
14
+ end
15
+ end
16
+
17
+ context 'receiving output with encoded new line' do
18
+ let(:raw_data) { '<obj><S>some data_x000D__x000A_</S></obj>' }
19
+
20
+ it 'decodes without double newline' do
21
+ expect(subject.output).to eq("some data\r\n")
22
+ end
23
+ end
24
+
25
+ context 'receiving output with new line in middle' do
26
+ let(:raw_data) { '<obj><S>some_x000D__x000A_data</S></obj>' }
27
+
28
+ it 'decodes and replaces newline' do
29
+ expect(subject.output).to eq("some\r\ndata\r\n")
30
+ end
31
+ end
32
+ end
@@ -1,40 +1,40 @@
1
- # encoding: UTF-8
2
-
3
- require 'winrm/psrp/message_data/base'
4
- require 'winrm/psrp/message_data/pipeline_state'
5
-
6
- describe WinRM::PSRP::MessageData::PipelineState do
7
- let(:test_data_xml_template) do
8
- ERB.new(stubbed_clixml('pipeline_state.xml.erb'))
9
- end
10
- let(:pipeline_state) { WinRM::PSRP::MessageData::PipelineState::FAILED }
11
- let(:error_message) { 'an error occured' }
12
- let(:category_message) { 'category message' }
13
- let(:error_id) { 'an error occured' }
14
- let(:raw_data) { test_data_xml_template.result(binding) }
15
- subject { described_class.new(raw_data) }
16
-
17
- it 'returns the state' do
18
- expect(subject.pipeline_state).to eq(pipeline_state)
19
- end
20
-
21
- it 'returns the exception' do
22
- expect(subject.exception_as_error_record.exception[:message]).to eq(error_message)
23
- end
24
-
25
- it 'returns the FullyQualifiedErrorId' do
26
- expect(subject.exception_as_error_record.fully_qualified_error_id).to eq(error_id)
27
- end
28
-
29
- it 'returns the error category message' do
30
- expect(subject.exception_as_error_record.error_category_message).to eq(category_message)
31
- end
32
-
33
- context 'state is not failed' do
34
- let(:pipeline_state) { WinRM::PSRP::MessageData::PipelineState::COMPLETED }
35
-
36
- it 'has a nil exception' do
37
- expect(subject.exception_as_error_record).to be(nil)
38
- end
39
- end
40
- end
1
+ # encoding: UTF-8
2
+
3
+ require 'winrm/psrp/message_data/base'
4
+ require 'winrm/psrp/message_data/pipeline_state'
5
+
6
+ describe WinRM::PSRP::MessageData::PipelineState do
7
+ let(:test_data_xml_template) do
8
+ ERB.new(stubbed_clixml('pipeline_state.xml.erb'))
9
+ end
10
+ let(:pipeline_state) { WinRM::PSRP::MessageData::PipelineState::FAILED }
11
+ let(:error_message) { 'an error occured' }
12
+ let(:category_message) { 'category message' }
13
+ let(:error_id) { 'an error occured' }
14
+ let(:raw_data) { test_data_xml_template.result(binding) }
15
+ subject { described_class.new(raw_data) }
16
+
17
+ it 'returns the state' do
18
+ expect(subject.pipeline_state).to eq(pipeline_state)
19
+ end
20
+
21
+ it 'returns the exception' do
22
+ expect(subject.exception_as_error_record.exception[:message]).to eq(error_message)
23
+ end
24
+
25
+ it 'returns the FullyQualifiedErrorId' do
26
+ expect(subject.exception_as_error_record.fully_qualified_error_id).to eq(error_id)
27
+ end
28
+
29
+ it 'returns the error category message' do
30
+ expect(subject.exception_as_error_record.error_category_message).to eq(category_message)
31
+ end
32
+
33
+ context 'state is not failed' do
34
+ let(:pipeline_state) { WinRM::PSRP::MessageData::PipelineState::COMPLETED }
35
+
36
+ it 'has a nil exception' do
37
+ expect(subject.exception_as_error_record).to be(nil)
38
+ end
39
+ end
40
+ end
@@ -1,25 +1,25 @@
1
- # encoding: UTF-8
2
-
3
- require 'winrm/psrp/message_data/base'
4
- require 'winrm/psrp/message_data/runspacepool_host_call'
5
-
6
- describe WinRM::PSRP::MessageData::RunspacepoolHostCall do
7
- let(:raw_data) do
8
- "\xEF\xBB\xBF<Obj RefId=\"0\"><MS><I64 N=\"ci\">-100</I64><Obj N=\"mi\" RefId=\"1\">"\
9
- '<TN RefId="0"><T>System.Management.Automation.Remoting.RemoteHostMethodId</T>'\
10
- '<T>System.Enum</T><T>System.ValueType</T><T>System.Object</T></TN>'\
11
- '<ToString>WriteLine3</ToString><I32>17</I32></Obj><Obj N="mp" RefId="2">'\
12
- '<TN RefId="1"><T>System.Collections.ArrayList</T><T>System.Object</T></TN><LST>'\
13
- '<I32>7</I32><I32>0</I32><S>hello</S></LST></Obj></MS></Obj>'
14
- end
15
-
16
- subject { described_class.new(raw_data) }
17
-
18
- it 'parses method identifier' do
19
- expect(subject.method_identifier).to eq('WriteLine3')
20
- end
21
-
22
- it 'parses method parameters' do
23
- expect(subject.method_parameters[:s]).to eq('hello')
24
- end
25
- end
1
+ # encoding: UTF-8
2
+
3
+ require 'winrm/psrp/message_data/base'
4
+ require 'winrm/psrp/message_data/runspacepool_host_call'
5
+
6
+ describe WinRM::PSRP::MessageData::RunspacepoolHostCall do
7
+ let(:raw_data) do
8
+ "\xEF\xBB\xBF<Obj RefId=\"0\"><MS><I64 N=\"ci\">-100</I64><Obj N=\"mi\" RefId=\"1\">"\
9
+ '<TN RefId="0"><T>System.Management.Automation.Remoting.RemoteHostMethodId</T>'\
10
+ '<T>System.Enum</T><T>System.ValueType</T><T>System.Object</T></TN>'\
11
+ '<ToString>WriteLine3</ToString><I32>17</I32></Obj><Obj N="mp" RefId="2">'\
12
+ '<TN RefId="1"><T>System.Collections.ArrayList</T><T>System.Object</T></TN><LST>'\
13
+ '<I32>7</I32><I32>0</I32><S>hello</S></LST></Obj></MS></Obj>'
14
+ end
15
+
16
+ subject { described_class.new(raw_data) }
17
+
18
+ it 'parses method identifier' do
19
+ expect(subject.method_identifier).to eq('WriteLine3')
20
+ end
21
+
22
+ it 'parses method parameters' do
23
+ expect(subject.method_parameters[:s]).to eq('hello')
24
+ end
25
+ end