winrm 2.0.3 → 2.1.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 (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 +260 -233
  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 +104 -101
  12. data/lib/winrm.rb +39 -39
  13. data/lib/winrm/connection.rb +83 -82
  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 +49 -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 +139 -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 -175
  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 -50
  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 -110
  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 +42 -42
  127. metadata +2 -2
@@ -1,184 +1,184 @@
1
- # encoding: UTF-8
2
- require 'winrm/connection_opts'
3
-
4
- describe WinRM::ConnectionOpts do
5
- shared_examples 'invalid options' do
6
- it 'throws a validation error' do
7
- expect { WinRM::ConnectionOpts.create_with_defaults(overrides) }.to raise_error
8
- end
9
- end
10
-
11
- context 'when there are no overrides' do
12
- it_behaves_like 'invalid options'
13
- end
14
-
15
- context 'when there are only username and password' do
16
- let(:overrides) do
17
- {
18
- user: 'Administrator',
19
- password: 'password'
20
- }
21
- end
22
-
23
- it_behaves_like 'invalid options'
24
- end
25
-
26
- context 'when there are only username and endpoint' do
27
- let(:overrides) do
28
- {
29
- user: 'Administrator',
30
- endpoint: 'http://localhost:5985/wsman'
31
- }
32
- end
33
-
34
- it_behaves_like 'invalid options'
35
- end
36
-
37
- context 'when there are only password and endpoint' do
38
- let(:overrides) do
39
- {
40
- password: 'password',
41
- endpoint: 'http://localhost:5985/wsman'
42
- }
43
- end
44
-
45
- it_behaves_like 'invalid options'
46
- end
47
-
48
- context 'when there are only certificate and key' do
49
- let(:overrides) do
50
- {
51
- client_cert: 'path/to/cert',
52
- client_key: 'path/to/key'
53
- }
54
- end
55
-
56
- it_behaves_like 'invalid options'
57
- end
58
-
59
- context 'when there are only certificate and endpoint' do
60
- let(:overrides) do
61
- {
62
- client_cert: 'path/to/cert',
63
- endpoint: 'http://localhost:5985/wsman'
64
- }
65
- end
66
-
67
- it_behaves_like 'invalid options'
68
- end
69
-
70
- context 'when there are only key and endpoint' do
71
- let(:overrides) do
72
- {
73
- client_key: 'path/to/key',
74
- endpoint: 'http://localhost:5985/wsman'
75
- }
76
- end
77
-
78
- it_behaves_like 'invalid options'
79
- end
80
-
81
- context 'when username, password, and endpoint are given' do
82
- let(:overrides) do
83
- {
84
- user: 'Administrator',
85
- password: 'password',
86
- endpoint: 'http://localhost:5985/wsman'
87
- }
88
- end
89
- describe '#create_with_defaults' do
90
- it 'creates a ConnectionOpts object' do
91
- config = WinRM::ConnectionOpts.create_with_defaults(overrides)
92
- expect(config[:user]).to eq(overrides[:user])
93
- expect(config[:password]).to eq(overrides[:password])
94
- expect(config[:endpoint]).to eq(overrides[:endpoint])
95
- end
96
- end
97
- end
98
-
99
- context 'when certificate, key and endpoint are given' do
100
- let(:overrides) do
101
- {
102
- client_cert: 'path/to/cert',
103
- client_key: 'path/to/key',
104
- endpoint: 'http://localhost:5985/wsman'
105
- }
106
- end
107
- describe '#create_with_defaults' do
108
- it 'creates a ConnectionOpts object' do
109
- config = WinRM::ConnectionOpts.create_with_defaults(overrides)
110
- expect(config[:client_cert]).to eq(overrides[:client_cert])
111
- expect(config[:client_key]).to eq(overrides[:client_key])
112
- expect(config[:endpoint]).to eq(overrides[:endpoint])
113
- end
114
- end
115
- end
116
-
117
- context 'when overrides are provided' do
118
- let(:overrides) do
119
- {
120
- user: 'Administrator',
121
- password: 'password',
122
- endpoint: 'http://localhost:5985/wsman',
123
- transport: :ssl
124
- }
125
- end
126
- describe '#create_with_defaults' do
127
- it 'creates a ConnectionOpts object with overrides' do
128
- config = WinRM::ConnectionOpts.create_with_defaults(overrides)
129
- expect(config[:transport]).to eq(overrides[:transport])
130
- end
131
- end
132
- end
133
-
134
- context 'when receive_timeout is specified' do
135
- let(:overrides) do
136
- {
137
- user: 'Administrator',
138
- password: 'password',
139
- endpoint: 'http://localhost:5985/wsman',
140
- receive_timeout: 120
141
- }
142
- end
143
- describe '#create_with_defaults' do
144
- it 'creates a ConnectionOpts object with the correct receive_timeout' do
145
- config = WinRM::ConnectionOpts.create_with_defaults(overrides)
146
- expect(config[:receive_timeout]).to eq(overrides[:receive_timeout])
147
- end
148
- end
149
- end
150
-
151
- context 'when operation_timeout is specified' do
152
- let(:overrides) do
153
- {
154
- user: 'Administrator',
155
- password: 'password',
156
- endpoint: 'http://localhost:5985/wsman',
157
- operation_timeout: 120
158
- }
159
- end
160
- describe '#create_with_defaults' do
161
- it 'creates a ConnectionOpts object with the correct timeouts' do
162
- config = WinRM::ConnectionOpts.create_with_defaults(overrides)
163
- expect(config[:operation_timeout]).to eq(overrides[:operation_timeout])
164
- expect(config[:receive_timeout]).to eq(overrides[:operation_timeout] + 10)
165
- end
166
- end
167
- end
168
-
169
- context 'when invalid data types are given' do
170
- let(:overrides) do
171
- {
172
- user: 'Administrator',
173
- password: 'password',
174
- endpoint: 'http://localhost:5985/wsman',
175
- operation_timeout: 'PT60S'
176
- }
177
- end
178
- describe '#create_with_defaults' do
179
- it 'raises an error' do
180
- expect { WinRM::ConnectionOpts.create_with_defaults(overrides) }.to raise_error
181
- end
182
- end
183
- end
184
- end
1
+ # encoding: UTF-8
2
+ require 'winrm/connection_opts'
3
+
4
+ describe WinRM::ConnectionOpts do
5
+ shared_examples 'invalid options' do
6
+ it 'throws a validation error' do
7
+ expect { WinRM::ConnectionOpts.create_with_defaults(overrides) }.to raise_error
8
+ end
9
+ end
10
+
11
+ context 'when there are no overrides' do
12
+ it_behaves_like 'invalid options'
13
+ end
14
+
15
+ context 'when there are only username and password' do
16
+ let(:overrides) do
17
+ {
18
+ user: 'Administrator',
19
+ password: 'password'
20
+ }
21
+ end
22
+
23
+ it_behaves_like 'invalid options'
24
+ end
25
+
26
+ context 'when there are only username and endpoint' do
27
+ let(:overrides) do
28
+ {
29
+ user: 'Administrator',
30
+ endpoint: 'http://localhost:5985/wsman'
31
+ }
32
+ end
33
+
34
+ it_behaves_like 'invalid options'
35
+ end
36
+
37
+ context 'when there are only password and endpoint' do
38
+ let(:overrides) do
39
+ {
40
+ password: 'password',
41
+ endpoint: 'http://localhost:5985/wsman'
42
+ }
43
+ end
44
+
45
+ it_behaves_like 'invalid options'
46
+ end
47
+
48
+ context 'when there are only certificate and key' do
49
+ let(:overrides) do
50
+ {
51
+ client_cert: 'path/to/cert',
52
+ client_key: 'path/to/key'
53
+ }
54
+ end
55
+
56
+ it_behaves_like 'invalid options'
57
+ end
58
+
59
+ context 'when there are only certificate and endpoint' do
60
+ let(:overrides) do
61
+ {
62
+ client_cert: 'path/to/cert',
63
+ endpoint: 'http://localhost:5985/wsman'
64
+ }
65
+ end
66
+
67
+ it_behaves_like 'invalid options'
68
+ end
69
+
70
+ context 'when there are only key and endpoint' do
71
+ let(:overrides) do
72
+ {
73
+ client_key: 'path/to/key',
74
+ endpoint: 'http://localhost:5985/wsman'
75
+ }
76
+ end
77
+
78
+ it_behaves_like 'invalid options'
79
+ end
80
+
81
+ context 'when username, password, and endpoint are given' do
82
+ let(:overrides) do
83
+ {
84
+ user: 'Administrator',
85
+ password: 'password',
86
+ endpoint: 'http://localhost:5985/wsman'
87
+ }
88
+ end
89
+ describe '#create_with_defaults' do
90
+ it 'creates a ConnectionOpts object' do
91
+ config = WinRM::ConnectionOpts.create_with_defaults(overrides)
92
+ expect(config[:user]).to eq(overrides[:user])
93
+ expect(config[:password]).to eq(overrides[:password])
94
+ expect(config[:endpoint]).to eq(overrides[:endpoint])
95
+ end
96
+ end
97
+ end
98
+
99
+ context 'when certificate, key and endpoint are given' do
100
+ let(:overrides) do
101
+ {
102
+ client_cert: 'path/to/cert',
103
+ client_key: 'path/to/key',
104
+ endpoint: 'http://localhost:5985/wsman'
105
+ }
106
+ end
107
+ describe '#create_with_defaults' do
108
+ it 'creates a ConnectionOpts object' do
109
+ config = WinRM::ConnectionOpts.create_with_defaults(overrides)
110
+ expect(config[:client_cert]).to eq(overrides[:client_cert])
111
+ expect(config[:client_key]).to eq(overrides[:client_key])
112
+ expect(config[:endpoint]).to eq(overrides[:endpoint])
113
+ end
114
+ end
115
+ end
116
+
117
+ context 'when overrides are provided' do
118
+ let(:overrides) do
119
+ {
120
+ user: 'Administrator',
121
+ password: 'password',
122
+ endpoint: 'http://localhost:5985/wsman',
123
+ transport: :ssl
124
+ }
125
+ end
126
+ describe '#create_with_defaults' do
127
+ it 'creates a ConnectionOpts object with overrides' do
128
+ config = WinRM::ConnectionOpts.create_with_defaults(overrides)
129
+ expect(config[:transport]).to eq(overrides[:transport])
130
+ end
131
+ end
132
+ end
133
+
134
+ context 'when receive_timeout is specified' do
135
+ let(:overrides) do
136
+ {
137
+ user: 'Administrator',
138
+ password: 'password',
139
+ endpoint: 'http://localhost:5985/wsman',
140
+ receive_timeout: 120
141
+ }
142
+ end
143
+ describe '#create_with_defaults' do
144
+ it 'creates a ConnectionOpts object with the correct receive_timeout' do
145
+ config = WinRM::ConnectionOpts.create_with_defaults(overrides)
146
+ expect(config[:receive_timeout]).to eq(overrides[:receive_timeout])
147
+ end
148
+ end
149
+ end
150
+
151
+ context 'when operation_timeout is specified' do
152
+ let(:overrides) do
153
+ {
154
+ user: 'Administrator',
155
+ password: 'password',
156
+ endpoint: 'http://localhost:5985/wsman',
157
+ operation_timeout: 120
158
+ }
159
+ end
160
+ describe '#create_with_defaults' do
161
+ it 'creates a ConnectionOpts object with the correct timeouts' do
162
+ config = WinRM::ConnectionOpts.create_with_defaults(overrides)
163
+ expect(config[:operation_timeout]).to eq(overrides[:operation_timeout])
164
+ expect(config[:receive_timeout]).to eq(overrides[:operation_timeout] + 10)
165
+ end
166
+ end
167
+ end
168
+
169
+ context 'when invalid data types are given' do
170
+ let(:overrides) do
171
+ {
172
+ user: 'Administrator',
173
+ password: 'password',
174
+ endpoint: 'http://localhost:5985/wsman',
175
+ operation_timeout: 'PT60S'
176
+ }
177
+ end
178
+ describe '#create_with_defaults' do
179
+ it 'raises an error' do
180
+ expect { WinRM::ConnectionOpts.create_with_defaults(overrides) }.to raise_error
181
+ end
182
+ end
183
+ end
184
+ end
@@ -1,39 +1,39 @@
1
- # encoding: UTF-8
2
-
3
- require 'winrm'
4
- require 'winrm/shells/cmd'
5
- require 'winrm/shells/power_shell'
6
-
7
- describe WinRM::Connection do
8
- context 'new' do
9
- it 'creates a new winrm session' do
10
- connection = WinRM::Connection.new(default_connection_opts)
11
- expect(connection).not_to be_nil
12
- end
13
- end
14
-
15
- context 'shell(:cmd)' do
16
- it 'creates a new cmd session' do
17
- connection = WinRM::Connection.new(default_connection_opts)
18
- cmd_shell = connection.shell(:cmd)
19
- expect(cmd_shell).not_to be_nil
20
- expect(cmd_shell).to be_an_instance_of(WinRM::Shells::Cmd)
21
- end
22
- end
23
-
24
- context 'shell(:powershell)' do
25
- it 'creates a new powershell session' do
26
- connection = WinRM::Connection.new(default_connection_opts)
27
- cmd_shell = connection.shell(:powershell)
28
- expect(cmd_shell).not_to be_nil
29
- expect(cmd_shell).to be_an_instance_of(WinRM::Shells::Powershell)
30
- end
31
- end
32
-
33
- context 'shell(:not_a_real_shell_type)' do
34
- it 'raises a descriptive error' do
35
- connection = WinRM::Connection.new(default_connection_opts)
36
- expect { connection.shell(:not_a_real_shell_type) }.to raise_error(WinRM::InvalidShellError)
37
- end
38
- end
39
- end
1
+ # encoding: UTF-8
2
+
3
+ require 'winrm'
4
+ require 'winrm/shells/cmd'
5
+ require 'winrm/shells/power_shell'
6
+
7
+ describe WinRM::Connection do
8
+ context 'new' do
9
+ it 'creates a new winrm session' do
10
+ connection = WinRM::Connection.new(default_connection_opts)
11
+ expect(connection).not_to be_nil
12
+ end
13
+ end
14
+
15
+ context 'shell(:cmd)' do
16
+ it 'creates a new cmd session' do
17
+ connection = WinRM::Connection.new(default_connection_opts)
18
+ cmd_shell = connection.shell(:cmd)
19
+ expect(cmd_shell).not_to be_nil
20
+ expect(cmd_shell).to be_an_instance_of(WinRM::Shells::Cmd)
21
+ end
22
+ end
23
+
24
+ context 'shell(:powershell)' do
25
+ it 'creates a new powershell session' do
26
+ connection = WinRM::Connection.new(default_connection_opts)
27
+ cmd_shell = connection.shell(:powershell)
28
+ expect(cmd_shell).not_to be_nil
29
+ expect(cmd_shell).to be_an_instance_of(WinRM::Shells::Powershell)
30
+ end
31
+ end
32
+
33
+ context 'shell(:not_a_real_shell_type)' do
34
+ it 'raises a descriptive error' do
35
+ connection = WinRM::Connection.new(default_connection_opts)
36
+ expect { connection.shell(:not_a_real_shell_type) }.to raise_error(WinRM::InvalidShellError)
37
+ end
38
+ end
39
+ end
@@ -1,50 +1,50 @@
1
- # encoding: UTF-8
2
- describe 'Exceptions' do
3
- describe WinRM::WinRMAuthorizationError do
4
- let(:error) { WinRM::WinRMHTTPTransportError.new('Foo happened', 500) }
5
-
6
- it 'adds the response code to the message' do
7
- expect(error.message).to eq('Foo happened (500).')
8
- end
9
-
10
- it 'exposes the response code as an attribute' do
11
- expect(error.status_code).to eq 500
12
- end
13
-
14
- it 'is a winrm error' do
15
- expect(error).to be_kind_of(WinRM::WinRMError)
16
- end
17
- end
18
-
19
- describe WinRM::WinRMWSManFault do
20
- let(:error) { WinRM::WinRMWSManFault.new('fault text', 42) }
21
-
22
- it 'exposes the fault text as an attribute' do
23
- expect(error.fault_description).to eq('fault text')
24
- end
25
-
26
- it 'exposes the fault code as an attribute' do
27
- expect(error.fault_code).to eq 42
28
- end
29
-
30
- it 'is a winrm error' do
31
- expect(error).to be_kind_of(WinRM::WinRMError)
32
- end
33
- end
34
-
35
- describe WinRM::WinRMWMIError do
36
- let(:error) { WinRM::WinRMWMIError.new('message text', 77_777) }
37
-
38
- it 'exposes the error text as an attribute' do
39
- expect(error.error).to eq('message text')
40
- end
41
-
42
- it 'exposes the error code as an attribute' do
43
- expect(error.error_code).to eq 77_777
44
- end
45
-
46
- it 'is a winrm error' do
47
- expect(error).to be_kind_of(WinRM::WinRMError)
48
- end
49
- end
50
- end
1
+ # encoding: UTF-8
2
+ describe 'Exceptions' do
3
+ describe WinRM::WinRMAuthorizationError do
4
+ let(:error) { WinRM::WinRMHTTPTransportError.new('Foo happened', 500) }
5
+
6
+ it 'adds the response code to the message' do
7
+ expect(error.message).to eq('Foo happened (500).')
8
+ end
9
+
10
+ it 'exposes the response code as an attribute' do
11
+ expect(error.status_code).to eq 500
12
+ end
13
+
14
+ it 'is a winrm error' do
15
+ expect(error).to be_kind_of(WinRM::WinRMError)
16
+ end
17
+ end
18
+
19
+ describe WinRM::WinRMWSManFault do
20
+ let(:error) { WinRM::WinRMWSManFault.new('fault text', 42) }
21
+
22
+ it 'exposes the fault text as an attribute' do
23
+ expect(error.fault_description).to eq('fault text')
24
+ end
25
+
26
+ it 'exposes the fault code as an attribute' do
27
+ expect(error.fault_code).to eq 42
28
+ end
29
+
30
+ it 'is a winrm error' do
31
+ expect(error).to be_kind_of(WinRM::WinRMError)
32
+ end
33
+ end
34
+
35
+ describe WinRM::WinRMWMIError do
36
+ let(:error) { WinRM::WinRMWMIError.new('message text', 77_777) }
37
+
38
+ it 'exposes the error text as an attribute' do
39
+ expect(error.error).to eq('message text')
40
+ end
41
+
42
+ it 'exposes the error code as an attribute' do
43
+ expect(error.error_code).to eq 77_777
44
+ end
45
+
46
+ it 'is a winrm error' do
47
+ expect(error).to be_kind_of(WinRM::WinRMError)
48
+ end
49
+ end
50
+ end