knife-windows 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -5
- data/.travis.yml +26 -26
- data/CHANGELOG.md +112 -108
- data/DOC_CHANGES.md +14 -14
- data/Gemfile +12 -12
- data/LICENSE +201 -201
- data/README.md +391 -385
- data/RELEASE_NOTES.md +34 -34
- data/Rakefile +21 -21
- data/appveyor.yml +42 -42
- data/ci.gemfile +15 -15
- data/features/knife_help.feature +20 -20
- data/features/support/env.rb +5 -5
- data/knife-windows.gemspec +25 -25
- data/lib/chef/knife/bootstrap/windows-chef-client-msi.erb +233 -247
- data/lib/chef/knife/bootstrap_windows_base.rb +449 -415
- data/lib/chef/knife/bootstrap_windows_ssh.rb +115 -115
- data/lib/chef/knife/bootstrap_windows_winrm.rb +95 -95
- data/lib/chef/knife/core/windows_bootstrap_context.rb +372 -366
- 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 +117 -117
- data/lib/chef/knife/winrm_knife_base.rb +305 -303
- data/lib/chef/knife/winrm_session.rb +88 -87
- 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 +117 -117
- data/lib/knife-windows/path_helper.rb +234 -234
- data/lib/knife-windows/version.rb +6 -6
- data/spec/assets/win_template_rendered_with_bootstrap_install_command.txt +217 -217
- data/spec/assets/win_template_rendered_with_bootstrap_install_command_on_12_5_client.txt +217 -217
- data/spec/assets/win_template_rendered_without_bootstrap_install_command.txt +329 -329
- data/spec/assets/win_template_rendered_without_bootstrap_install_command_on_12_5_client.txt +329 -329
- data/spec/assets/win_template_unrendered.txt +246 -246
- data/spec/functional/bootstrap_download_spec.rb +241 -234
- data/spec/spec_helper.rb +94 -93
- data/spec/unit/knife/bootstrap_options_spec.rb +155 -155
- data/spec/unit/knife/bootstrap_template_spec.rb +98 -92
- data/spec/unit/knife/bootstrap_windows_winrm_spec.rb +341 -295
- data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +177 -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 +65 -65
- data/spec/unit/knife/winrm_spec.rb +516 -516
- data/spec/unit/knife/wsman_test_spec.rb +202 -202
- metadata +23 -4
@@ -1,202 +1,202 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Steven Murawski (<smurawski@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2015 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
|
-
|
24
|
-
before(:all) do
|
25
|
-
Chef::Config.reset
|
26
|
-
end
|
27
|
-
|
28
|
-
before(:each) do
|
29
|
-
allow(HTTPClient).to receive(:new).and_return(http_client_mock)
|
30
|
-
subject.config[:verbosity] = 0
|
31
|
-
allow(subject.ui).to receive(:ask).and_return('prompted_password')
|
32
|
-
end
|
33
|
-
|
34
|
-
subject { Chef::Knife::WsmanTest.new(['-m', 'localhost']) }
|
35
|
-
|
36
|
-
context 'when testing the WSMAN endpoint' do
|
37
|
-
context 'and the service does not respond' do
|
38
|
-
error_message = 'A connection attempt failed because the connected party did not properly respond after a period of time.'
|
39
|
-
|
40
|
-
before(:each) do
|
41
|
-
allow(http_client_mock).to receive(:post).and_raise(Exception.new(error_message))
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'exits with a status code of 1' do
|
45
|
-
expect(subject).to receive(:exit).with(1)
|
46
|
-
subject.run
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'writes a warning message for each node it fails to connect to' do
|
50
|
-
expect(subject.ui).to receive(:warn)
|
51
|
-
expect(subject).to receive(:exit).with(1)
|
52
|
-
subject.run
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'writes an error message if it fails to connect to any nodes' do
|
56
|
-
expect(subject.ui).to receive(:error)
|
57
|
-
expect(subject).to receive(:exit).with(1)
|
58
|
-
subject.run
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
context 'and the service responds' do
|
63
|
-
context 'successfully' do
|
64
|
-
it 'writes a message about a successful connection' do
|
65
|
-
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>'
|
66
|
-
http_response_mock = HTTP::Message.new_response(response_body)
|
67
|
-
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
68
|
-
expect(subject.ui).to receive(:msg)
|
69
|
-
subject.run
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context 'with an invalid body' do
|
74
|
-
it 'warns for a failed connection and exit with a status of 1' do
|
75
|
-
response_body = 'I am invalid'
|
76
|
-
http_response_mock = HTTP::Message.new_response(response_body)
|
77
|
-
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
78
|
-
expect(subject.ui).to receive(:warn)
|
79
|
-
expect(subject.ui).to receive(:error)
|
80
|
-
expect(subject).to receive(:exit).with(1)
|
81
|
-
subject.run
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context 'with a non-200 code' do
|
86
|
-
it 'warns for a failed connection and exits with a status of 1' do
|
87
|
-
http_response_mock = HTTP::Message.new_response('<resp></resp>')
|
88
|
-
http_response_mock.status = 404
|
89
|
-
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
90
|
-
expect(subject.ui).to receive(:warn)
|
91
|
-
expect(subject.ui).to receive(:error)
|
92
|
-
expect(subject).to receive(:exit).with(1)
|
93
|
-
subject.run
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
context 'when not validating ssl cert' do
|
100
|
-
before(:each) do
|
101
|
-
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>'
|
102
|
-
allow(http_client_mock).to receive(:post).and_return(HTTP::Message.new_response(response_body))
|
103
|
-
expect(subject.ui).to receive(:msg)
|
104
|
-
subject.config[:winrm_ssl_verify_mode] = :verify_none
|
105
|
-
subject.config[:winrm_transport] = :ssl
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'sets verify_mode to verify_none' do
|
109
|
-
subject.run
|
110
|
-
expect(http_client_mock.ssl_config.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
context 'when testing the WSMAN endpoint with verbose output' do
|
115
|
-
before(:each) do
|
116
|
-
subject.config[:verbosity] = 1
|
117
|
-
end
|
118
|
-
|
119
|
-
context 'and the service does not respond' do
|
120
|
-
it 'returns an object with an error message' do
|
121
|
-
error_message = 'A connection attempt failed because the connected party did not properly respond after a period of time.'
|
122
|
-
allow(http_client_mock).to receive(:post).and_raise(Exception.new(error_message))
|
123
|
-
expect(subject).to receive(:exit).with(1)
|
124
|
-
expect(subject).to receive(:output) do |output|
|
125
|
-
expect(output.error_message).to match(/#{error_message}/)
|
126
|
-
end
|
127
|
-
subject.run
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
context 'with an invalid body' do
|
132
|
-
it 'includes invalid body in error message' do
|
133
|
-
response_body = 'I am invalid'
|
134
|
-
http_response_mock = HTTP::Message.new_response(response_body)
|
135
|
-
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
136
|
-
expect(subject).to receive(:exit).with(1)
|
137
|
-
expect(subject).to receive(:output) do |output|
|
138
|
-
expect(output.error_message).to match(/#{response_body}/)
|
139
|
-
end
|
140
|
-
subject.run
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
context 'and the target node is Windows Server 2008 R2' do
|
145
|
-
before(:each) do
|
146
|
-
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>'
|
147
|
-
http_response_mock = HTTP::Message.new_response(ws2008r2_response_body)
|
148
|
-
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
149
|
-
end
|
150
|
-
|
151
|
-
it 'identifies the stack of the product version as 2.0 ' do
|
152
|
-
expect(subject).to receive(:output) do |output|
|
153
|
-
expect(output.product_version).to eq 'OS: 0.0.0 SP: 0.0 Stack: 2.0'
|
154
|
-
end
|
155
|
-
subject.run
|
156
|
-
end
|
157
|
-
|
158
|
-
it 'identifies the protocol version as the current DMTF standard' do
|
159
|
-
expect(subject).to receive(:output) do |output|
|
160
|
-
expect(output.protocol_version).to eq 'http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd'
|
161
|
-
end
|
162
|
-
subject.run
|
163
|
-
end
|
164
|
-
|
165
|
-
it 'identifies the vendor as the Microsoft Corporation' do
|
166
|
-
expect(subject).to receive(:output) do |output|
|
167
|
-
expect(output.product_vendor).to eq 'Microsoft Corporation'
|
168
|
-
end
|
169
|
-
subject.run
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
context 'and the target node is Windows Server 2012 R2' do
|
174
|
-
before(:each) do
|
175
|
-
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>'
|
176
|
-
http_response_mock = HTTP::Message.new_response(ws2012_response_body)
|
177
|
-
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
178
|
-
end
|
179
|
-
|
180
|
-
it 'identifies the stack of the product version as 3.0 ' do
|
181
|
-
expect(subject).to receive(:output) do |output|
|
182
|
-
expect(output.product_version).to eq 'OS: 0.0.0 SP: 0.0 Stack: 3.0'
|
183
|
-
end
|
184
|
-
subject.run
|
185
|
-
end
|
186
|
-
|
187
|
-
it 'identifies the protocol version as the current DMTF standard' do
|
188
|
-
expect(subject).to receive(:output) do |output|
|
189
|
-
expect(output.protocol_version).to eq 'http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd'
|
190
|
-
end
|
191
|
-
subject.run
|
192
|
-
end
|
193
|
-
|
194
|
-
it 'identifies the vendor as the Microsoft Corporation' do
|
195
|
-
expect(subject).to receive(:output) do |output|
|
196
|
-
expect(output.product_vendor).to eq 'Microsoft Corporation'
|
197
|
-
end
|
198
|
-
subject.run
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
202
|
-
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
|
+
|
24
|
+
before(:all) do
|
25
|
+
Chef::Config.reset
|
26
|
+
end
|
27
|
+
|
28
|
+
before(:each) do
|
29
|
+
allow(HTTPClient).to receive(:new).and_return(http_client_mock)
|
30
|
+
subject.config[:verbosity] = 0
|
31
|
+
allow(subject.ui).to receive(:ask).and_return('prompted_password')
|
32
|
+
end
|
33
|
+
|
34
|
+
subject { Chef::Knife::WsmanTest.new(['-m', 'localhost']) }
|
35
|
+
|
36
|
+
context 'when testing the WSMAN endpoint' do
|
37
|
+
context 'and the service does not respond' do
|
38
|
+
error_message = 'A connection attempt failed because the connected party did not properly respond after a period of time.'
|
39
|
+
|
40
|
+
before(:each) do
|
41
|
+
allow(http_client_mock).to receive(:post).and_raise(Exception.new(error_message))
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'exits with a status code of 1' do
|
45
|
+
expect(subject).to receive(:exit).with(1)
|
46
|
+
subject.run
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'writes a warning message for each node it fails to connect to' do
|
50
|
+
expect(subject.ui).to receive(:warn)
|
51
|
+
expect(subject).to receive(:exit).with(1)
|
52
|
+
subject.run
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'writes an error message if it fails to connect to any nodes' do
|
56
|
+
expect(subject.ui).to receive(:error)
|
57
|
+
expect(subject).to receive(:exit).with(1)
|
58
|
+
subject.run
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'and the service responds' do
|
63
|
+
context 'successfully' do
|
64
|
+
it 'writes a message about a successful connection' do
|
65
|
+
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>'
|
66
|
+
http_response_mock = HTTP::Message.new_response(response_body)
|
67
|
+
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
68
|
+
expect(subject.ui).to receive(:msg)
|
69
|
+
subject.run
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'with an invalid body' do
|
74
|
+
it 'warns for a failed connection and exit with a status of 1' do
|
75
|
+
response_body = 'I am invalid'
|
76
|
+
http_response_mock = HTTP::Message.new_response(response_body)
|
77
|
+
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
78
|
+
expect(subject.ui).to receive(:warn)
|
79
|
+
expect(subject.ui).to receive(:error)
|
80
|
+
expect(subject).to receive(:exit).with(1)
|
81
|
+
subject.run
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'with a non-200 code' do
|
86
|
+
it 'warns for a failed connection and exits with a status of 1' do
|
87
|
+
http_response_mock = HTTP::Message.new_response('<resp></resp>')
|
88
|
+
http_response_mock.status = 404
|
89
|
+
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
90
|
+
expect(subject.ui).to receive(:warn)
|
91
|
+
expect(subject.ui).to receive(:error)
|
92
|
+
expect(subject).to receive(:exit).with(1)
|
93
|
+
subject.run
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'when not validating ssl cert' do
|
100
|
+
before(:each) do
|
101
|
+
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>'
|
102
|
+
allow(http_client_mock).to receive(:post).and_return(HTTP::Message.new_response(response_body))
|
103
|
+
expect(subject.ui).to receive(:msg)
|
104
|
+
subject.config[:winrm_ssl_verify_mode] = :verify_none
|
105
|
+
subject.config[:winrm_transport] = :ssl
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'sets verify_mode to verify_none' do
|
109
|
+
subject.run
|
110
|
+
expect(http_client_mock.ssl_config.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'when testing the WSMAN endpoint with verbose output' do
|
115
|
+
before(:each) do
|
116
|
+
subject.config[:verbosity] = 1
|
117
|
+
end
|
118
|
+
|
119
|
+
context 'and the service does not respond' do
|
120
|
+
it 'returns an object with an error message' do
|
121
|
+
error_message = 'A connection attempt failed because the connected party did not properly respond after a period of time.'
|
122
|
+
allow(http_client_mock).to receive(:post).and_raise(Exception.new(error_message))
|
123
|
+
expect(subject).to receive(:exit).with(1)
|
124
|
+
expect(subject).to receive(:output) do |output|
|
125
|
+
expect(output.error_message).to match(/#{error_message}/)
|
126
|
+
end
|
127
|
+
subject.run
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
context 'with an invalid body' do
|
132
|
+
it 'includes invalid body in error message' do
|
133
|
+
response_body = 'I am invalid'
|
134
|
+
http_response_mock = HTTP::Message.new_response(response_body)
|
135
|
+
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
136
|
+
expect(subject).to receive(:exit).with(1)
|
137
|
+
expect(subject).to receive(:output) do |output|
|
138
|
+
expect(output.error_message).to match(/#{response_body}/)
|
139
|
+
end
|
140
|
+
subject.run
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
context 'and the target node is Windows Server 2008 R2' do
|
145
|
+
before(:each) do
|
146
|
+
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>'
|
147
|
+
http_response_mock = HTTP::Message.new_response(ws2008r2_response_body)
|
148
|
+
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'identifies the stack of the product version as 2.0 ' do
|
152
|
+
expect(subject).to receive(:output) do |output|
|
153
|
+
expect(output.product_version).to eq 'OS: 0.0.0 SP: 0.0 Stack: 2.0'
|
154
|
+
end
|
155
|
+
subject.run
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'identifies the protocol version as the current DMTF standard' do
|
159
|
+
expect(subject).to receive(:output) do |output|
|
160
|
+
expect(output.protocol_version).to eq 'http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd'
|
161
|
+
end
|
162
|
+
subject.run
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'identifies the vendor as the Microsoft Corporation' do
|
166
|
+
expect(subject).to receive(:output) do |output|
|
167
|
+
expect(output.product_vendor).to eq 'Microsoft Corporation'
|
168
|
+
end
|
169
|
+
subject.run
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
context 'and the target node is Windows Server 2012 R2' do
|
174
|
+
before(:each) do
|
175
|
+
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>'
|
176
|
+
http_response_mock = HTTP::Message.new_response(ws2012_response_body)
|
177
|
+
allow(http_client_mock).to receive(:post).and_return(http_response_mock)
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'identifies the stack of the product version as 3.0 ' do
|
181
|
+
expect(subject).to receive(:output) do |output|
|
182
|
+
expect(output.product_version).to eq 'OS: 0.0.0 SP: 0.0 Stack: 3.0'
|
183
|
+
end
|
184
|
+
subject.run
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'identifies the protocol version as the current DMTF standard' do
|
188
|
+
expect(subject).to receive(:output) do |output|
|
189
|
+
expect(output.protocol_version).to eq 'http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd'
|
190
|
+
end
|
191
|
+
subject.run
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'identifies the vendor as the Microsoft Corporation' do
|
195
|
+
expect(subject).to receive(:output) do |output|
|
196
|
+
expect(output.product_vendor).to eq 'Microsoft Corporation'
|
197
|
+
end
|
198
|
+
subject.run
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
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.
|
4
|
+
version: 1.4.0
|
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-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: winrm
|
@@ -117,9 +117,28 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.4.
|
120
|
+
rubygems_version: 2.4.7
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: Plugin that adds functionality to Chef's Knife CLI for configuring/interacting
|
124
124
|
with nodes running Microsoft Windows
|
125
|
-
test_files:
|
125
|
+
test_files:
|
126
|
+
- features/knife_help.feature
|
127
|
+
- features/support/env.rb
|
128
|
+
- spec/assets/win_template_rendered_with_bootstrap_install_command.txt
|
129
|
+
- spec/assets/win_template_rendered_with_bootstrap_install_command_on_12_5_client.txt
|
130
|
+
- spec/assets/win_template_rendered_without_bootstrap_install_command.txt
|
131
|
+
- spec/assets/win_template_rendered_without_bootstrap_install_command_on_12_5_client.txt
|
132
|
+
- spec/assets/win_template_unrendered.txt
|
133
|
+
- spec/functional/bootstrap_download_spec.rb
|
134
|
+
- spec/spec_helper.rb
|
135
|
+
- spec/unit/knife/bootstrap_options_spec.rb
|
136
|
+
- spec/unit/knife/bootstrap_template_spec.rb
|
137
|
+
- spec/unit/knife/bootstrap_windows_winrm_spec.rb
|
138
|
+
- spec/unit/knife/core/windows_bootstrap_context_spec.rb
|
139
|
+
- spec/unit/knife/windows_cert_generate_spec.rb
|
140
|
+
- spec/unit/knife/windows_cert_install_spec.rb
|
141
|
+
- spec/unit/knife/windows_listener_create_spec.rb
|
142
|
+
- spec/unit/knife/winrm_session_spec.rb
|
143
|
+
- spec/unit/knife/winrm_spec.rb
|
144
|
+
- spec/unit/knife/wsman_test_spec.rb
|