knife-windows 3.0.6 → 3.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,11 +16,11 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'spec_helper'
19
+ require "spec_helper"
20
20
 
21
21
  describe Chef::Knife::WsmanTest do
22
22
  let(:http_client_mock) { HTTPClient.new }
23
- let(:ssl_policy) { double('DefaultSSLPolicy', :set_custom_certs => nil) }
23
+ let(:ssl_policy) { double("DefaultSSLPolicy", set_custom_certs: nil) }
24
24
 
25
25
  before(:all) do
26
26
  Chef::Config.reset
@@ -32,31 +32,31 @@ describe Chef::Knife::WsmanTest do
32
32
  allow(http_client_mock).to receive(:post).and_return(http_response_mock)
33
33
  allow(HTTPClient).to receive(:new).and_return(http_client_mock)
34
34
  subject.config[:verbosity] = 0
35
- allow(subject.ui).to receive(:ask).and_return('prompted_password')
35
+ allow(subject.ui).to receive(:ask).and_return("prompted_password")
36
36
  allow(Chef::HTTP::DefaultSSLPolicy).to receive(:new)
37
37
  .with(http_client_mock.ssl_config)
38
38
  .and_return(ssl_policy)
39
39
  end
40
40
 
41
- subject { Chef::Knife::WsmanTest.new(['-m', 'localhost']) }
41
+ subject { Chef::Knife::WsmanTest.new(["-m", "localhost"]) }
42
42
 
43
- it 'sets the ssl policy' do
43
+ it "sets the ssl policy" do
44
44
  expect(ssl_policy).to receive(:set_custom_certs).twice
45
45
  subject.run
46
46
  end
47
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
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
52
  expect(subject.ui).to receive(:msg)
53
53
  subject.run
54
54
  end
55
55
  end
56
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'
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
60
  http_response_mock = HTTP::Message.new_response(response_body)
61
61
  allow(http_client_mock).to receive(:post).and_return(http_response_mock)
62
62
  expect(subject.ui).to receive(:warn)
@@ -66,9 +66,9 @@ describe Chef::Knife::WsmanTest do
66
66
  end
67
67
  end
68
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>')
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
72
  http_response_mock.status = 404
73
73
  allow(http_client_mock).to receive(:post).and_return(http_response_mock)
74
74
  expect(subject.ui).to receive(:warn)
@@ -79,25 +79,25 @@ describe Chef::Knife::WsmanTest do
79
79
  end
80
80
  end
81
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.'
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
84
 
85
85
  before(:each) do
86
86
  allow(http_client_mock).to receive(:post).and_raise(Exception.new(error_message))
87
87
  end
88
88
 
89
- it 'exits with a status code of 1' do
89
+ it "exits with a status code of 1" do
90
90
  expect(subject).to receive(:exit).with(1)
91
91
  subject.run
92
92
  end
93
93
 
94
- it 'writes a warning message for each node it fails to connect to' do
94
+ it "writes a warning message for each node it fails to connect to" do
95
95
  expect(subject.ui).to receive(:warn)
96
96
  expect(subject).to receive(:exit).with(1)
97
97
  subject.run
98
98
  end
99
99
 
100
- it 'writes an error message if it fails to connect to any nodes' do
100
+ it "writes an error message if it fails to connect to any nodes" do
101
101
  expect(subject.ui).to receive(:error)
102
102
  expect(subject).to receive(:exit).with(1)
103
103
  subject.run
@@ -105,27 +105,27 @@ describe Chef::Knife::WsmanTest do
105
105
  end
106
106
  end
107
107
 
108
- context 'when not validating ssl cert' do
108
+ context "when not validating ssl cert" do
109
109
  before(:each) do
110
110
  expect(subject.ui).to receive(:msg)
111
111
  subject.config[:winrm_ssl_verify_mode] = :verify_none
112
112
  subject.config[:winrm_transport] = :ssl
113
113
  end
114
114
 
115
- it 'sets verify_mode to verify_none' do
115
+ it "sets verify_mode to verify_none" do
116
116
  subject.run
117
117
  expect(http_client_mock.ssl_config.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
118
118
  end
119
119
  end
120
120
 
121
- context 'when testing the WSMAN endpoint with verbose output' do
121
+ context "when testing the WSMAN endpoint with verbose output" do
122
122
  before(:each) do
123
123
  subject.config[:verbosity] = 1
124
124
  end
125
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.'
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
129
  allow(http_client_mock).to receive(:post).and_raise(Exception.new(error_message))
130
130
  expect(subject).to receive(:exit).with(1)
131
131
  expect(subject).to receive(:output) do |output|
@@ -135,9 +135,9 @@ describe Chef::Knife::WsmanTest do
135
135
  end
136
136
  end
137
137
 
138
- context 'with an invalid body' do
139
- it 'includes invalid body in error message' do
140
- response_body = 'I am invalid'
138
+ context "with an invalid body" do
139
+ it "includes invalid body in error message" do
140
+ response_body = "I am invalid"
141
141
  http_response_mock = HTTP::Message.new_response(response_body)
142
142
  allow(http_client_mock).to receive(:post).and_return(http_response_mock)
143
143
  expect(subject).to receive(:exit).with(1)
@@ -148,59 +148,59 @@ describe Chef::Knife::WsmanTest do
148
148
  end
149
149
  end
150
150
 
151
- context 'and the target node is Windows Server 2008 R2' do
151
+ context "and the target node is Windows Server 2008 R2" do
152
152
  before(:each) do
153
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
154
  http_response_mock = HTTP::Message.new_response(ws2008r2_response_body)
155
155
  allow(http_client_mock).to receive(:post).and_return(http_response_mock)
156
156
  end
157
157
 
158
- it 'identifies the stack of the product version as 2.0 ' do
158
+ it "identifies the stack of the product version as 2.0 " do
159
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'
160
+ expect(output.product_version).to eq "OS: 0.0.0 SP: 0.0 Stack: 2.0"
161
161
  end
162
162
  subject.run
163
163
  end
164
164
 
165
- it 'identifies the protocol version as the current DMTF standard' do
165
+ it "identifies the protocol version as the current DMTF standard" do
166
166
  expect(subject).to receive(:output) do |output|
167
- expect(output.protocol_version).to eq 'http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd'
167
+ expect(output.protocol_version).to eq "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"
168
168
  end
169
169
  subject.run
170
170
  end
171
171
 
172
- it 'identifies the vendor as the Microsoft Corporation' do
172
+ it "identifies the vendor as the Microsoft Corporation" do
173
173
  expect(subject).to receive(:output) do |output|
174
- expect(output.product_vendor).to eq 'Microsoft Corporation'
174
+ expect(output.product_vendor).to eq "Microsoft Corporation"
175
175
  end
176
176
  subject.run
177
177
  end
178
178
  end
179
179
 
180
- context 'and the target node is Windows Server 2012 R2' do
180
+ context "and the target node is Windows Server 2012 R2" do
181
181
  before(:each) do
182
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
183
  http_response_mock = HTTP::Message.new_response(ws2012_response_body)
184
184
  allow(http_client_mock).to receive(:post).and_return(http_response_mock)
185
185
  end
186
186
 
187
- it 'identifies the stack of the product version as 3.0 ' do
187
+ it "identifies the stack of the product version as 3.0 " do
188
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'
189
+ expect(output.product_version).to eq "OS: 0.0.0 SP: 0.0 Stack: 3.0"
190
190
  end
191
191
  subject.run
192
192
  end
193
193
 
194
- it 'identifies the protocol version as the current DMTF standard' do
194
+ it "identifies the protocol version as the current DMTF standard" do
195
195
  expect(subject).to receive(:output) do |output|
196
- expect(output.protocol_version).to eq 'http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd'
196
+ expect(output.protocol_version).to eq "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"
197
197
  end
198
198
  subject.run
199
199
  end
200
200
 
201
- it 'identifies the vendor as the Microsoft Corporation' do
201
+ it "identifies the vendor as the Microsoft Corporation" do
202
202
  expect(subject).to receive(:output) do |output|
203
- expect(output.product_vendor).to eq 'Microsoft Corporation'
203
+ expect(output.product_vendor).to eq "Microsoft Corporation"
204
204
  end
205
205
  subject.run
206
206
  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: 3.0.6
4
+ version: 3.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Chisamore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-21 00:00:00.000000000 Z
11
+ date: 2020-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef