winrm 2.3.0 → 2.3.1
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.
- checksums.yaml +4 -4
- data/lib/winrm/http/transport.rb +1 -1
- data/lib/winrm/psrp/message.rb +128 -128
- data/lib/winrm/shells/power_shell.rb +0 -1
- data/lib/winrm/version.rb +1 -1
- metadata +12 -85
- data/.gitignore +0 -10
- data/.rubocop.yml +0 -38
- data/.travis.yml +0 -10
- data/Gemfile +0 -2
- data/Rakefile +0 -33
- data/Vagrantfile +0 -6
- data/WinrmAppveyor.psm1 +0 -32
- data/appveyor.yml +0 -50
- data/changelog.md +0 -133
- data/preamble +0 -17
- data/tests/integration/auth_timeout_spec.rb +0 -17
- data/tests/integration/cmd_spec.rb +0 -130
- data/tests/integration/config-example.yml +0 -16
- data/tests/integration/issue_59_spec.rb +0 -25
- data/tests/integration/powershell_spec.rb +0 -164
- data/tests/integration/spec_helper.rb +0 -62
- data/tests/integration/transport_spec.rb +0 -98
- data/tests/integration/wql_spec.rb +0 -33
- data/tests/matchers.rb +0 -59
- data/tests/spec/configuration_spec.rb +0 -183
- data/tests/spec/connection_spec.rb +0 -37
- data/tests/spec/exception_spec.rb +0 -49
- data/tests/spec/http/transport_factory_spec.rb +0 -66
- data/tests/spec/http/transport_spec.rb +0 -43
- data/tests/spec/output_spec.rb +0 -128
- data/tests/spec/psrp/fragment_spec.rb +0 -60
- data/tests/spec/psrp/message_data/base_spec.rb +0 -11
- data/tests/spec/psrp/message_data/error_record_spec.rb +0 -39
- data/tests/spec/psrp/message_data/pipeline_host_call_spec.rb +0 -23
- data/tests/spec/psrp/message_data/pipeline_output_spec.rb +0 -30
- data/tests/spec/psrp/message_data/pipeline_state_spec.rb +0 -38
- data/tests/spec/psrp/message_data/runspace_pool_host_call_spec.rb +0 -23
- data/tests/spec/psrp/message_data/runspacepool_state_spec.rb +0 -14
- data/tests/spec/psrp/message_data/session_capability_spec.rb +0 -28
- data/tests/spec/psrp/message_data_spec.rb +0 -33
- data/tests/spec/psrp/message_defragmenter_spec.rb +0 -45
- data/tests/spec/psrp/message_fragmenter_spec.rb +0 -103
- data/tests/spec/psrp/powershell_output_decoder_spec.rb +0 -98
- data/tests/spec/psrp/psrp_message_spec.rb +0 -73
- data/tests/spec/psrp/recieve_response_reader_spec.rb +0 -170
- data/tests/spec/psrp/uuid_spec.rb +0 -28
- data/tests/spec/response_handler_spec.rb +0 -69
- data/tests/spec/shells/base_spec.rb +0 -227
- data/tests/spec/shells/cmd_spec.rb +0 -75
- data/tests/spec/shells/powershell_spec.rb +0 -221
- data/tests/spec/spec_helper.rb +0 -46
- data/tests/spec/stubs/clixml/error_record.xml.erb +0 -84
- data/tests/spec/stubs/clixml/pipeline_state.xml.erb +0 -88
- data/tests/spec/stubs/responses/get_command_output_response.xml.erb +0 -13
- data/tests/spec/stubs/responses/get_command_output_response_not_done.xml.erb +0 -10
- data/tests/spec/stubs/responses/get_omi_command_output_response.xml.erb +0 -23
- data/tests/spec/stubs/responses/get_omi_command_output_response_not_done.xml.erb +0 -24
- data/tests/spec/stubs/responses/get_omi_config_response.xml +0 -45
- data/tests/spec/stubs/responses/get_omi_powershell_keepalive_response.xml.erb +0 -33
- data/tests/spec/stubs/responses/get_powershell_keepalive_response.xml.erb +0 -10
- data/tests/spec/stubs/responses/get_powershell_output_response.xml.erb +0 -12
- data/tests/spec/stubs/responses/get_powershell_output_response_not_done.xml.erb +0 -9
- data/tests/spec/stubs/responses/open_shell_omi.xml +0 -43
- data/tests/spec/stubs/responses/open_shell_v1.xml +0 -19
- data/tests/spec/stubs/responses/open_shell_v2.xml +0 -20
- data/tests/spec/stubs/responses/soap_fault_omi.xml +0 -31
- data/tests/spec/stubs/responses/soap_fault_v1.xml +0 -36
- data/tests/spec/stubs/responses/soap_fault_v2.xml +0 -42
- data/tests/spec/stubs/responses/wmi_error_v2.xml +0 -41
- data/tests/spec/wsmv/cleanup_command_spec.rb +0 -20
- data/tests/spec/wsmv/close_shell_spec.rb +0 -15
- data/tests/spec/wsmv/command_output_decoder_spec.rb +0 -35
- data/tests/spec/wsmv/command_output_spec.rb +0 -43
- data/tests/spec/wsmv/command_spec.rb +0 -17
- data/tests/spec/wsmv/configuration_spec.rb +0 -15
- data/tests/spec/wsmv/create_pipeline_spec.rb +0 -30
- data/tests/spec/wsmv/create_shell_spec.rb +0 -39
- data/tests/spec/wsmv/init_runspace_pool_spec.rb +0 -38
- data/tests/spec/wsmv/keep_alive_spec.rb +0 -21
- data/tests/spec/wsmv/receive_response_reader_spec.rb +0 -124
- data/tests/spec/wsmv/send_data_spec.rb +0 -30
- data/tests/spec/wsmv/wql_query_spec.rb +0 -11
- data/tests/spec/wsmv/write_stdin_spec.rb +0 -20
- data/winrm.gemspec +0 -46
@@ -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
|
data/tests/spec/output_spec.rb
DELETED
@@ -1,128 +0,0 @@
|
|
1
|
-
describe WinRM::Output do
|
2
|
-
subject { WinRM::Output.new }
|
3
|
-
|
4
|
-
context 'when there is no output' do
|
5
|
-
describe '#stdout' do
|
6
|
-
it 'is empty' do
|
7
|
-
expect(subject.stdout).to be_empty
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '#stderr' do
|
12
|
-
it 'is empty' do
|
13
|
-
expect(subject.stderr).to be_empty
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#output' do
|
18
|
-
it 'is empty' do
|
19
|
-
expect(subject.output).to be_empty
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'when there is only one line' do
|
25
|
-
describe '#stdout' do
|
26
|
-
it 'is equal to that line' do
|
27
|
-
subject << { stdout: 'foo' }
|
28
|
-
expect(subject.stdout).to eq('foo')
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '#stderr' do
|
33
|
-
it 'is equal to that line' do
|
34
|
-
subject << { stderr: 'foo' }
|
35
|
-
expect(subject.stderr).to eq('foo')
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '#output' do
|
40
|
-
it 'is equal to stdout' do
|
41
|
-
subject << { stdout: 'foo' }
|
42
|
-
expect(subject.output).to eq('foo')
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'is equal to stderr' do
|
46
|
-
subject << { stderr: 'foo' }
|
47
|
-
expect(subject.output).to eq('foo')
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'when there is one line of each type' do
|
53
|
-
before(:each) do
|
54
|
-
subject << { stdout: 'foo' }
|
55
|
-
subject << { stderr: 'bar' }
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '#stdout' do
|
59
|
-
it 'is equal to that line' do
|
60
|
-
expect(subject.stdout).to eq('foo')
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe '#stderr' do
|
65
|
-
it 'is equal to that line' do
|
66
|
-
expect(subject.stderr).to eq('bar')
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe '#output' do
|
71
|
-
it 'is equal to stdout + stderr' do
|
72
|
-
expect(subject.output).to eq('foobar')
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
context 'when there are multiple lines' do
|
78
|
-
before(:each) do
|
79
|
-
subject << { stdout: 'I can have a newline\nanywhere, ' }
|
80
|
-
subject << { stderr: 'I can also have stderr' }
|
81
|
-
subject << { stdout: 'or stdout', stderr: ' and stderr' }
|
82
|
-
subject << {}
|
83
|
-
subject << { stdout: ' or nothing! (above)' }
|
84
|
-
end
|
85
|
-
|
86
|
-
describe '#stdout' do
|
87
|
-
it 'is equal to that line' do
|
88
|
-
expect(subject.stdout).to eq(
|
89
|
-
'I can have a newline\nanywhere, or stdout or nothing! (above)'
|
90
|
-
)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe '#stderr' do
|
95
|
-
it 'is equal to that line' do
|
96
|
-
expect(subject.stderr).to eq('I can also have stderr and stderr')
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe '#output' do
|
101
|
-
it 'is equal to stdout + stderr' do
|
102
|
-
expect(subject.output).to eq(
|
103
|
-
'I can have a newline\nanywhere, I can also have stderror stdout ' \
|
104
|
-
'and stderr or nothing! (above)'
|
105
|
-
)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe '#exitcode' do
|
111
|
-
let(:exitcode) { 0 }
|
112
|
-
|
113
|
-
context 'when a valid exit code is set' do
|
114
|
-
it 'sets the exit code' do
|
115
|
-
subject.exitcode = exitcode
|
116
|
-
expect(subject.exitcode).to eq exitcode
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
context 'when an invalid exit code is set' do
|
121
|
-
let(:exitcode) { 'bad' }
|
122
|
-
|
123
|
-
it 'sets the exit code' do
|
124
|
-
expect { subject.exitcode = exitcode }.to raise_error WinRM::InvalidExitCode
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|