knife-windows 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +26 -26
- data/CHANGELOG.md +139 -135
- data/DOC_CHANGES.md +22 -22
- data/Gemfile +13 -13
- data/README.md +404 -404
- data/RELEASE_NOTES.md +9 -9
- data/appveyor.yml +39 -39
- data/ci.gemfile +16 -16
- data/knife-windows.gemspec +26 -26
- data/lib/chef/knife/bootstrap/windows-chef-client-msi.erb +246 -246
- data/lib/chef/knife/bootstrap_windows_base.rb +443 -443
- data/lib/chef/knife/bootstrap_windows_ssh.rb +116 -116
- data/lib/chef/knife/bootstrap_windows_winrm.rb +102 -102
- data/lib/chef/knife/core/windows_bootstrap_context.rb +378 -378
- data/lib/chef/knife/knife_windows_base.rb +33 -33
- data/lib/chef/knife/windows_cert_generate.rb +155 -155
- data/lib/chef/knife/windows_cert_install.rb +68 -68
- data/lib/chef/knife/windows_helper.rb +36 -36
- data/lib/chef/knife/windows_listener_create.rb +107 -107
- data/lib/chef/knife/winrm.rb +122 -122
- data/lib/chef/knife/winrm_base.rb +128 -128
- data/lib/chef/knife/winrm_knife_base.rb +307 -307
- data/lib/chef/knife/winrm_session.rb +98 -98
- data/lib/chef/knife/winrm_shared_options.rb +47 -47
- data/lib/chef/knife/wsman_endpoint.rb +44 -44
- data/lib/chef/knife/wsman_test.rb +118 -118
- data/lib/knife-windows/path_helper.rb +242 -234
- data/lib/knife-windows/version.rb +6 -6
- data/spec/assets/fake_trusted_certs/excluded.txt +2 -0
- data/spec/assets/fake_trusted_certs/github.pem +42 -0
- data/spec/assets/fake_trusted_certs/google.crt +41 -0
- data/spec/assets/win_fake_trusted_cert_script.txt +89 -0
- data/spec/assets/win_template_rendered_with_bootstrap_install_command.txt +223 -223
- data/spec/assets/win_template_rendered_with_bootstrap_install_command_on_12_5_client.txt +223 -223
- data/spec/assets/win_template_rendered_without_bootstrap_install_command.txt +335 -335
- data/spec/assets/win_template_rendered_without_bootstrap_install_command_on_12_5_client.txt +335 -335
- data/spec/assets/win_template_unrendered.txt +246 -246
- data/spec/dummy_winrm_connection.rb +21 -21
- data/spec/functional/bootstrap_download_spec.rb +236 -236
- data/spec/spec_helper.rb +94 -94
- data/spec/unit/knife/bootstrap_options_spec.rb +157 -157
- data/spec/unit/knife/bootstrap_template_spec.rb +98 -98
- data/spec/unit/knife/bootstrap_windows_winrm_spec.rb +423 -423
- data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +213 -177
- data/spec/unit/knife/windows_cert_generate_spec.rb +90 -90
- data/spec/unit/knife/windows_cert_install_spec.rb +51 -51
- data/spec/unit/knife/windows_listener_create_spec.rb +76 -76
- data/spec/unit/knife/winrm_session_spec.rb +95 -95
- data/spec/unit/knife/winrm_spec.rb +500 -500
- data/spec/unit/knife/wsman_test_spec.rb +209 -209
- metadata +7 -3
@@ -1,209 +1,209 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Steven Murawski (<smurawski@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2015-2016 Chef Software, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'spec_helper'
|
20
|
-
|
21
|
-
describe Chef::Knife::WsmanTest do
|
22
|
-
let(:http_client_mock) { HTTPClient.new }
|
23
|
-
let(:ssl_policy) { double('DefaultSSLPolicy', :set_custom_certs => nil) }
|
24
|
-
|
25
|
-
before(:all) do
|
26
|
-
Chef::Config.reset
|
27
|
-
end
|
28
|
-
|
29
|
-
before(:each) do
|
30
|
-
response_body = '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header/><s:Body><wsmid:IdentifyResponse xmlns:wsmid="http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd"><wsmid:ProtocolVersion>http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd</wsmid:ProtocolVersion><wsmid:ProductVendor>Microsoft Corporation</wsmid:ProductVendor><wsmid:ProductVersion>OS: 0.0.0 SP: 0.0 Stack: 2.0</wsmid:ProductVersion></wsmid:IdentifyResponse></s:Body></s:Envelope>'
|
31
|
-
http_response_mock = HTTP::Message.new_response(response_body)
|
32
|
-
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
33
|
-
allow(HTTPClient).to receive(:new).and_return(http_client_mock)
|
34
|
-
subject.config[:verbosity] = 0
|
35
|
-
allow(subject.ui).to receive(:ask).and_return('prompted_password')
|
36
|
-
allow(Chef::HTTP::DefaultSSLPolicy).to receive(:new)
|
37
|
-
.with(http_client_mock.ssl_config)
|
38
|
-
.and_return(ssl_policy)
|
39
|
-
end
|
40
|
-
|
41
|
-
subject { Chef::Knife::WsmanTest.new(['-m', 'localhost']) }
|
42
|
-
|
43
|
-
it 'sets the ssl policy' do
|
44
|
-
expect(ssl_policy).to receive(:set_custom_certs).twice
|
45
|
-
subject.run
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'when testing the WSMAN endpoint' do
|
49
|
-
context 'and the service responds' do
|
50
|
-
context 'successfully' do
|
51
|
-
it 'writes a message about a successful connection' do
|
52
|
-
expect(subject.ui).to receive(:msg)
|
53
|
-
subject.run
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context 'with an invalid body' do
|
58
|
-
it 'warns for a failed connection and exit with a status of 1' do
|
59
|
-
response_body = 'I am invalid'
|
60
|
-
http_response_mock = HTTP::Message.new_response(response_body)
|
61
|
-
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
62
|
-
expect(subject.ui).to receive(:warn)
|
63
|
-
expect(subject.ui).to receive(:error)
|
64
|
-
expect(subject).to receive(:exit).with(1)
|
65
|
-
subject.run
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context 'with a non-200 code' do
|
70
|
-
it 'warns for a failed connection and exits with a status of 1' do
|
71
|
-
http_response_mock = HTTP::Message.new_response('<resp></resp>')
|
72
|
-
http_response_mock.status = 404
|
73
|
-
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
74
|
-
expect(subject.ui).to receive(:warn)
|
75
|
-
expect(subject.ui).to receive(:error)
|
76
|
-
expect(subject).to receive(:exit).with(1)
|
77
|
-
subject.run
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'and the service does not respond' do
|
83
|
-
error_message = 'A connection attempt failed because the connected party did not properly respond after a period of time.'
|
84
|
-
|
85
|
-
before(:each) do
|
86
|
-
allow(http_client_mock).to receive(:post).and_raise(Exception.new(error_message))
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'exits with a status code of 1' do
|
90
|
-
expect(subject).to receive(:exit).with(1)
|
91
|
-
subject.run
|
92
|
-
end
|
93
|
-
|
94
|
-
it 'writes a warning message for each node it fails to connect to' do
|
95
|
-
expect(subject.ui).to receive(:warn)
|
96
|
-
expect(subject).to receive(:exit).with(1)
|
97
|
-
subject.run
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'writes an error message if it fails to connect to any nodes' do
|
101
|
-
expect(subject.ui).to receive(:error)
|
102
|
-
expect(subject).to receive(:exit).with(1)
|
103
|
-
subject.run
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
context 'when not validating ssl cert' do
|
109
|
-
before(:each) do
|
110
|
-
expect(subject.ui).to receive(:msg)
|
111
|
-
subject.config[:winrm_ssl_verify_mode] = :verify_none
|
112
|
-
subject.config[:winrm_transport] = :ssl
|
113
|
-
end
|
114
|
-
|
115
|
-
it 'sets verify_mode to verify_none' do
|
116
|
-
subject.run
|
117
|
-
expect(http_client_mock.ssl_config.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
context 'when testing the WSMAN endpoint with verbose output' do
|
122
|
-
before(:each) do
|
123
|
-
subject.config[:verbosity] = 1
|
124
|
-
end
|
125
|
-
|
126
|
-
context 'and the service does not respond' do
|
127
|
-
it 'returns an object with an error message' do
|
128
|
-
error_message = 'A connection attempt failed because the connected party did not properly respond after a period of time.'
|
129
|
-
allow(http_client_mock).to receive(:post).and_raise(Exception.new(error_message))
|
130
|
-
expect(subject).to receive(:exit).with(1)
|
131
|
-
expect(subject).to receive(:output) do |output|
|
132
|
-
expect(output.error_message).to match(/#{error_message}/)
|
133
|
-
end
|
134
|
-
subject.run
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
context 'with an invalid body' do
|
139
|
-
it 'includes invalid body in error message' do
|
140
|
-
response_body = 'I am invalid'
|
141
|
-
http_response_mock = HTTP::Message.new_response(response_body)
|
142
|
-
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
143
|
-
expect(subject).to receive(:exit).with(1)
|
144
|
-
expect(subject).to receive(:output) do |output|
|
145
|
-
expect(output.error_message).to match(/#{response_body}/)
|
146
|
-
end
|
147
|
-
subject.run
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
context 'and the target node is Windows Server 2008 R2' do
|
152
|
-
before(:each) do
|
153
|
-
ws2008r2_response_body = '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header/><s:Body><wsmid:IdentifyResponse xmlns:wsmid="http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd"><wsmid:ProtocolVersion>http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd</wsmid:ProtocolVersion><wsmid:ProductVendor>Microsoft Corporation</wsmid:ProductVendor><wsmid:ProductVersion>OS: 0.0.0 SP: 0.0 Stack: 2.0</wsmid:ProductVersion></wsmid:IdentifyResponse></s:Body></s:Envelope>'
|
154
|
-
http_response_mock = HTTP::Message.new_response(ws2008r2_response_body)
|
155
|
-
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
156
|
-
end
|
157
|
-
|
158
|
-
it 'identifies the stack of the product version as 2.0 ' do
|
159
|
-
expect(subject).to receive(:output) do |output|
|
160
|
-
expect(output.product_version).to eq 'OS: 0.0.0 SP: 0.0 Stack: 2.0'
|
161
|
-
end
|
162
|
-
subject.run
|
163
|
-
end
|
164
|
-
|
165
|
-
it 'identifies the protocol version as the current DMTF standard' do
|
166
|
-
expect(subject).to receive(:output) do |output|
|
167
|
-
expect(output.protocol_version).to eq 'http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd'
|
168
|
-
end
|
169
|
-
subject.run
|
170
|
-
end
|
171
|
-
|
172
|
-
it 'identifies the vendor as the Microsoft Corporation' do
|
173
|
-
expect(subject).to receive(:output) do |output|
|
174
|
-
expect(output.product_vendor).to eq 'Microsoft Corporation'
|
175
|
-
end
|
176
|
-
subject.run
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
context 'and the target node is Windows Server 2012 R2' do
|
181
|
-
before(:each) do
|
182
|
-
ws2012_response_body = '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header/><s:Body><wsmid:IdentifyResponse xmlns:wsmid="http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd"><wsmid:ProtocolVersion>http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd</wsmid:ProtocolVersion><wsmid:ProductVendor>Microsoft Corporation</wsmid:ProductVendor><wsmid:ProductVersion>OS: 0.0.0 SP: 0.0 Stack: 3.0</wsmid:ProductVersion></wsmid:IdentifyResponse></s:Body></s:Envelope>'
|
183
|
-
http_response_mock = HTTP::Message.new_response(ws2012_response_body)
|
184
|
-
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
185
|
-
end
|
186
|
-
|
187
|
-
it 'identifies the stack of the product version as 3.0 ' do
|
188
|
-
expect(subject).to receive(:output) do |output|
|
189
|
-
expect(output.product_version).to eq 'OS: 0.0.0 SP: 0.0 Stack: 3.0'
|
190
|
-
end
|
191
|
-
subject.run
|
192
|
-
end
|
193
|
-
|
194
|
-
it 'identifies the protocol version as the current DMTF standard' do
|
195
|
-
expect(subject).to receive(:output) do |output|
|
196
|
-
expect(output.protocol_version).to eq 'http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd'
|
197
|
-
end
|
198
|
-
subject.run
|
199
|
-
end
|
200
|
-
|
201
|
-
it 'identifies the vendor as the Microsoft Corporation' do
|
202
|
-
expect(subject).to receive(:output) do |output|
|
203
|
-
expect(output.product_vendor).to eq 'Microsoft Corporation'
|
204
|
-
end
|
205
|
-
subject.run
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
209
|
-
end
|
1
|
+
#
|
2
|
+
# Author:: Steven Murawski (<smurawski@chef.io>)
|
3
|
+
# Copyright:: Copyright (c) 2015-2016 Chef Software, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'spec_helper'
|
20
|
+
|
21
|
+
describe Chef::Knife::WsmanTest do
|
22
|
+
let(:http_client_mock) { HTTPClient.new }
|
23
|
+
let(:ssl_policy) { double('DefaultSSLPolicy', :set_custom_certs => nil) }
|
24
|
+
|
25
|
+
before(:all) do
|
26
|
+
Chef::Config.reset
|
27
|
+
end
|
28
|
+
|
29
|
+
before(:each) do
|
30
|
+
response_body = '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header/><s:Body><wsmid:IdentifyResponse xmlns:wsmid="http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd"><wsmid:ProtocolVersion>http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd</wsmid:ProtocolVersion><wsmid:ProductVendor>Microsoft Corporation</wsmid:ProductVendor><wsmid:ProductVersion>OS: 0.0.0 SP: 0.0 Stack: 2.0</wsmid:ProductVersion></wsmid:IdentifyResponse></s:Body></s:Envelope>'
|
31
|
+
http_response_mock = HTTP::Message.new_response(response_body)
|
32
|
+
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
33
|
+
allow(HTTPClient).to receive(:new).and_return(http_client_mock)
|
34
|
+
subject.config[:verbosity] = 0
|
35
|
+
allow(subject.ui).to receive(:ask).and_return('prompted_password')
|
36
|
+
allow(Chef::HTTP::DefaultSSLPolicy).to receive(:new)
|
37
|
+
.with(http_client_mock.ssl_config)
|
38
|
+
.and_return(ssl_policy)
|
39
|
+
end
|
40
|
+
|
41
|
+
subject { Chef::Knife::WsmanTest.new(['-m', 'localhost']) }
|
42
|
+
|
43
|
+
it 'sets the ssl policy' do
|
44
|
+
expect(ssl_policy).to receive(:set_custom_certs).twice
|
45
|
+
subject.run
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when testing the WSMAN endpoint' do
|
49
|
+
context 'and the service responds' do
|
50
|
+
context 'successfully' do
|
51
|
+
it 'writes a message about a successful connection' do
|
52
|
+
expect(subject.ui).to receive(:msg)
|
53
|
+
subject.run
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'with an invalid body' do
|
58
|
+
it 'warns for a failed connection and exit with a status of 1' do
|
59
|
+
response_body = 'I am invalid'
|
60
|
+
http_response_mock = HTTP::Message.new_response(response_body)
|
61
|
+
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
62
|
+
expect(subject.ui).to receive(:warn)
|
63
|
+
expect(subject.ui).to receive(:error)
|
64
|
+
expect(subject).to receive(:exit).with(1)
|
65
|
+
subject.run
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'with a non-200 code' do
|
70
|
+
it 'warns for a failed connection and exits with a status of 1' do
|
71
|
+
http_response_mock = HTTP::Message.new_response('<resp></resp>')
|
72
|
+
http_response_mock.status = 404
|
73
|
+
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
74
|
+
expect(subject.ui).to receive(:warn)
|
75
|
+
expect(subject.ui).to receive(:error)
|
76
|
+
expect(subject).to receive(:exit).with(1)
|
77
|
+
subject.run
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'and the service does not respond' do
|
83
|
+
error_message = 'A connection attempt failed because the connected party did not properly respond after a period of time.'
|
84
|
+
|
85
|
+
before(:each) do
|
86
|
+
allow(http_client_mock).to receive(:post).and_raise(Exception.new(error_message))
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'exits with a status code of 1' do
|
90
|
+
expect(subject).to receive(:exit).with(1)
|
91
|
+
subject.run
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'writes a warning message for each node it fails to connect to' do
|
95
|
+
expect(subject.ui).to receive(:warn)
|
96
|
+
expect(subject).to receive(:exit).with(1)
|
97
|
+
subject.run
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'writes an error message if it fails to connect to any nodes' do
|
101
|
+
expect(subject.ui).to receive(:error)
|
102
|
+
expect(subject).to receive(:exit).with(1)
|
103
|
+
subject.run
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'when not validating ssl cert' do
|
109
|
+
before(:each) do
|
110
|
+
expect(subject.ui).to receive(:msg)
|
111
|
+
subject.config[:winrm_ssl_verify_mode] = :verify_none
|
112
|
+
subject.config[:winrm_transport] = :ssl
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'sets verify_mode to verify_none' do
|
116
|
+
subject.run
|
117
|
+
expect(http_client_mock.ssl_config.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context 'when testing the WSMAN endpoint with verbose output' do
|
122
|
+
before(:each) do
|
123
|
+
subject.config[:verbosity] = 1
|
124
|
+
end
|
125
|
+
|
126
|
+
context 'and the service does not respond' do
|
127
|
+
it 'returns an object with an error message' do
|
128
|
+
error_message = 'A connection attempt failed because the connected party did not properly respond after a period of time.'
|
129
|
+
allow(http_client_mock).to receive(:post).and_raise(Exception.new(error_message))
|
130
|
+
expect(subject).to receive(:exit).with(1)
|
131
|
+
expect(subject).to receive(:output) do |output|
|
132
|
+
expect(output.error_message).to match(/#{error_message}/)
|
133
|
+
end
|
134
|
+
subject.run
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context 'with an invalid body' do
|
139
|
+
it 'includes invalid body in error message' do
|
140
|
+
response_body = 'I am invalid'
|
141
|
+
http_response_mock = HTTP::Message.new_response(response_body)
|
142
|
+
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
143
|
+
expect(subject).to receive(:exit).with(1)
|
144
|
+
expect(subject).to receive(:output) do |output|
|
145
|
+
expect(output.error_message).to match(/#{response_body}/)
|
146
|
+
end
|
147
|
+
subject.run
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
context 'and the target node is Windows Server 2008 R2' do
|
152
|
+
before(:each) do
|
153
|
+
ws2008r2_response_body = '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header/><s:Body><wsmid:IdentifyResponse xmlns:wsmid="http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd"><wsmid:ProtocolVersion>http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd</wsmid:ProtocolVersion><wsmid:ProductVendor>Microsoft Corporation</wsmid:ProductVendor><wsmid:ProductVersion>OS: 0.0.0 SP: 0.0 Stack: 2.0</wsmid:ProductVersion></wsmid:IdentifyResponse></s:Body></s:Envelope>'
|
154
|
+
http_response_mock = HTTP::Message.new_response(ws2008r2_response_body)
|
155
|
+
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'identifies the stack of the product version as 2.0 ' do
|
159
|
+
expect(subject).to receive(:output) do |output|
|
160
|
+
expect(output.product_version).to eq 'OS: 0.0.0 SP: 0.0 Stack: 2.0'
|
161
|
+
end
|
162
|
+
subject.run
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'identifies the protocol version as the current DMTF standard' do
|
166
|
+
expect(subject).to receive(:output) do |output|
|
167
|
+
expect(output.protocol_version).to eq 'http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd'
|
168
|
+
end
|
169
|
+
subject.run
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'identifies the vendor as the Microsoft Corporation' do
|
173
|
+
expect(subject).to receive(:output) do |output|
|
174
|
+
expect(output.product_vendor).to eq 'Microsoft Corporation'
|
175
|
+
end
|
176
|
+
subject.run
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
context 'and the target node is Windows Server 2012 R2' do
|
181
|
+
before(:each) do
|
182
|
+
ws2012_response_body = '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header/><s:Body><wsmid:IdentifyResponse xmlns:wsmid="http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd"><wsmid:ProtocolVersion>http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd</wsmid:ProtocolVersion><wsmid:ProductVendor>Microsoft Corporation</wsmid:ProductVendor><wsmid:ProductVersion>OS: 0.0.0 SP: 0.0 Stack: 3.0</wsmid:ProductVersion></wsmid:IdentifyResponse></s:Body></s:Envelope>'
|
183
|
+
http_response_mock = HTTP::Message.new_response(ws2012_response_body)
|
184
|
+
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'identifies the stack of the product version as 3.0 ' do
|
188
|
+
expect(subject).to receive(:output) do |output|
|
189
|
+
expect(output.product_version).to eq 'OS: 0.0.0 SP: 0.0 Stack: 3.0'
|
190
|
+
end
|
191
|
+
subject.run
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'identifies the protocol version as the current DMTF standard' do
|
195
|
+
expect(subject).to receive(:output) do |output|
|
196
|
+
expect(output.protocol_version).to eq 'http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd'
|
197
|
+
end
|
198
|
+
subject.run
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'identifies the vendor as the Microsoft Corporation' do
|
202
|
+
expect(subject).to receive(:output) do |output|
|
203
|
+
expect(output.product_vendor).to eq 'Microsoft Corporation'
|
204
|
+
end
|
205
|
+
subject.run
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-windows
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Chisamore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: winrm
|
@@ -94,6 +94,10 @@ files:
|
|
94
94
|
- lib/chef/knife/wsman_test.rb
|
95
95
|
- lib/knife-windows/path_helper.rb
|
96
96
|
- lib/knife-windows/version.rb
|
97
|
+
- spec/assets/fake_trusted_certs/excluded.txt
|
98
|
+
- spec/assets/fake_trusted_certs/github.pem
|
99
|
+
- spec/assets/fake_trusted_certs/google.crt
|
100
|
+
- spec/assets/win_fake_trusted_cert_script.txt
|
97
101
|
- spec/assets/win_template_rendered_with_bootstrap_install_command.txt
|
98
102
|
- spec/assets/win_template_rendered_with_bootstrap_install_command_on_12_5_client.txt
|
99
103
|
- spec/assets/win_template_rendered_without_bootstrap_install_command.txt
|
@@ -132,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
136
|
version: '0'
|
133
137
|
requirements: []
|
134
138
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.6.
|
139
|
+
rubygems_version: 2.6.7
|
136
140
|
signing_key:
|
137
141
|
specification_version: 4
|
138
142
|
summary: Plugin that adds functionality to Chef's Knife CLI for configuring/interacting
|