winrm 2.3.0 → 2.3.5

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 (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,33 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- describe 'winrm client wql' do
4
- before(:all) do
5
- @winrm = winrm_connection
6
- end
7
-
8
- it 'should query Win32_OperatingSystem' do
9
- output = @winrm.run_wql('select * from Win32_OperatingSystem')
10
- expect(output).to_not be_empty
11
- output_caption = output[:win32_operating_system][0][:caption]
12
- expect(output_caption).to include('Microsoft')
13
- expect(output_caption).to include('Windows')
14
- end
15
-
16
- it 'should query Win32_Process' do
17
- output = @winrm.run_wql('select * from Win32_Process')
18
- expect(output).to_not be_empty
19
- process_count = output[:win32_process].count
20
- expect(process_count).to be > 1
21
- expect(output[:win32_process]).to all(include(:command_line))
22
- end
23
-
24
- it 'should query Win32_Process with block' do
25
- count = 0
26
- @winrm.run_wql('select * from Win32_Process') do |type, item|
27
- expect(type).to eq(:win32_process)
28
- expect(item).to include(:command_line)
29
- count += 1
30
- end
31
- expect(count).to be > 1
32
- end
33
- end
@@ -1,59 +0,0 @@
1
- require 'rspec/expectations'
2
-
3
- # rspec matchers
4
- RSpec::Matchers.define :have_stdout_match do |expected_stdout|
5
- match do |actual_output|
6
- !expected_stdout.match(actual_output.stdout).nil?
7
- end
8
- failure_message do |actual_output|
9
- "expected that '#{actual_output.stdout}' would match #{expected_stdout}"
10
- end
11
- end
12
-
13
- RSpec::Matchers.define :have_stderr_match do |expected_stderr|
14
- match do |actual_output|
15
- !expected_stderr.match(actual_output.stderr).nil?
16
- end
17
- failure_message do |actual_output|
18
- "expected that '#{actual_output.stderr}' would match #{expected_stderr}"
19
- end
20
- end
21
-
22
- RSpec::Matchers.define :have_no_stdout do
23
- match do |actual_output|
24
- stdout = actual_output.stdout
25
- ['\r\n', ''].include?(stdout)
26
- end
27
- failure_message do |actual_output|
28
- "expected that '#{actual_output.stdout}' would have no stdout"
29
- end
30
- end
31
-
32
- RSpec::Matchers.define :have_no_stderr do
33
- match do |actual_output|
34
- stderr = actual_output.stderr
35
- ['\r\n', ''].include?(stderr)
36
- end
37
- failure_message do |actual_output|
38
- "expected that '#{actual_output.stderr}' would have no stderr"
39
- end
40
- end
41
-
42
- RSpec::Matchers.define :have_exit_code do |expected_exit_code|
43
- match do |actual_output|
44
- expected_exit_code == actual_output.exitcode
45
- end
46
- failure_message do |actual_output|
47
- "expected exit code #{expected_exit_code}, but got #{actual_output.exitcode}"
48
- end
49
- end
50
-
51
- RSpec::Matchers.define :be_a_uid do
52
- match do |actual|
53
- # WinRM1.1 returns uuid's prefixed with 'uuid:' where as later versions do not
54
- actual && actual.to_s.match(/^(uuid:)*\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/)
55
- end
56
- failure_message do |actual|
57
- "expected a uid, but got '#{actual}'"
58
- end
59
- end
@@ -1,183 +0,0 @@
1
- require 'winrm/connection_opts'
2
-
3
- describe WinRM::ConnectionOpts do
4
- shared_examples 'invalid options' do
5
- it 'throws a validation error' do
6
- expect { WinRM::ConnectionOpts.create_with_defaults(overrides) }.to raise_error
7
- end
8
- end
9
-
10
- context 'when there are no overrides' do
11
- it_behaves_like 'invalid options'
12
- end
13
-
14
- context 'when there are only username and password' do
15
- let(:overrides) do
16
- {
17
- user: 'Administrator',
18
- password: 'password'
19
- }
20
- end
21
-
22
- it_behaves_like 'invalid options'
23
- end
24
-
25
- context 'when there are only username and endpoint' do
26
- let(:overrides) do
27
- {
28
- user: 'Administrator',
29
- endpoint: 'http://localhost:5985/wsman'
30
- }
31
- end
32
-
33
- it_behaves_like 'invalid options'
34
- end
35
-
36
- context 'when there are only password and endpoint' do
37
- let(:overrides) do
38
- {
39
- password: 'password',
40
- endpoint: 'http://localhost:5985/wsman'
41
- }
42
- end
43
-
44
- it_behaves_like 'invalid options'
45
- end
46
-
47
- context 'when there are only certificate and key' do
48
- let(:overrides) do
49
- {
50
- client_cert: 'path/to/cert',
51
- client_key: 'path/to/key'
52
- }
53
- end
54
-
55
- it_behaves_like 'invalid options'
56
- end
57
-
58
- context 'when there are only certificate and endpoint' do
59
- let(:overrides) do
60
- {
61
- client_cert: 'path/to/cert',
62
- endpoint: 'http://localhost:5985/wsman'
63
- }
64
- end
65
-
66
- it_behaves_like 'invalid options'
67
- end
68
-
69
- context 'when there are only key and endpoint' do
70
- let(:overrides) do
71
- {
72
- client_key: 'path/to/key',
73
- endpoint: 'http://localhost:5985/wsman'
74
- }
75
- end
76
-
77
- it_behaves_like 'invalid options'
78
- end
79
-
80
- context 'when username, password, and endpoint are given' do
81
- let(:overrides) do
82
- {
83
- user: 'Administrator',
84
- password: 'password',
85
- endpoint: 'http://localhost:5985/wsman'
86
- }
87
- end
88
- describe '#create_with_defaults' do
89
- it 'creates a ConnectionOpts object' do
90
- config = WinRM::ConnectionOpts.create_with_defaults(overrides)
91
- expect(config[:user]).to eq(overrides[:user])
92
- expect(config[:password]).to eq(overrides[:password])
93
- expect(config[:endpoint]).to eq(overrides[:endpoint])
94
- end
95
- end
96
- end
97
-
98
- context 'when certificate, key and endpoint are given' do
99
- let(:overrides) do
100
- {
101
- client_cert: 'path/to/cert',
102
- client_key: 'path/to/key',
103
- endpoint: 'http://localhost:5985/wsman'
104
- }
105
- end
106
- describe '#create_with_defaults' do
107
- it 'creates a ConnectionOpts object' do
108
- config = WinRM::ConnectionOpts.create_with_defaults(overrides)
109
- expect(config[:client_cert]).to eq(overrides[:client_cert])
110
- expect(config[:client_key]).to eq(overrides[:client_key])
111
- expect(config[:endpoint]).to eq(overrides[:endpoint])
112
- end
113
- end
114
- end
115
-
116
- context 'when overrides are provided' do
117
- let(:overrides) do
118
- {
119
- user: 'Administrator',
120
- password: 'password',
121
- endpoint: 'http://localhost:5985/wsman',
122
- transport: :ssl
123
- }
124
- end
125
- describe '#create_with_defaults' do
126
- it 'creates a ConnectionOpts object with overrides' do
127
- config = WinRM::ConnectionOpts.create_with_defaults(overrides)
128
- expect(config[:transport]).to eq(overrides[:transport])
129
- end
130
- end
131
- end
132
-
133
- context 'when receive_timeout is specified' do
134
- let(:overrides) do
135
- {
136
- user: 'Administrator',
137
- password: 'password',
138
- endpoint: 'http://localhost:5985/wsman',
139
- receive_timeout: 120
140
- }
141
- end
142
- describe '#create_with_defaults' do
143
- it 'creates a ConnectionOpts object with the correct receive_timeout' do
144
- config = WinRM::ConnectionOpts.create_with_defaults(overrides)
145
- expect(config[:receive_timeout]).to eq(overrides[:receive_timeout])
146
- end
147
- end
148
- end
149
-
150
- context 'when operation_timeout is specified' do
151
- let(:overrides) do
152
- {
153
- user: 'Administrator',
154
- password: 'password',
155
- endpoint: 'http://localhost:5985/wsman',
156
- operation_timeout: 120
157
- }
158
- end
159
- describe '#create_with_defaults' do
160
- it 'creates a ConnectionOpts object with the correct timeouts' do
161
- config = WinRM::ConnectionOpts.create_with_defaults(overrides)
162
- expect(config[:operation_timeout]).to eq(overrides[:operation_timeout])
163
- expect(config[:receive_timeout]).to eq(overrides[:operation_timeout] + 10)
164
- end
165
- end
166
- end
167
-
168
- context 'when invalid data types are given' do
169
- let(:overrides) do
170
- {
171
- user: 'Administrator',
172
- password: 'password',
173
- endpoint: 'http://localhost:5985/wsman',
174
- operation_timeout: 'PT60S'
175
- }
176
- end
177
- describe '#create_with_defaults' do
178
- it 'raises an error' do
179
- expect { WinRM::ConnectionOpts.create_with_defaults(overrides) }.to raise_error
180
- end
181
- end
182
- end
183
- end
@@ -1,37 +0,0 @@
1
- require 'winrm'
2
- require 'winrm/shells/cmd'
3
- require 'winrm/shells/power_shell'
4
-
5
- describe WinRM::Connection do
6
- context 'new' do
7
- it 'creates a new winrm session' do
8
- connection = WinRM::Connection.new(default_connection_opts)
9
- expect(connection).not_to be_nil
10
- end
11
- end
12
-
13
- context 'shell(:cmd)' do
14
- it 'creates a new cmd session' do
15
- connection = WinRM::Connection.new(default_connection_opts)
16
- cmd_shell = connection.shell(:cmd)
17
- expect(cmd_shell).not_to be_nil
18
- expect(cmd_shell).to be_an_instance_of(WinRM::Shells::Cmd)
19
- end
20
- end
21
-
22
- context 'shell(:powershell)' do
23
- it 'creates a new powershell session' do
24
- connection = WinRM::Connection.new(default_connection_opts)
25
- cmd_shell = connection.shell(:powershell)
26
- expect(cmd_shell).not_to be_nil
27
- expect(cmd_shell).to be_an_instance_of(WinRM::Shells::Powershell)
28
- end
29
- end
30
-
31
- context 'shell(:not_a_real_shell_type)' do
32
- it 'raises a descriptive error' do
33
- connection = WinRM::Connection.new(default_connection_opts)
34
- expect { connection.shell(:not_a_real_shell_type) }.to raise_error(WinRM::InvalidShellError)
35
- end
36
- end
37
- end
@@ -1,49 +0,0 @@
1
- describe 'Exceptions' do
2
- describe WinRM::WinRMAuthorizationError do
3
- let(:error) { WinRM::WinRMHTTPTransportError.new('Foo happened', 500) }
4
-
5
- it 'adds the response code to the message' do
6
- expect(error.message).to eq('Foo happened (500).')
7
- end
8
-
9
- it 'exposes the response code as an attribute' do
10
- expect(error.status_code).to eq 500
11
- end
12
-
13
- it 'is a winrm error' do
14
- expect(error).to be_kind_of(WinRM::WinRMError)
15
- end
16
- end
17
-
18
- describe WinRM::WinRMWSManFault do
19
- let(:error) { WinRM::WinRMWSManFault.new('fault text', 42) }
20
-
21
- it 'exposes the fault text as an attribute' do
22
- expect(error.fault_description).to eq('fault text')
23
- end
24
-
25
- it 'exposes the fault code as an attribute' do
26
- expect(error.fault_code).to eq 42
27
- end
28
-
29
- it 'is a winrm error' do
30
- expect(error).to be_kind_of(WinRM::WinRMError)
31
- end
32
- end
33
-
34
- describe WinRM::WinRMWMIError do
35
- let(:error) { WinRM::WinRMWMIError.new('message text', 77_777) }
36
-
37
- it 'exposes the error text as an attribute' do
38
- expect(error.error).to eq('message text')
39
- end
40
-
41
- it 'exposes the error code as an attribute' do
42
- expect(error.error_code).to eq 77_777
43
- end
44
-
45
- it 'is a winrm error' do
46
- expect(error).to be_kind_of(WinRM::WinRMError)
47
- end
48
- end
49
- end
@@ -1,66 +0,0 @@
1
- require 'winrm/exceptions'
2
- require 'winrm/http/transport_factory'
3
-
4
- module WinRM
5
- module HTTP
6
- # Remove the gssapi stuff in kerberos init for tests
7
- class HttpGSSAPI < HttpTransport
8
- def initialize(endpoint, realm, opts, service = nil) end
9
- end
10
- end
11
- end
12
-
13
- describe WinRM::HTTP::TransportFactory do
14
- describe '#create_transport' do
15
- let(:transport) { :negotiate }
16
- let(:options) do
17
- {
18
- transport: transport,
19
- endpoint: 'endpoint',
20
- user: 'user'
21
- }
22
- end
23
-
24
- it 'creates a negotiate transport' do
25
- options[:transport] = :negotiate
26
- expect(subject.create_transport(options)).to be_a(WinRM::HTTP::HttpNegotiate)
27
- end
28
-
29
- it 'creates a plaintext transport' do
30
- options[:transport] = :plaintext
31
- expect(subject.create_transport(options)).to be_a(WinRM::HTTP::HttpPlaintext)
32
- end
33
-
34
- it 'creates a basic auth ssl transport' do
35
- options[:transport] = :ssl
36
- options[:basic_auth_only] = true
37
- expect(subject.create_transport(options)).to be_a(WinRM::HTTP::BasicAuthSSL)
38
- end
39
-
40
- it 'creates a client cert ssl transport' do
41
- options[:transport] = :ssl
42
- options[:client_cert] = 'cert'
43
- expect(subject.create_transport(options)).to be_a(WinRM::HTTP::ClientCertAuthSSL)
44
- end
45
-
46
- it 'creates a negotiate over ssl transport' do
47
- options[:transport] = :ssl
48
- expect(subject.create_transport(options)).to be_a(WinRM::HTTP::HttpNegotiate)
49
- end
50
-
51
- it 'creates a kerberos transport' do
52
- options[:transport] = :kerberos
53
- expect(subject.create_transport(options)).to be_a(WinRM::HTTP::HttpGSSAPI)
54
- end
55
-
56
- it 'creates a transport from a stringified transport' do
57
- options[:transport] = 'negotiate'
58
- expect(subject.create_transport(options)).to be_a(WinRM::HTTP::HttpNegotiate)
59
- end
60
-
61
- it 'raises when transport type does not exist' do
62
- options[:transport] = :fancy
63
- expect { subject.create_transport(options) }.to raise_error(WinRM::InvalidTransportError)
64
- end
65
- end
66
- end
@@ -1,43 +0,0 @@
1
- require 'rubyntlm'
2
- require 'winrm/http/transport'
3
-
4
- describe WinRM::HTTP::HttpNegotiate do
5
- describe '#init' do
6
- let(:endpoint) { 'some_endpoint' }
7
- let(:domain) { 'some_domain' }
8
- let(:user) { 'some_user' }
9
- let(:password) { 'some_password' }
10
- let(:options) { {} }
11
-
12
- context 'user is not domain prefixed' do
13
- it 'does not pass a domain to the NTLM client' do
14
- expect(Net::NTLM::Client).to receive(:new).with(user, password, options)
15
- WinRM::HTTP::HttpNegotiate.new(endpoint, user, password, options)
16
- end
17
- end
18
-
19
- context 'user is domain prefixed' do
20
- it 'passes prefixed domain to the NTLM client' do
21
- expect(Net::NTLM::Client).to receive(:new) do |passed_user, passed_password, passed_options|
22
- expect(passed_user).to eq user
23
- expect(passed_password).to eq password
24
- expect(passed_options[:domain]).to eq domain
25
- end
26
- WinRM::HTTP::HttpNegotiate.new(endpoint, "#{domain}\\#{user}", password, options)
27
- end
28
- end
29
-
30
- context 'option is passed with a domain' do
31
- let(:options) { { domain: domain } }
32
-
33
- it 'passes domain option to the NTLM client' do
34
- expect(Net::NTLM::Client).to receive(:new) do |passed_user, passed_password, passed_options|
35
- expect(passed_user).to eq user
36
- expect(passed_password).to eq password
37
- expect(passed_options[:domain]).to eq domain
38
- end
39
- WinRM::HTTP::HttpNegotiate.new(endpoint, user, password, options)
40
- end
41
- end
42
- end
43
- end