knife-cloud 1.2.1 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +1 -1
- data/lib/chef/knife/cloud/chefbootstrap/bootstrap_distribution.rb +2 -2
- data/lib/chef/knife/cloud/chefbootstrap/bootstrap_options.rb +115 -133
- data/lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb +6 -6
- data/lib/chef/knife/cloud/chefbootstrap/bootstrapper.rb +11 -12
- data/lib/chef/knife/cloud/chefbootstrap/ssh_bootstrap_protocol.rb +49 -54
- data/lib/chef/knife/cloud/chefbootstrap/unix_distribution.rb +3 -3
- data/lib/chef/knife/cloud/chefbootstrap/windows_distribution.rb +3 -3
- data/lib/chef/knife/cloud/chefbootstrap/winrm_bootstrap_protocol.rb +11 -12
- data/lib/chef/knife/cloud/command.rb +24 -27
- data/lib/chef/knife/cloud/exceptions.rb +1 -2
- data/lib/chef/knife/cloud/fog/options.rb +8 -8
- data/lib/chef/knife/cloud/fog/service.rb +54 -60
- data/lib/chef/knife/cloud/helpers.rb +2 -3
- data/lib/chef/knife/cloud/list_resource_command.rb +6 -7
- data/lib/chef/knife/cloud/list_resource_options.rb +5 -5
- data/lib/chef/knife/cloud/server/create_command.rb +30 -35
- data/lib/chef/knife/cloud/server/create_options.rb +33 -34
- data/lib/chef/knife/cloud/server/delete_command.rb +12 -15
- data/lib/chef/knife/cloud/server/delete_options.rb +7 -8
- data/lib/chef/knife/cloud/server/list_command.rb +22 -22
- data/lib/chef/knife/cloud/server/list_options.rb +9 -10
- data/lib/chef/knife/cloud/server/options.rb +7 -7
- data/lib/chef/knife/cloud/server/show_command.rb +5 -5
- data/lib/chef/knife/cloud/server/show_options.rb +5 -6
- data/lib/chef/knife/cloud/service.rb +12 -13
- data/lib/knife-cloud/version.rb +2 -2
- data/lib/test/fixtures/knife.rb +3 -3
- data/lib/test/fixtures/validation.pem +27 -0
- data/lib/test/knife-utils/helper.rb +11 -11
- data/lib/test/knife-utils/knife_test_utils.rb +4 -4
- data/lib/test/knife-utils/matchers.rb +3 -3
- data/lib/test/knife-utils/test_bed.rb +38 -38
- data/lib/test/templates/windows-chef-client-msi.erb +3 -4
- data/lib/test/templates/windows-shell.erb +2 -2
- metadata +12 -152
- data/.gitignore +0 -33
- data/.travis.yml +0 -6
- data/CHANGELOG.md +0 -133
- data/CONTRIBUTING.md +0 -5
- data/Gemfile +0 -9
- data/README.md +0 -421
- data/Rakefile +0 -35
- data/ci.gemfile +0 -18
- data/knife-cloud.gemspec +0 -26
- data/spec/resource_spec_helper.rb +0 -49
- data/spec/server_command_common_spec_helper.rb +0 -48
- data/spec/spec_helper.rb +0 -25
- data/spec/support/shared_examples_for_command.rb +0 -35
- data/spec/support/shared_examples_for_servercreatecommand.rb +0 -144
- data/spec/support/shared_examples_for_serverdeletecommand.rb +0 -77
- data/spec/support/shared_examples_for_service.rb +0 -85
- data/spec/unit/bootstrap_protocol_spec.rb +0 -98
- data/spec/unit/bootstrapper_spec.rb +0 -171
- data/spec/unit/cloud_command_spec.rb +0 -35
- data/spec/unit/command_spec.rb +0 -49
- data/spec/unit/fog_service_spec.rb +0 -163
- data/spec/unit/list_resource_command_spec.rb +0 -140
- data/spec/unit/server_create_command_spec.rb +0 -198
- data/spec/unit/server_delete_command_spec.rb +0 -25
- data/spec/unit/server_list_command_spec.rb +0 -119
- data/spec/unit/server_show_command_spec.rb +0 -64
- data/spec/unit/service_spec.rb +0 -46
- data/spec/unit/ssh_bootstrap_protocol_spec.rb +0 -116
- data/spec/unit/unix_distribution_spec.rb +0 -37
- data/spec/unit/windows_distribution_spec.rb +0 -37
- data/spec/unit/winrm_bootstrap_protocol_spec.rb +0 -108
@@ -1,64 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
|
3
|
-
# Copyright:: Copyright (c) 2013-2014 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
|
-
require 'support/shared_examples_for_command'
|
19
|
-
require 'chef/knife/cloud/server/show_command'
|
20
|
-
|
21
|
-
describe Chef::Knife::Cloud::ServerShowCommand do
|
22
|
-
it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::ServerShowCommand.new
|
23
|
-
|
24
|
-
describe "#validate_params!" do
|
25
|
-
before(:each) do
|
26
|
-
@instance = Chef::Knife::Cloud::ServerShowCommand.new
|
27
|
-
allow(@instance.ui).to receive(:error)
|
28
|
-
Chef::Config[:knife][:instance_id] = "instance_id"
|
29
|
-
end
|
30
|
-
after(:all) do
|
31
|
-
Chef::Config[:knife].delete(:instance_id)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "run sucessfully on all params exist" do
|
35
|
-
expect { @instance.validate_params! }.to_not raise_error
|
36
|
-
end
|
37
|
-
|
38
|
-
it "raise error on missing instance_id param" do
|
39
|
-
Chef::Config[:knife].delete(:instance_id)
|
40
|
-
expect { @instance.validate_params! }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ValidationError, " You must provide a valid Instance Id.")
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "#execute_command" do
|
45
|
-
it "show server summary" do
|
46
|
-
instance = Chef::Knife::Cloud::ServerShowCommand.new
|
47
|
-
instance.service = Chef::Knife::Cloud::Service.new
|
48
|
-
server = Object.new
|
49
|
-
expect(instance.service).to receive(:get_server).and_return(server)
|
50
|
-
expect(instance.service).to receive(:server_summary)
|
51
|
-
instance.execute_command
|
52
|
-
end
|
53
|
-
|
54
|
-
it "raise error on invalid instance id" do
|
55
|
-
instance = Chef::Knife::Cloud::ServerShowCommand.new
|
56
|
-
instance.service = Chef::Knife::Cloud::Service.new
|
57
|
-
Chef::Config[:knife][:instance_id] = "invalid_id"
|
58
|
-
allow(instance.ui).to receive(:error)
|
59
|
-
expect(instance.service).to receive(:get_server).and_return(nil)
|
60
|
-
expect(instance.service).to_not receive(:server_summary)
|
61
|
-
expect { instance.execute_command }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ServerShowError, "Server doesn't exists for this invalid_id instance id.")
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
data/spec/unit/service_spec.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Prabhu Das (<prabhu.das@clogeny.com>)
|
3
|
-
# Copyright:: Copyright (c) 2013-2014 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
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
19
|
-
require 'chef/knife/cloud/service'
|
20
|
-
|
21
|
-
|
22
|
-
describe Chef::Knife::Cloud::Service do
|
23
|
-
|
24
|
-
let (:instance) { Chef::Knife::Cloud::Service.new }
|
25
|
-
|
26
|
-
it { expect {instance}.to_not raise_error }
|
27
|
-
|
28
|
-
it { expect {instance.connection}.to raise_error(Chef::Exceptions::Override, "You must override connection in #{instance.to_s}") }
|
29
|
-
|
30
|
-
it { expect {instance.create_server}.to raise_error(Chef::Exceptions::Override, "You must override create_server in #{instance.to_s}") }
|
31
|
-
|
32
|
-
it { expect {instance.delete_server(:server_name)}.to raise_error(Chef::Exceptions::Override, "You must override delete_server in #{instance.to_s}") }
|
33
|
-
|
34
|
-
it { expect {instance.delete_server}.to raise_error(ArgumentError, "wrong number of arguments (0 for 1)") }
|
35
|
-
|
36
|
-
it { expect {instance.list_servers}.to raise_error(Chef::Exceptions::Override, "You must override list_servers in #{instance.to_s}") }
|
37
|
-
|
38
|
-
it { expect {instance.list_images}.to raise_error(ArgumentError, "wrong number of arguments (0 for 1)") }
|
39
|
-
|
40
|
-
it { expect {instance.list_images(:image_filters)}.to raise_error(Chef::Exceptions::Override, "You must override list_images in #{instance.to_s}") }
|
41
|
-
|
42
|
-
it { expect {instance.list_resource_configurations()}.to raise_error(Chef::Exceptions::Override, "You must override list_resource_configurations in #{instance.to_s}") }
|
43
|
-
|
44
|
-
it { expect { Chef::Knife::Cloud::Service.new({:auth_params => {:provider => 'Any Cloud Provider'}}) }.to_not raise_error }
|
45
|
-
|
46
|
-
end
|
@@ -1,116 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
|
3
|
-
# Copyright:: Copyright (c) 2013-2014 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
|
-
require 'spec_helper'
|
19
|
-
require 'chef/knife/cloud/chefbootstrap/ssh_bootstrap_protocol'
|
20
|
-
require 'chef/knife/bootstrap_windows_ssh'
|
21
|
-
|
22
|
-
describe Chef::Knife::Cloud::SshBootstrapProtocol do
|
23
|
-
before do
|
24
|
-
@config = {:bootstrap_protocol => 'ssh'}
|
25
|
-
@instance = Chef::Knife::Cloud::SshBootstrapProtocol.new(@config)
|
26
|
-
allow(@instance).to receive(:sleep).and_return(0)
|
27
|
-
allow(@instance).to receive(:print)
|
28
|
-
end
|
29
|
-
|
30
|
-
context "Create instance" do
|
31
|
-
it "asks for compulsory properties" do
|
32
|
-
expect {Chef::Knife::Cloud::SshBootstrapProtocol.new}.to raise_error(ArgumentError)
|
33
|
-
end
|
34
|
-
|
35
|
-
it "non windows image" do
|
36
|
-
@config[:image_os_type] = 'linux'
|
37
|
-
ssh_bootstrap_protocol = Chef::Knife::Cloud::SshBootstrapProtocol.new(@config)
|
38
|
-
expect(ssh_bootstrap_protocol.bootstrap.class).to eq(Chef::Knife::Bootstrap)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "windows image" do
|
42
|
-
@config[:image_os_type] = 'windows'
|
43
|
-
ssh_bootstrap_protocol = Chef::Knife::Cloud::SshBootstrapProtocol.new(@config)
|
44
|
-
expect(ssh_bootstrap_protocol.bootstrap.class).to eq(Chef::Knife::BootstrapWindowsSsh)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "#wait_for_server_ready" do
|
49
|
-
it "execute with correct method calls" do
|
50
|
-
allow(@instance).to receive(:tcp_test_ssh).and_return(true)
|
51
|
-
expect(@instance).to receive(:tcp_test_ssh).ordered
|
52
|
-
@instance.wait_for_server_ready
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe "#init_bootstrap_options" do
|
57
|
-
it "set correct bootstrap config" do
|
58
|
-
@config[:bootstrap_ip_address] = "127.0.0.1"
|
59
|
-
@config[:chef_node_name] = "testnode"
|
60
|
-
@config[:environment] = "_default"
|
61
|
-
@config[:ssh_user] = "testuser"
|
62
|
-
@config[:ssh_gateway] = "ssh_gateway"
|
63
|
-
@config[:forward_agent] = true
|
64
|
-
@config[:use_sudo_password] = true
|
65
|
-
allow(@config).to receive(:locate_config_value).and_return({})
|
66
|
-
@instance.bootstrap = Chef::Knife::Bootstrap.new
|
67
|
-
@instance.init_bootstrap_options
|
68
|
-
expect(@instance.bootstrap.name_args).to eq([@config[:bootstrap_ip_address]])
|
69
|
-
expect(@instance.bootstrap.config[:chef_node_name]).to eq(@config[:chef_node_name])
|
70
|
-
expect(@instance.bootstrap.config[:environment]).to eq(@config[:environment])
|
71
|
-
expect(@instance.bootstrap.config[:ssh_user]).to eq(@config[:ssh_user])
|
72
|
-
expect(@instance.bootstrap.config[:forward_agent]).to be(true)
|
73
|
-
expect(@instance.bootstrap.config[:use_sudo_password]).to be(true)
|
74
|
-
expect(@instance.bootstrap.config[:ssh_gateway]).to eq(@config[:ssh_gateway])
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe "#tcp_test_ssh" do
|
79
|
-
|
80
|
-
it "return true" do
|
81
|
-
tcpSocket = double()
|
82
|
-
allow(tcpSocket).to receive(:close).and_return(true)
|
83
|
-
allow(tcpSocket).to receive(:gets).and_return(true)
|
84
|
-
allow(TCPSocket).to receive(:new).and_return(tcpSocket)
|
85
|
-
allow(IO).to receive(:select).and_return(true)
|
86
|
-
allow(tcpSocket.gets).to receive(:nil?).and_return(false)
|
87
|
-
allow(tcpSocket.gets).to receive(:empty?).and_return(false)
|
88
|
-
expect(@instance.tcp_test_ssh("localhost","22"){}).to be(true)
|
89
|
-
end
|
90
|
-
|
91
|
-
it "raise ETIMEDOUT error" do
|
92
|
-
allow(TCPSocket).to receive(:new).and_raise(Errno::ETIMEDOUT)
|
93
|
-
expect(@instance.tcp_test_ssh("localhost","22"){}).to be(false)
|
94
|
-
end
|
95
|
-
|
96
|
-
it "raise EPERM error" do
|
97
|
-
allow(TCPSocket).to receive(:new).and_raise(Errno::EPERM)
|
98
|
-
expect(@instance.tcp_test_ssh("localhost","22"){}).to be(false)
|
99
|
-
end
|
100
|
-
|
101
|
-
it "raise ECONNREFUSED error" do
|
102
|
-
allow(TCPSocket).to receive(:new).and_raise(Errno::ECONNREFUSED)
|
103
|
-
expect(@instance.tcp_test_ssh("localhost","22"){}).to be(false)
|
104
|
-
end
|
105
|
-
|
106
|
-
it "raise EHOSTUNREACH error" do
|
107
|
-
allow(TCPSocket).to receive(:new).and_raise(Errno::EHOSTUNREACH)
|
108
|
-
expect(@instance.tcp_test_ssh("localhost","22"){}).to be(false)
|
109
|
-
end
|
110
|
-
|
111
|
-
it "raise ENETUNREACH error" do
|
112
|
-
allow(TCPSocket).to receive(:new).and_raise(Errno::ENETUNREACH)
|
113
|
-
expect(@instance.tcp_test_ssh("localhost","22"){}).to be(false)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Prabhu Das (<prabhu.das@clogeny.com>)
|
3
|
-
# Copyright:: Copyright (c) 2013 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
|
-
require 'spec_helper'
|
19
|
-
require 'chef/knife/cloud/chefbootstrap/unix_distribution'
|
20
|
-
|
21
|
-
describe Chef::Knife::Cloud::UnixDistribution do
|
22
|
-
|
23
|
-
before do
|
24
|
-
@config = {:bootstrap_protocol => 'ssh'}
|
25
|
-
end
|
26
|
-
|
27
|
-
context "Unix Distribution initializer" do
|
28
|
-
it "asks for compulsory properties while creating instance" do
|
29
|
-
expect {Chef::Knife::Cloud::UnixDistribution.new}.to raise_error(ArgumentError)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "creates instance" do
|
33
|
-
expect {Chef::Knife::Cloud::UnixDistribution.new(@config)}.to_not raise_error
|
34
|
-
expect(Chef::Knife::Cloud::UnixDistribution.new(@config).class).to eq(Chef::Knife::Cloud::UnixDistribution)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Prabhu Das (<prabhu.das@clogeny.com>)
|
3
|
-
# Copyright:: Copyright (c) 2013 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
|
-
require 'spec_helper'
|
19
|
-
require 'chef/knife/cloud/chefbootstrap/windows_distribution'
|
20
|
-
|
21
|
-
describe Chef::Knife::Cloud::WindowsDistribution do
|
22
|
-
|
23
|
-
before do
|
24
|
-
@config = {:bootstrap_protocol => 'winrm'}
|
25
|
-
end
|
26
|
-
|
27
|
-
context "Windows Distribution initializer" do
|
28
|
-
it "asks for compulsory properties while creating instance" do
|
29
|
-
expect {Chef::Knife::Cloud::WindowsDistribution.new}.to raise_error(ArgumentError)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "creates instance" do
|
33
|
-
expect {Chef::Knife::Cloud::WindowsDistribution.new(@config)}.to_not raise_error
|
34
|
-
expect(Chef::Knife::Cloud::WindowsDistribution.new(@config).class).to eq(Chef::Knife::Cloud::WindowsDistribution)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,108 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
|
3
|
-
# Copyright:: Copyright (c) 2013-2014 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
|
-
require 'spec_helper'
|
19
|
-
require 'chef/knife/cloud/chefbootstrap/winrm_bootstrap_protocol'
|
20
|
-
|
21
|
-
describe Chef::Knife::Cloud::WinrmBootstrapProtocol do
|
22
|
-
before do
|
23
|
-
@config = {:bootstrap_protocol => 'winrm'}
|
24
|
-
@config = {:image_os_type => 'windows'}
|
25
|
-
@instance = Chef::Knife::Cloud::WinrmBootstrapProtocol.new(@config)
|
26
|
-
allow(@instance).to receive(:sleep).and_return(0)
|
27
|
-
allow(@instance).to receive(:print)
|
28
|
-
end
|
29
|
-
|
30
|
-
context "Create instance" do
|
31
|
-
it "asks for compulsory properties" do
|
32
|
-
expect {Chef::Knife::Cloud::WinrmBootstrapProtocol.new}.to raise_error(ArgumentError)
|
33
|
-
end
|
34
|
-
|
35
|
-
it "windows image" do
|
36
|
-
@config[:image_os_type] = 'windows'
|
37
|
-
winrm_bootstrap_protocol = Chef::Knife::Cloud::WinrmBootstrapProtocol.new(@config)
|
38
|
-
expect(winrm_bootstrap_protocol.bootstrap.class).to eq(Chef::Knife::BootstrapWindowsWinrm)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "#wait_for_server_ready" do
|
43
|
-
it "execute with correct method calls" do
|
44
|
-
@config[:image_os_type] = 'windows'
|
45
|
-
allow(@instance).to receive(:tcp_test_winrm).and_return(true)
|
46
|
-
expect(@instance).to receive(:tcp_test_winrm).ordered
|
47
|
-
@instance.wait_for_server_ready
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "#init_bootstrap_options" do
|
52
|
-
it "set correct bootstrap config" do
|
53
|
-
@config[:bootstrap_ip_address] = "127.0.0.1"
|
54
|
-
@config[:chef_node_name] = "testnode"
|
55
|
-
@config[:environment] = "_default"
|
56
|
-
@config[:winrm_user] = "testuser"
|
57
|
-
@config[:auth_timeout] = "100"
|
58
|
-
@config[:winrm_ssl_verify_mode] = "verify_none"
|
59
|
-
@instance.bootstrap = Chef::Knife::Bootstrap.new
|
60
|
-
@instance.init_bootstrap_options
|
61
|
-
expect(@instance.bootstrap.name_args).to eq([@config[:bootstrap_ip_address]])
|
62
|
-
expect(@instance.bootstrap.config[:chef_node_name]).to eq(@config[:chef_node_name])
|
63
|
-
expect(@instance.bootstrap.config[:environment]).to eq(@config[:environment])
|
64
|
-
expect(@instance.bootstrap.config[:winrm_user]).to eq(@config[:winrm_user])
|
65
|
-
expect(@instance.bootstrap.config[:auth_timeout]).to eq(@config[:auth_timeout])
|
66
|
-
expect(@instance.bootstrap.config[:winrm_ssl_verify_mode]).to eq(@config[:winrm_ssl_verify_mode])
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe "#tcp_test_winrm" do
|
71
|
-
it "return true" do
|
72
|
-
tcpSocket = double()
|
73
|
-
allow(tcpSocket).to receive(:close).and_return(true)
|
74
|
-
allow(TCPSocket).to receive(:new).and_return(tcpSocket)
|
75
|
-
expect(@instance.tcp_test_winrm("localhost","5989")).to be(true)
|
76
|
-
end
|
77
|
-
|
78
|
-
it "raise SocketError error" do
|
79
|
-
allow(TCPSocket).to receive(:new).and_raise(SocketError)
|
80
|
-
expect(@instance.tcp_test_winrm("localhost","5989")).to be(false)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "raise ETIMEDOUT error" do
|
84
|
-
allow(TCPSocket).to receive(:new).and_raise(Errno::ETIMEDOUT)
|
85
|
-
expect(@instance.tcp_test_winrm("localhost","5989")).to be(false)
|
86
|
-
end
|
87
|
-
|
88
|
-
it "raise EPERM error" do
|
89
|
-
allow(TCPSocket).to receive(:new).and_raise(Errno::EPERM)
|
90
|
-
expect(@instance.tcp_test_winrm("localhost","5989"){raise Errno::EPERM}).to be(false)
|
91
|
-
end
|
92
|
-
|
93
|
-
it "raise ECONNREFUSED error" do
|
94
|
-
allow(TCPSocket).to receive(:new).and_raise(Errno::ECONNREFUSED)
|
95
|
-
expect(@instance.tcp_test_winrm("localhost","5989"){raise Errno::ECONNREFUSED}).to be(false)
|
96
|
-
end
|
97
|
-
|
98
|
-
it "raise EHOSTUNREACH error" do
|
99
|
-
allow(TCPSocket).to receive(:new).and_raise(Errno::EHOSTUNREACH)
|
100
|
-
expect(@instance.tcp_test_winrm("localhost","5989"){raise Errno::EHOSTUNREACH}).to be(false)
|
101
|
-
end
|
102
|
-
|
103
|
-
it "raise ENETUNREACH error" do
|
104
|
-
allow(TCPSocket).to receive(:new).and_raise(Errno::ENETUNREACH)
|
105
|
-
expect(@instance.tcp_test_winrm("localhost","5989"){raise Errno::ENETUNREACH}).to be(false)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|