ohai 8.14.0 → 8.15.0

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.
@@ -21,21 +21,19 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
21
21
  require "open-uri"
22
22
 
23
23
  describe Ohai::System, "plugin eucalyptus" do
24
- before(:each) do
25
- @plugin = get_plugin("eucalyptus")
26
- end
24
+ let(:plugin) { get_plugin("eucalyptus") }
27
25
 
28
26
  shared_examples_for "!eucalyptus" do
29
- it "should NOT attempt to fetch the eucalyptus metadata" do
27
+ it "does NOT attempt to fetch the eucalyptus metadata" do
30
28
  expect(OpenURI).not_to receive(:open)
31
- @plugin.run
29
+ plugin.run
32
30
  end
33
31
  end
34
32
 
35
33
  shared_examples_for "eucalyptus" do
36
34
  before(:each) do
37
35
  @http_client = double("Net::HTTP client")
38
- allow(@plugin).to receive(:http_client).and_return(@http_client)
36
+ allow(plugin).to receive(:http_client).and_return(@http_client)
39
37
 
40
38
  expect(@http_client).to receive(:get).
41
39
  with("/").twice.
@@ -57,69 +55,50 @@ describe Ohai::System, "plugin eucalyptus" do
57
55
  and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
58
56
  end
59
57
 
60
- it "should recursively fetch all the eucalyptus metadata" do
58
+ it "recursively fetches all the eucalyptus metadata" do
61
59
  allow(IO).to receive(:select).and_return([[], [1], []])
62
60
  t = double("connection")
63
61
  allow(t).to receive(:connect_nonblock).and_raise(Errno::EINPROGRESS)
64
62
  allow(Socket).to receive(:new).and_return(t)
65
- @plugin.run
66
- expect(@plugin[:eucalyptus]).not_to be_nil
67
- expect(@plugin[:eucalyptus]["instance_type"]).to eq("c1.medium")
68
- expect(@plugin[:eucalyptus]["ami_id"]).to eq("ami-5d2dc934")
69
- expect(@plugin[:eucalyptus]["security_groups"]).to eql %w{group1 group2}
63
+ plugin.run
64
+ expect(plugin[:eucalyptus]).not_to be_nil
65
+ expect(plugin[:eucalyptus]["instance_type"]).to eq("c1.medium")
66
+ expect(plugin[:eucalyptus]["ami_id"]).to eq("ami-5d2dc934")
67
+ expect(plugin[:eucalyptus]["security_groups"]).to eql %w{group1 group2}
70
68
  end
71
69
  end
72
70
 
73
71
  describe "with eucalyptus mac and metadata address connected" do
74
- it_should_behave_like "eucalyptus"
72
+ it_behaves_like "eucalyptus"
75
73
 
76
74
  before(:each) do
77
75
  allow(IO).to receive(:select).and_return([[], [1], []])
78
- @plugin[:network] = { "interfaces" => { "eth0" => { "addresses" => { "d0:0d:95:47:6E:ED" => { "family" => "lladdr" } } } } }
76
+ plugin[:network] = { "interfaces" => { "eth0" => { "addresses" => { "d0:0d:95:47:6E:ED" => { "family" => "lladdr" } } } } }
79
77
  end
80
78
  end
81
79
 
82
80
  describe "without eucalyptus mac and metadata address connected" do
83
- it_should_behave_like "!eucalyptus"
81
+ it_behaves_like "!eucalyptus"
84
82
 
85
83
  before(:each) do
86
- @plugin[:network] = { "interfaces" => { "eth0" => { "addresses" => { "ff:ff:95:47:6E:ED" => { "family" => "lladdr" } } } } }
84
+ plugin[:network] = { "interfaces" => { "eth0" => { "addresses" => { "ff:ff:95:47:6E:ED" => { "family" => "lladdr" } } } } }
87
85
  end
88
86
  end
89
87
 
90
- describe "with eucalyptus cloud file" do
91
- it_should_behave_like "eucalyptus"
88
+ describe "with eucalyptus hint file" do
89
+ it_behaves_like "eucalyptus"
92
90
 
93
91
  before(:each) do
94
- allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/eucalyptus.json").and_return(true)
95
- allow(File).to receive(:read).with("/etc/chef/ohai/hints/eucalyptus.json").and_return("")
96
- allow(File).to receive(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(true)
97
- allow(File).to receive(:read).with('C:\chef\ohai\hints/eucalyptus.json').and_return("")
92
+ allow(plugin).to receive(:hint?).with("eucalyptus").and_return(true)
98
93
  end
99
94
  end
100
95
 
101
- describe "without cloud file" do
102
- it_should_behave_like "!eucalyptus"
96
+ describe "without hint file" do
97
+ it_behaves_like "!eucalyptus"
103
98
 
104
99
  before(:each) do
105
- @plugin[:network] = { :interfaces => {} }
106
- allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/eucalyptus.json").and_return(false)
107
- allow(File).to receive(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(false)
108
- end
109
- end
110
-
111
- describe "with ec2 cloud file" do
112
- it_should_behave_like "!eucalyptus"
113
-
114
- before(:each) do
115
- @plugin[:network] = { :interfaces => {} }
116
-
117
- allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/eucalyptus.json").and_return(false)
118
- allow(File).to receive(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(false)
119
- allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true)
120
- allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/ec2.json").and_return(true)
121
- allow(File).to receive(:read).with("/etc/chef/ohai/hints/ec2.json").and_return("")
122
- allow(File).to receive(:read).with('C:\chef\ohai\hints/ec2.json').and_return("")
100
+ plugin[:network] = { :interfaces => {} }
101
+ allow(plugin).to receive(:hint?).with("eucalyptus").and_return(false)
123
102
  end
124
103
  end
125
104
 
@@ -19,26 +19,24 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
19
19
  require "open-uri"
20
20
 
21
21
  describe Ohai::System, "plugin gce" do
22
- before(:each) do
23
- @plugin = get_plugin("gce")
24
- end
22
+ let(:plugin) { get_plugin("gce") }
25
23
 
26
24
  shared_examples_for "!gce" do
27
- it "should NOT attempt to fetch the gce metadata" do
28
- expect(@plugin).not_to receive(:http_get)
29
- @plugin.run
25
+ it "does NOT attempt to fetch the gce metadata" do
26
+ expect(plugin).not_to receive(:http_get)
27
+ plugin.run
30
28
  end
31
29
 
32
- it "should NOT set gce attributes" do
33
- expect(@plugin[:gce]).to be_nil
34
- @plugin.run
30
+ it "does NOT set gce attributes" do
31
+ expect(plugin[:gce]).to be_nil
32
+ plugin.run
35
33
  end
36
34
  end
37
35
 
38
36
  shared_examples_for "gce" do
39
37
  before(:each) do
40
38
  @http_get = double("Net::HTTP client")
41
- allow(@plugin).to receive(:http_get).and_return(double("Net::HTTP Response", :body => '{"instance":{"hostname":"test-host"}}', :code => "200"))
39
+ allow(plugin).to receive(:http_get).and_return(double("Net::HTTP Response", :body => '{"instance":{"hostname":"test-host"}}', :code => "200"))
42
40
  allow(IO).to receive(:select).and_return([[], [1], []])
43
41
  t = double("connection")
44
42
  allow(t).to receive(:connect_nonblock).and_raise(Errno::EINPROGRESS)
@@ -46,32 +44,28 @@ describe Ohai::System, "plugin gce" do
46
44
  allow(Socket).to receive(:pack_sockaddr_in).and_return(nil)
47
45
  end
48
46
 
49
- it "should recursively fetch and properly parse json metadata" do
50
- @plugin.run
47
+ it "recursively fetches and properly parses json metadata" do
48
+ plugin.run
51
49
 
52
- expect(@plugin[:gce]).not_to be_nil
53
- expect(@plugin[:gce]["instance"]).to eq("hostname" => "test-host")
50
+ expect(plugin[:gce]).not_to be_nil
51
+ expect(plugin[:gce]["instance"]).to eq("hostname" => "test-host")
54
52
  end
55
53
 
56
54
  end
57
55
 
58
56
  describe "with hint file and with metadata connection" do
59
- it_should_behave_like "gce"
57
+ it_behaves_like "gce"
60
58
 
61
59
  before(:each) do
62
- allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/gce.json").and_return(true)
63
- allow(File).to receive(:read).with("/etc/chef/ohai/hints/gce.json").and_return("")
64
- allow(File).to receive(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(true)
65
- allow(File).to receive(:read).with('C:\chef\ohai\hints/gce.json').and_return("")
60
+ allow(plugin).to receive(:hint?).with("gce").and_return({})
66
61
  end
67
62
  end
68
63
 
69
64
  describe "without hint file and without metadata connection" do
70
- it_should_behave_like "!gce"
65
+ it_behaves_like "!gce"
71
66
 
72
67
  before(:each) do
73
- allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/gce.json").and_return(false)
74
- allow(File).to receive(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(false)
68
+ allow(plugin).to receive(:hint?).with("gce").and_return(false)
75
69
 
76
70
  # Raise Errno::ENOENT to simulate the scenario in which metadata server
77
71
  # can not be connected
@@ -18,12 +18,10 @@
18
18
  require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
19
19
 
20
20
  describe Ohai::System, "plugin linode" do
21
- let(:hint_path_nix) { "/etc/chef/ohai/hints/linode.json" }
22
- let(:hint_path_win) { 'C:\chef\ohai\hints/linode.json' }
21
+ let(:plugin) { get_plugin("linode") }
23
22
 
24
23
  before do
25
- @plugin = get_plugin("linode")
26
- @plugin[:network] = {
24
+ plugin[:network] = {
27
25
  "interfaces" => {
28
26
  "eth0" => {
29
27
  "addresses" => {
@@ -48,49 +46,49 @@ describe Ohai::System, "plugin linode" do
48
46
 
49
47
  shared_examples_for "!linode" do
50
48
  it "does not create the linode mash" do
51
- @plugin.run
52
- expect(@plugin[:linode]).to be_nil
49
+ plugin.run
50
+ expect(plugin[:linode]).to be_nil
53
51
  end
54
52
  end
55
53
 
56
54
  shared_examples_for "linode" do
57
- it "creates a linode mash" do
58
- @plugin.run
59
- expect(@plugin[:linode]).not_to be_nil
55
+ it "creates the linode mash" do
56
+ plugin.run
57
+ expect(plugin[:linode]).not_to be_nil
60
58
  end
61
59
 
62
- it "has all required attributes" do
63
- @plugin.run
64
- expect(@plugin[:linode][:public_ip]).not_to be_nil
60
+ it "has public_ip attribute" do
61
+ plugin.run
62
+ expect(plugin[:linode][:public_ip]).not_to be_nil
65
63
  end
66
64
 
67
- it "has correct values for all attributes" do
68
- @plugin.run
69
- expect(@plugin[:linode][:public_ip]).to eq("1.2.3.4")
65
+ it "has correct value for public_ip attribute" do
66
+ plugin.run
67
+ expect(plugin[:linode][:public_ip]).to eq("1.2.3.4")
70
68
  end
71
69
 
72
70
  end
73
71
 
74
72
  context "without linode kernel" do
75
73
  before do
76
- @plugin[:kernel] = { "release" => "3.5.2-x86_64" }
74
+ plugin[:kernel] = { "release" => "3.5.2-x86_64" }
77
75
  end
78
76
 
79
- it_should_behave_like "!linode"
77
+ it_behaves_like "!linode"
80
78
  end
81
79
 
82
80
  context "with linode kernel" do
83
81
  before do
84
- @plugin[:kernel] = { "release" => "3.5.2-x86_64-linode24" }
82
+ plugin[:kernel] = { "release" => "3.5.2-x86_64-linode24" }
85
83
  end
86
84
 
87
- it_should_behave_like "linode"
85
+ it_behaves_like "linode"
88
86
 
89
87
  # This test is an interface created according to this guide by Linode
90
88
  # http://library.linode.com/networking/configuring-static-ip-interfaces
91
89
  context "with configured private ip address as suggested by linode" do
92
90
  before do
93
- @plugin[:network][:interfaces]["eth0:1"] = {
91
+ plugin[:network][:interfaces]["eth0:1"] = {
94
92
  "addresses" => {
95
93
  "5.6.7.8" => {
96
94
  "broadcast" => "10.176.191.255",
@@ -110,49 +108,28 @@ describe Ohai::System, "plugin linode" do
110
108
  end
111
109
 
112
110
  it "detects and sets the private ip" do
113
- @plugin.run
114
- expect(@plugin[:linode][:private_ip]).not_to be_nil
115
- expect(@plugin[:linode][:private_ip]).to eq("5.6.7.8")
111
+ plugin.run
112
+ expect(plugin[:linode][:private_ip]).not_to be_nil
113
+ expect(plugin[:linode][:private_ip]).to eq("5.6.7.8")
116
114
  end
117
115
  end
118
116
 
119
117
  end
120
118
 
121
- describe "with linode cloud file" do
119
+ describe "with linode hint file" do
122
120
  before do
123
- allow(File).to receive(:exist?).with(hint_path_nix).and_return(true)
124
- allow(File).to receive(:read).with(hint_path_nix).and_return("")
125
- allow(File).to receive(:exist?).with(hint_path_win).and_return(true)
126
- allow(File).to receive(:read).with(hint_path_win).and_return("")
121
+ allow(plugin).to receive(:hint?).with("linode").and_return({})
127
122
  end
128
123
 
129
- it_should_behave_like "linode"
124
+ it_behaves_like "linode"
130
125
  end
131
126
 
132
- describe "without cloud file" do
127
+ describe "without hint file" do
133
128
  before do
134
- allow(File).to receive(:exist?).with(hint_path_nix).and_return(false)
135
- allow(File).to receive(:exist?).with(hint_path_win).and_return(false)
129
+ allow(plugin).to receive(:hint?).with("linode").and_return(false)
136
130
  end
137
131
 
138
- it_should_behave_like "!linode"
139
- end
140
-
141
- context "with ec2 cloud file" do
142
- let(:ec2_hint_path_nix) { "/etc/chef/ohai/hints/ec2.json" }
143
- let(:ec2_hint_path_win) { 'C:\chef\ohai\hints/ec2.json' }
144
-
145
- before do
146
- allow(File).to receive(:exist?).with(hint_path_nix).and_return(false)
147
- allow(File).to receive(:exist?).with(hint_path_win).and_return(false)
148
-
149
- allow(File).to receive(:exist?).with(ec2_hint_path_nix).and_return(true)
150
- allow(File).to receive(:read).with(ec2_hint_path_nix).and_return("")
151
- allow(File).to receive(:exist?).with(ec2_hint_path_win).and_return(true)
152
- allow(File).to receive(:read).with(ec2_hint_path_win).and_return("")
153
- end
154
-
155
- it_should_behave_like "!linode"
132
+ it_behaves_like "!linode"
156
133
  end
157
134
 
158
135
  end
@@ -0,0 +1,59 @@
1
+ #
2
+ # Author:: Matt Wrock (<matt@mattwrock.com>)
3
+ # Copyright:: Copyright (c) 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 File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
20
+
21
+ describe Ohai::System, "plugin fips" do
22
+ let(:enabled) { "0" }
23
+ let(:plugin) { get_plugin("linux/fips") }
24
+ let(:fips_path) { "/proc/sys/crypto/fips_enabled" }
25
+
26
+ before(:each) do
27
+ allow(plugin).to receive(:collect_os).and_return(:linux)
28
+ allow(::File).to receive(:read).with(fips_path).and_return(enabled)
29
+ end
30
+
31
+ context "fips file is present and contains 1" do
32
+ let(:enabled) { "1" }
33
+
34
+ it "sets fips plugin" do
35
+ plugin.run
36
+ expect(plugin["fips"]["kernel"]["enabled"]).to be(true)
37
+ end
38
+ end
39
+
40
+ context "fips file does not contain 1" do
41
+ let(:enabled) { "0" }
42
+
43
+ it "does not set fips plugin" do
44
+ plugin.run
45
+ expect(plugin["fips"]["kernel"]["enabled"]).to be(false)
46
+ end
47
+ end
48
+
49
+ context "fips file is not present" do
50
+ before do
51
+ allow(::File).to receive(:read).and_raise(Errno::ENOENT, "bibbleboop")
52
+ end
53
+
54
+ it "does not set fips plugin" do
55
+ plugin.run
56
+ expect(plugin["fips"]["kernel"]["enabled"]).to be(false)
57
+ end
58
+ end
59
+ end
@@ -19,29 +19,44 @@
19
19
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb"))
20
20
 
21
21
  describe Ohai::System, "plugin mono" do
22
+ let(:plugin) { get_plugin("mono") }
22
23
 
23
24
  before(:each) do
24
- @plugin = get_plugin("mono")
25
- @plugin[:languages] = Mash.new
26
- @stdout = "Mono JIT compiler version 1.2.6 (tarball)\nCopyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com\n"
27
- allow(@plugin).to receive(:shell_out).with("mono -V").and_return(mock_shell_out(0, @stdout, ""))
25
+ plugin[:languages] = Mash.new
26
+ @stdout = <<-OUT
27
+ Mono JIT compiler version 4.2.3 (Stable 4.2.3.4/832de4b Wed Mar 30 13:57:48 PDT 2016)
28
+ Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
29
+ TLS: normal
30
+ SIGSEGV: altstack
31
+ Notification: kqueue
32
+ Architecture: amd64
33
+ Disabled: none
34
+ Misc: softdebug
35
+ LLVM: supported, not enabled.
36
+ GC: sgen
37
+ OUT
38
+ allow(plugin).to receive(:shell_out).with("mono -V").and_return(mock_shell_out(0, @stdout, ""))
28
39
  end
29
40
 
30
41
  it "should get the mono version from running mono -V" do
31
- expect(@plugin).to receive(:shell_out).with("mono -V").and_return(mock_shell_out(0, @stdout, ""))
32
- @plugin.run
42
+ expect(plugin).to receive(:shell_out).with("mono -V").and_return(mock_shell_out(0, @stdout, ""))
43
+ plugin.run
33
44
  end
34
45
 
35
46
  it "should set languages[:mono][:version]" do
36
- @plugin.run
37
- expect(@plugin.languages[:mono][:version]).to eql("1.2.6")
47
+ plugin.run
48
+ expect(plugin.languages[:mono][:version]).to eql("4.2.3")
49
+ end
50
+
51
+ it "should set languages[:mono][:builddate]" do
52
+ plugin.run
53
+ expect(plugin.languages[:mono][:builddate]).to eql("Wed Mar 30 13:57:48 PDT 2016")
38
54
  end
39
55
 
40
56
  it "should not set the languages[:mono] tree up if mono command fails" do
41
- @stdout = "Mono JIT compiler version 1.2.6 (tarball)\nCopyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com\n"
42
- allow(@plugin).to receive(:shell_out).with("mono -V").and_return(mock_shell_out(1, @stdout, ""))
43
- @plugin.run
44
- expect(@plugin.languages).not_to have_key(:mono)
57
+ allow(plugin).to receive(:shell_out).with("mono -V").and_return(mock_shell_out(1, @stdout, ""))
58
+ plugin.run
59
+ expect(plugin.languages).not_to have_key(:mono)
45
60
  end
46
61
 
47
62
  end
@@ -82,19 +82,19 @@ describe Ohai::System, "plugin rackspace" do
82
82
  end
83
83
 
84
84
  shared_examples_for "!rackspace" do
85
- it "does not create rackspace" do
85
+ it "does not create rackspace attribute" do
86
86
  plugin.run
87
87
  expect(plugin[:rackspace]).to be_nil
88
88
  end
89
89
  end
90
90
 
91
91
  shared_examples_for "rackspace" do
92
- it "creates rackspace" do
92
+ it "has rackspace attribute" do
93
93
  plugin.run
94
94
  expect(plugin[:rackspace]).not_to be_nil
95
95
  end
96
96
 
97
- it "has all required attributes" do
97
+ it "has expected rackspace ip/hostname attributes" do
98
98
  plugin.run
99
99
  expect(plugin[:rackspace][:public_ip]).not_to be_nil
100
100
  expect(plugin[:rackspace][:private_ip]).not_to be_nil
@@ -184,17 +184,14 @@ OUT
184
184
  end
185
185
  end
186
186
 
187
- describe "with rackspace cloud file" do
187
+ describe "with rackspace hint file" do
188
188
  it_behaves_like "rackspace"
189
189
 
190
190
  before(:each) do
191
191
  allow(Resolv).to receive(:getname).and_raise(Resolv::ResolvError)
192
- allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/rackspace.json").and_return(true)
193
- allow(File).to receive(:read).with("/etc/chef/ohai/hints/rackspace.json").and_return("")
194
- allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
195
- allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return("")
196
192
  allow(File).to receive(:exist?).with("/etc/resolv.conf").and_return(true)
197
193
  allow(File).to receive(:read).with("/etc/resolv.conf").and_return("")
194
+ allow(plugin).to receive(:hint?).with("rackspace").and_return(true)
198
195
  end
199
196
 
200
197
  describe "with no public interfaces (empty eth0)" do
@@ -203,7 +200,7 @@ OUT
203
200
  plugin[:network][:interfaces][:eth0]["addresses"] = {}
204
201
  end
205
202
 
206
- it "has all required attributes" do
203
+ it "has correct rackspace attributes" do
207
204
  plugin.run
208
205
  # expliticly nil
209
206
  expect(plugin[:rackspace][:public_ip]).to be_nil
@@ -211,14 +208,7 @@ OUT
211
208
  expect(plugin[:rackspace][:public_ipv6]).to be_nil
212
209
  expect(plugin[:rackspace][:public_hostname]).to be_nil
213
210
  # per normal
214
- expect(plugin[:rackspace][:private_ip]).not_to be_nil
215
- expect(plugin[:rackspace][:local_ipv4]).not_to be_nil
216
211
  expect(plugin[:rackspace][:local_ipv6]).to be_nil
217
- expect(plugin[:rackspace][:local_hostname]).not_to be_nil
218
- end
219
-
220
- it "has correct values for all attributes" do
221
- plugin.run
222
212
  expect(plugin[:rackspace][:private_ip]).to eq("5.6.7.8")
223
213
  expect(plugin[:rackspace][:local_ipv4]).to eq("5.6.7.8")
224
214
  expect(plugin[:rackspace][:local_hostname]).to eq("katie")
@@ -226,26 +216,11 @@ OUT
226
216
  end
227
217
  end
228
218
 
229
- describe "without cloud file" do
230
- it_behaves_like "!rackspace"
231
-
232
- before(:each) do
233
- allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/rackspace.json").and_return(false)
234
- allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(false)
235
- end
236
- end
237
-
238
- describe "with ec2 cloud file" do
219
+ describe "without hint file" do
239
220
  it_behaves_like "!rackspace"
240
221
 
241
222
  before(:each) do
242
- allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/ec2.json").and_return(true)
243
- allow(File).to receive(:read).with("/etc/chef/ohai/hints/ec2.json").and_return("")
244
- allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true)
245
- allow(File).to receive(:read).with('C:\chef\ohai\hints/ec2.json').and_return("")
246
-
247
- allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/rackspace.json").and_return(false)
248
- allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(false)
223
+ allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
249
224
  end
250
225
  end
251
226
 
@@ -254,6 +229,7 @@ OUT
254
229
 
255
230
  before(:each) do
256
231
  stdout = "Rackspace\n"
232
+ allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
257
233
  allow(plugin).to receive(:shell_out).with("xenstore-read vm-data/provider_data/provider").and_return(mock_shell_out(0, stdout, "" ))
258
234
  end
259
235
  end
@@ -262,6 +238,7 @@ OUT
262
238
  it_behaves_like "!rackspace"
263
239
 
264
240
  before(:each) do
241
+ allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
265
242
  stdout = "cumulonimbus\n"
266
243
  allow(plugin).to receive(:shell_out).with("xenstore-read vm-data/provider_data/provider").and_return(mock_shell_out(0, stdout, "" ))
267
244
  end
@@ -271,6 +248,7 @@ OUT
271
248
  it_behaves_like "!rackspace"
272
249
 
273
250
  before(:each) do
251
+ allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
274
252
  allow(plugin).
275
253
  to receive(:shell_out).
276
254
  with("xenstore-read vm-data/provider_data/provider").
@@ -301,14 +279,10 @@ OUT
301
279
  describe "does not have private networks" do
302
280
  before do
303
281
  stdout = 'BC764E20422B = "{"label": "public"}"\n'
282
+ allow(plugin).to receive(:hint?).with("rackspace").and_return(true)
304
283
  allow(plugin).to receive(:shell_out).with("xenstore-ls vm-data/networking").and_return(mock_shell_out(0, stdout, "" ))
305
284
  stdout = '{"label": "public", "broadcast": "9.10.11.255", "ips": [{"ip": "9.10.11.12", "netmask": "255.255.255.0", "enabled": "1", "gateway": null}], "mac": "BC:76:4E:20:42:2B", "dns": ["69.20.0.164", "69.20.0.196"], "gateway": null}'
306
285
  allow(plugin).to receive(:shell_out).with("xenstore-read vm-data/networking/BC764E20422B").and_return(mock_shell_out(0, stdout, "" ))
307
-
308
- allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/rackspace.json").and_return(true)
309
- allow(File).to receive(:read).with("/etc/chef/ohai/hints/rackspace.json").and_return("")
310
- allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
311
- allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return("")
312
286
  end
313
287
 
314
288
  it "does not have private_networks object" do
@@ -340,11 +314,7 @@ OUT
340
314
  allow(plugin).to receive(:shell_out).with("xenstore-ls vm-data/networking").and_return(mock_shell_out(0, stdout, "" ))
341
315
  stdout = '{"label": "private-network", "broadcast": "9.10.11.255", "ips": [{"ip": "9.10.11.12", "netmask": "255.255.255.0", "enabled": "1", "gateway": null}], "mac": "BC:76:4E:20:42:2B", "dns": ["69.20.0.164", "69.20.0.196"], "gateway": null}'
342
316
  allow(plugin).to receive(:shell_out).with("xenstore-read vm-data/networking/BC764E20422B").and_return(mock_shell_out(0, stdout, "" ))
343
-
344
- allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/rackspace.json").and_return(true)
345
- allow(File).to receive(:read).with("/etc/chef/ohai/hints/rackspace.json").and_return("")
346
- allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
347
- allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return("")
317
+ allow(plugin).to receive(:hint?).with("rackspace").and_return(true)
348
318
  end
349
319
 
350
320
  it "has private_networks object" do
@@ -352,7 +322,7 @@ OUT
352
322
  expect(plugin[:rackspace][:private_networks]).not_to be_nil
353
323
  end
354
324
 
355
- it "has correct values for all attributes" do
325
+ it "has correct values for all rackspace attributes" do
356
326
  plugin.run
357
327
  expect(plugin[:rackspace][:private_networks][0][:label]).to eq("private-network")
358
328
  expect(plugin[:rackspace][:private_networks][0][:broadcast]).to eq("9.10.11.255")