ohai 7.6.0.rc.1 → 8.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/ohai/version.rb +1 -1
- data/spec/functional/plugins/powershell_spec.rb +4 -4
- data/spec/functional/plugins/root_group_spec.rb +1 -1
- data/spec/ohai_spec.rb +1 -1
- data/spec/spec_helper.rb +12 -12
- data/spec/unit/dsl/plugin_spec.rb +40 -40
- data/spec/unit/hints_spec.rb +3 -3
- data/spec/unit/loader_spec.rb +16 -16
- data/spec/unit/mixin/cloudstack_metadata_spec.rb +1 -1
- data/spec/unit/mixin/command_spec.rb +6 -6
- data/spec/unit/mixin/ec2_metadata_spec.rb +8 -8
- data/spec/unit/plugins/aix/cpu_spec.rb +15 -15
- data/spec/unit/plugins/aix/filesystem_spec.rb +15 -15
- data/spec/unit/plugins/aix/hostname_spec.rb +3 -3
- data/spec/unit/plugins/aix/kernel_spec.rb +14 -14
- data/spec/unit/plugins/aix/network_spec.rb +43 -43
- data/spec/unit/plugins/aix/platform_spec.rb +5 -5
- data/spec/unit/plugins/aix/uptime_spec.rb +7 -7
- data/spec/unit/plugins/aix/virtualization_spec.rb +3 -3
- data/spec/unit/plugins/azure_spec.rb +18 -18
- data/spec/unit/plugins/c_spec.rb +52 -52
- data/spec/unit/plugins/chef_spec.rb +1 -1
- data/spec/unit/plugins/cloud_spec.rb +31 -31
- data/spec/unit/plugins/cloud_v2_spec.rb +33 -33
- data/spec/unit/plugins/cloudstack_spec.rb +6 -6
- data/spec/unit/plugins/darwin/cpu_spec.rb +19 -19
- data/spec/unit/plugins/darwin/hostname_spec.rb +6 -6
- data/spec/unit/plugins/darwin/kernel_spec.rb +14 -14
- data/spec/unit/plugins/darwin/memory_spec.rb +7 -7
- data/spec/unit/plugins/darwin/network_spec.rb +358 -358
- data/spec/unit/plugins/darwin/platform_spec.rb +10 -10
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +4 -4
- data/spec/unit/plugins/dmi_spec.rb +3 -3
- data/spec/unit/plugins/ec2_spec.rb +80 -80
- data/spec/unit/plugins/erlang_spec.rb +7 -7
- data/spec/unit/plugins/eucalyptus_spec.rb +28 -28
- data/spec/unit/plugins/fail_spec.rb +8 -8
- data/spec/unit/plugins/freebsd/cpu_spec.rb +10 -10
- data/spec/unit/plugins/freebsd/hostname_spec.rb +4 -4
- data/spec/unit/plugins/freebsd/kernel_spec.rb +6 -6
- data/spec/unit/plugins/freebsd/os_spec.rb +3 -3
- data/spec/unit/plugins/freebsd/platform_spec.rb +5 -5
- data/spec/unit/plugins/freebsd/virtualization_spec.rb +20 -20
- data/spec/unit/plugins/gce_spec.rb +18 -18
- data/spec/unit/plugins/go_spec.rb +5 -5
- data/spec/unit/plugins/groovy_spec.rb +5 -5
- data/spec/unit/plugins/hostname_spec.rb +24 -24
- data/spec/unit/plugins/init_package_spec.rb +5 -5
- data/spec/unit/plugins/ip_scopes_spec.rb +1 -1
- data/spec/unit/plugins/java_spec.rb +23 -23
- data/spec/unit/plugins/joyent_spec.rb +13 -13
- data/spec/unit/plugins/kernel_spec.rb +20 -20
- data/spec/unit/plugins/linode_spec.rb +18 -18
- data/spec/unit/plugins/linux/cpu_spec.rb +25 -25
- data/spec/unit/plugins/linux/filesystem_spec.rb +61 -60
- data/spec/unit/plugins/linux/hostname_spec.rb +7 -7
- data/spec/unit/plugins/linux/kernel_spec.rb +5 -5
- data/spec/unit/plugins/linux/lsb_spec.rb +23 -23
- data/spec/unit/plugins/linux/mdadm_spec.rb +11 -11
- data/spec/unit/plugins/linux/platform_spec.rb +167 -167
- data/spec/unit/plugins/linux/uptime_spec.rb +6 -6
- data/spec/unit/plugins/linux/virtualization_spec.rb +156 -156
- data/spec/unit/plugins/lua_spec.rb +5 -5
- data/spec/unit/plugins/mono_spec.rb +5 -5
- data/spec/unit/plugins/netbsd/hostname_spec.rb +6 -6
- data/spec/unit/plugins/netbsd/kernel_spec.rb +6 -6
- data/spec/unit/plugins/netbsd/platform_spec.rb +5 -5
- data/spec/unit/plugins/network_spec.rb +116 -116
- data/spec/unit/plugins/nodejs_spec.rb +5 -5
- data/spec/unit/plugins/ohai_spec.rb +1 -1
- data/spec/unit/plugins/ohai_time_spec.rb +5 -5
- data/spec/unit/plugins/openbsd/hostname_spec.rb +6 -6
- data/spec/unit/plugins/openbsd/kernel_spec.rb +6 -6
- data/spec/unit/plugins/openbsd/platform_spec.rb +4 -4
- data/spec/unit/plugins/openstack_spec.rb +8 -8
- data/spec/unit/plugins/os_spec.rb +5 -5
- data/spec/unit/plugins/passwd_spec.rb +13 -13
- data/spec/unit/plugins/perl_spec.rb +8 -8
- data/spec/unit/plugins/php_spec.rb +7 -7
- data/spec/unit/plugins/platform_spec.rb +9 -9
- data/spec/unit/plugins/powershell_spec.rb +10 -10
- data/spec/unit/plugins/rackspace_spec.rb +72 -70
- data/spec/unit/plugins/root_group_spec.rb +14 -14
- data/spec/unit/plugins/ruby_spec.rb +1 -1
- data/spec/unit/plugins/sigar/network_route_spec.rb +17 -17
- data/spec/unit/plugins/solaris2/cpu_spec.rb +18 -18
- data/spec/unit/plugins/solaris2/hostname_spec.rb +4 -4
- data/spec/unit/plugins/solaris2/kernel_spec.rb +8 -8
- data/spec/unit/plugins/solaris2/memory_spec.rb +3 -3
- data/spec/unit/plugins/solaris2/network_spec.rb +13 -13
- data/spec/unit/plugins/solaris2/platform_spec.rb +14 -14
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +24 -24
- data/spec/unit/plugins/solaris2/zpools_spec.rb +6 -6
- data/spec/unit/plugins/ssh_host_keys_spec.rb +18 -18
- data/spec/unit/runner_spec.rb +26 -26
- data/spec/unit/system_spec.rb +54 -54
- data/spec/unit/util/file_helper_spec.rb +2 -2
- metadata +50 -95
@@ -26,24 +26,24 @@ describe Ohai::System, "plugin nodejs" do
|
|
26
26
|
@plugin = get_plugin("nodejs")
|
27
27
|
@plugin[:languages] = Mash.new
|
28
28
|
@stdout = "v0.8.11\n"
|
29
|
-
@plugin.
|
29
|
+
allow(@plugin).to receive(:shell_out).with("node -v").and_return(mock_shell_out(0, @stdout, ""))
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should get the nodejs version from running node -v" do
|
33
|
-
@plugin.
|
33
|
+
expect(@plugin).to receive(:shell_out).with("node -v").and_return(mock_shell_out(0, @stdout, ""))
|
34
34
|
@plugin.run
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should set languages[:nodejs][:version]" do
|
38
38
|
@plugin.run
|
39
|
-
@plugin.languages[:nodejs][:version].
|
39
|
+
expect(@plugin.languages[:nodejs][:version]).to eql("0.8.11")
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should not set the languages[:nodejs] tree up if node command fails" do
|
43
43
|
@stdout = "v0.8.11\n"
|
44
|
-
@plugin.
|
44
|
+
allow(@plugin).to receive(:shell_out).with("node -v").and_return(mock_shell_out(1, @stdout, ""))
|
45
45
|
@plugin.run
|
46
|
-
@plugin.languages.
|
46
|
+
expect(@plugin.languages).not_to have_key(:nodejs)
|
47
47
|
end
|
48
48
|
|
49
49
|
end
|
@@ -27,6 +27,6 @@ describe Ohai::System, "plugin ohai" do
|
|
27
27
|
|
28
28
|
it "should set [:chef_packages][:ohai][:version] to the current version" do
|
29
29
|
@plugin.run
|
30
|
-
@plugin[:chef_packages][:ohai][:version].
|
30
|
+
expect(@plugin[:chef_packages][:ohai][:version]).to eq(Ohai::VERSION)
|
31
31
|
end
|
32
32
|
end
|
@@ -25,21 +25,21 @@ describe Ohai::System, "plugin ohai_time" do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should get the current time" do
|
28
|
-
Time.
|
28
|
+
expect(Time).to receive(:now)
|
29
29
|
@plugin.run
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should turn the time into a floating point number" do
|
33
33
|
time = Time.now
|
34
|
-
time.
|
35
|
-
Time.
|
34
|
+
expect(time).to receive(:to_f)
|
35
|
+
allow(Time).to receive(:now).and_return(time)
|
36
36
|
@plugin.run
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should set ohai_time to the current time" do
|
40
40
|
time = Time.now
|
41
|
-
Time.
|
41
|
+
allow(Time).to receive(:now).and_return(time)
|
42
42
|
@plugin.run
|
43
|
-
@plugin[:ohai_time].
|
43
|
+
expect(@plugin[:ohai_time]).to eq(time.to_f)
|
44
44
|
end
|
45
45
|
end
|
@@ -22,10 +22,10 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
22
22
|
describe Ohai::System, "OpenBSD hostname plugin" do
|
23
23
|
before(:each) do
|
24
24
|
@plugin = get_plugin("hostname")
|
25
|
-
@plugin.
|
26
|
-
@plugin.
|
27
|
-
@plugin.
|
28
|
-
@plugin.
|
25
|
+
allow(@plugin).to receive(:collect_os).and_return(:openbsd)
|
26
|
+
allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie\n", ""))
|
27
|
+
allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
|
28
|
+
allow(@plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
|
29
29
|
end
|
30
30
|
|
31
31
|
it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie")
|
@@ -34,11 +34,11 @@ describe Ohai::System, "OpenBSD hostname plugin" do
|
|
34
34
|
|
35
35
|
it "should use #resolve_fqdn to find the fqdn" do
|
36
36
|
@plugin.run
|
37
|
-
@plugin[:fqdn].
|
37
|
+
expect(@plugin[:fqdn]).to eq("katie.bethell")
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should set the domain to everything after the first dot of the fqdn" do
|
41
41
|
@plugin.run
|
42
|
-
@plugin[:domain].
|
42
|
+
expect(@plugin[:domain]).to eq("bethell")
|
43
43
|
end
|
44
44
|
end
|
@@ -22,16 +22,16 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
22
22
|
describe Ohai::System, "OpenBSD kernel plugin" do
|
23
23
|
before(:each) do
|
24
24
|
@plugin = get_plugin("kernel")
|
25
|
-
@plugin.
|
26
|
-
@plugin.
|
27
|
-
@plugin.
|
28
|
-
@plugin.
|
29
|
-
@plugin.
|
25
|
+
allow(@plugin).to receive(:collect_os).and_return(:openbsd)
|
26
|
+
allow(@plugin).to receive(:init_kernel).and_return({})
|
27
|
+
allow(@plugin).to receive(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo", ""))
|
28
|
+
allow(@plugin).to receive(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1\n", ""))
|
29
|
+
allow(@plugin).to receive(:shell_out).with( Ohai.abs_path( "/usr/bin/modstat" )).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should set the kernel_os to the kernel_name value" do
|
33
33
|
@plugin.run
|
34
|
-
@plugin[:kernel][:os].
|
34
|
+
expect(@plugin[:kernel][:os]).to eq(@plugin[:kernel][:name])
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
@@ -22,13 +22,13 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
|
22
22
|
describe Ohai::System, "OpenBSD plugin platform" do
|
23
23
|
before(:each) do
|
24
24
|
@plugin = get_plugin("openbsd/platform")
|
25
|
-
@plugin.
|
26
|
-
@plugin.
|
27
|
-
@plugin.
|
25
|
+
allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "OpenBSD\n", ""))
|
26
|
+
allow(@plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "4.5\n", ""))
|
27
|
+
allow(@plugin).to receive(:collect_os).and_return(:openbsd)
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should set platform_version to lsb[:release]" do
|
31
31
|
@plugin.run
|
32
|
-
@plugin[:platform_version].
|
32
|
+
expect(@plugin[:platform_version]).to eq("4.5")
|
33
33
|
end
|
34
34
|
end
|
@@ -29,8 +29,8 @@ describe "OpenStack Plugin" do
|
|
29
29
|
|
30
30
|
let(:openstack_plugin) do
|
31
31
|
plugin = get_plugin("openstack", ohai_system)
|
32
|
-
plugin.
|
33
|
-
plugin.
|
32
|
+
allow(plugin).to receive(:hint?).with("openstack").and_return(openstack_hint)
|
33
|
+
allow(plugin).to receive(:hint?).with("hp").and_return(hp_hint)
|
34
34
|
plugin
|
35
35
|
end
|
36
36
|
|
@@ -52,7 +52,7 @@ describe "OpenStack Plugin" do
|
|
52
52
|
context "and the metadata service is not available" do
|
53
53
|
|
54
54
|
before do
|
55
|
-
openstack_plugin.
|
55
|
+
expect(openstack_plugin).to receive(:can_metadata_connect?).
|
56
56
|
with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR,80).
|
57
57
|
and_return(false)
|
58
58
|
end
|
@@ -141,27 +141,27 @@ EOM
|
|
141
141
|
let(:http_client) { double("Net::HTTP", :read_timeout= => nil) }
|
142
142
|
|
143
143
|
def expect_get(url, response_body)
|
144
|
-
http_client.
|
144
|
+
expect(http_client).to receive(:get).
|
145
145
|
with(url).
|
146
146
|
and_return(double("HTTP Response", :code => "200", :body => response_body))
|
147
147
|
end
|
148
148
|
|
149
149
|
def expect_get_response(url, response_body)
|
150
|
-
http_client.
|
150
|
+
expect(http_client).to receive(:get_response).
|
151
151
|
with(url,nil,nil).
|
152
152
|
and_return(double("HTTP Response", :code => "200", :body => response_body))
|
153
153
|
end
|
154
154
|
|
155
155
|
before do
|
156
|
-
openstack_plugin.
|
156
|
+
expect(openstack_plugin).to receive(:can_metadata_connect?).
|
157
157
|
with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR,80).
|
158
158
|
and_return(true)
|
159
159
|
|
160
|
-
Net::HTTP.
|
160
|
+
allow(Net::HTTP).to receive(:start).
|
161
161
|
with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR).
|
162
162
|
and_return(http_client)
|
163
163
|
|
164
|
-
openstack_plugin.
|
164
|
+
allow(openstack_plugin).to receive(:best_api_version).and_return(metadata_version)
|
165
165
|
|
166
166
|
expect_get("/#{metadata_version}/meta-data/", metadata_root)
|
167
167
|
|
@@ -34,7 +34,7 @@ describe Ohai::System, "plugin os" do
|
|
34
34
|
|
35
35
|
it "should set os_version to kernel_release" do
|
36
36
|
@plugin.run
|
37
|
-
@plugin[:os_version].
|
37
|
+
expect(@plugin[:os_version]).to eq(@plugin[:kernel][:release])
|
38
38
|
end
|
39
39
|
|
40
40
|
describe "on linux" do
|
@@ -44,7 +44,7 @@ describe Ohai::System, "plugin os" do
|
|
44
44
|
|
45
45
|
it "should set the os to linux" do
|
46
46
|
@plugin.run
|
47
|
-
@plugin[:os].
|
47
|
+
expect(@plugin[:os]).to eq("linux")
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -55,7 +55,7 @@ describe Ohai::System, "plugin os" do
|
|
55
55
|
|
56
56
|
it "should set the os to darwin" do
|
57
57
|
@plugin.run
|
58
|
-
@plugin[:os].
|
58
|
+
expect(@plugin[:os]).to eq("darwin")
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -66,7 +66,7 @@ describe Ohai::System, "plugin os" do
|
|
66
66
|
|
67
67
|
it "sets the os to solaris2" do
|
68
68
|
@plugin.run
|
69
|
-
@plugin[:os].
|
69
|
+
expect(@plugin[:os]).to eq("solaris2")
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -77,7 +77,7 @@ describe Ohai::System, "plugin os" do
|
|
77
77
|
|
78
78
|
it "sets the os to the ruby 'host_os'" do
|
79
79
|
@plugin.run
|
80
|
-
@plugin[:os].
|
80
|
+
expect(@plugin[:os]).to eq("tron")
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
@@ -9,42 +9,42 @@ describe Ohai::System, "plugin etc", :unix_only do
|
|
9
9
|
GroupEntry = Struct.new(:name, :gid, :mem)
|
10
10
|
|
11
11
|
it "should include a list of all users" do
|
12
|
-
Etc.
|
12
|
+
expect(Etc).to receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, '/root', '/bin/zsh', 'BOFH')).
|
13
13
|
and_yield(PasswdEntry.new('www', 800, 800, '/var/www', '/bin/false', 'Serving the web since 1970'))
|
14
14
|
@plugin.run
|
15
|
-
@plugin[:etc][:passwd]['root'].
|
16
|
-
@plugin[:etc][:passwd]['www'].
|
15
|
+
expect(@plugin[:etc][:passwd]['root']).to eq(Mash.new(:shell => '/bin/zsh', :gecos => 'BOFH', :gid => 1, :uid => 1, :dir => '/root'))
|
16
|
+
expect(@plugin[:etc][:passwd]['www']).to eq(Mash.new(:shell => '/bin/false', :gecos => 'Serving the web since 1970', :gid => 800, :uid => 800, :dir => '/var/www'))
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should ignore duplicate users" do
|
20
|
-
Etc.
|
20
|
+
expect(Etc).to receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, '/root', '/bin/zsh', 'BOFH')).
|
21
21
|
and_yield(PasswdEntry.new('root', 1, 1, '/', '/bin/false', 'I do not belong'))
|
22
22
|
@plugin.run
|
23
|
-
@plugin[:etc][:passwd]['root'].
|
23
|
+
expect(@plugin[:etc][:passwd]['root']).to eq(Mash.new(:shell => '/bin/zsh', :gecos => 'BOFH', :gid => 1, :uid => 1, :dir => '/root'))
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should set the current user" do
|
27
|
-
Process.
|
28
|
-
Etc.
|
27
|
+
expect(Process).to receive(:euid).and_return('31337')
|
28
|
+
expect(Etc).to receive(:getpwuid).and_return(PasswdEntry.new('chef', 31337, 31337, '/home/chef', '/bin/ksh', 'Julia Child'))
|
29
29
|
@plugin.run
|
30
|
-
@plugin[:current_user].
|
30
|
+
expect(@plugin[:current_user]).to eq('chef')
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should set the available groups" do
|
34
|
-
Etc.
|
34
|
+
expect(Etc).to receive(:group).and_yield(GroupEntry.new("admin", 100, ['root', 'chef'])).and_yield(GroupEntry.new('www', 800, ['www', 'deploy']))
|
35
35
|
@plugin.run
|
36
|
-
@plugin[:etc][:group]['admin'].
|
37
|
-
@plugin[:etc][:group]['www'].
|
36
|
+
expect(@plugin[:etc][:group]['admin']).to eq(Mash.new(:gid => 100, :members => ['root', 'chef']))
|
37
|
+
expect(@plugin[:etc][:group]['www']).to eq(Mash.new(:gid => 800, :members => ['www', 'deploy']))
|
38
38
|
end
|
39
39
|
|
40
40
|
if "".respond_to?(:force_encoding)
|
41
41
|
it "sets the encoding of strings to the default external encoding" do
|
42
42
|
fields = ["root", 1, 1, '/root', '/bin/zsh', 'BOFH']
|
43
43
|
fields.each {|f| f.force_encoding(Encoding::ASCII_8BIT) if f.respond_to?(:force_encoding) }
|
44
|
-
Etc.
|
44
|
+
allow(Etc).to receive(:passwd).and_yield(PasswdEntry.new(*fields))
|
45
45
|
@plugin.run
|
46
46
|
root = @plugin[:etc][:passwd]['root']
|
47
|
-
root['gecos'].encoding.
|
47
|
+
expect(root['gecos'].encoding).to eq(Encoding.default_external)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -24,35 +24,35 @@ describe Ohai::System, "plugin perl" do
|
|
24
24
|
@plugin = get_plugin("perl")
|
25
25
|
@plugin[:languages] = Mash.new
|
26
26
|
@stdout = "version='5.8.8';#{$/}archname='darwin-thread-multi-2level';"
|
27
|
-
@plugin.
|
27
|
+
allow(@plugin).to receive(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, @stdout, ""))
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should run perl -V:version -V:archname" do
|
31
|
-
@plugin.
|
31
|
+
expect(@plugin).to receive(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, @stdout, ""))
|
32
32
|
@plugin.run
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should set languages[:perl][:version]" do
|
36
36
|
@plugin.run
|
37
|
-
@plugin.languages[:perl][:version].
|
37
|
+
expect(@plugin.languages[:perl][:version]).to eql("5.8.8")
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should set languages[:perl][:archname]" do
|
41
41
|
@plugin.run
|
42
|
-
@plugin.languages[:perl][:archname].
|
42
|
+
expect(@plugin.languages[:perl][:archname]).to eql("darwin-thread-multi-2level")
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should set languages[:perl] if perl command succeeds" do
|
46
|
-
@plugin.
|
46
|
+
allow(@plugin).to receive(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, @stdout, ""))
|
47
47
|
@plugin.run
|
48
|
-
@plugin.languages.
|
48
|
+
expect(@plugin.languages).to have_key(:perl)
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should not set languages[:perl] if perl command fails" do
|
52
52
|
@status = 1
|
53
|
-
@plugin.
|
53
|
+
allow(@plugin).to receive(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(1, @stdout, ""))
|
54
54
|
@plugin.run
|
55
|
-
@plugin.languages.
|
55
|
+
expect(@plugin.languages).not_to have_key(:perl)
|
56
56
|
end
|
57
57
|
|
58
58
|
end
|
@@ -26,31 +26,31 @@ describe Ohai::System, "plugin php" do
|
|
26
26
|
@plugin = get_plugin("php")
|
27
27
|
@plugin[:languages] = Mash.new
|
28
28
|
@stdout = "PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)\nCopyright (c) 1997-2006 The PHP Group\nZend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies\n"
|
29
|
-
@plugin.
|
29
|
+
allow(@plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should get the php version from running php -V" do
|
33
|
-
@plugin.
|
33
|
+
expect(@plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
|
34
34
|
@plugin.run
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should set languages[:php][:version]" do
|
38
38
|
@plugin.run
|
39
|
-
@plugin.languages[:php][:version].
|
39
|
+
expect(@plugin.languages[:php][:version]).to eql("5.1.6")
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should not set the languages[:php] tree up if php command fails" do
|
43
43
|
@stdout = "PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)\nCopyright (c) 1997-2006 The PHP Group\nZend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies\n"
|
44
|
-
@plugin.
|
44
|
+
allow(@plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(1, @stdout, ""))
|
45
45
|
@plugin.run
|
46
|
-
@plugin.languages.
|
46
|
+
expect(@plugin.languages).not_to have_key(:php)
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should parse builddate even if it's suhosin patched" do
|
50
50
|
@stdout = "PHP 5.3.27 with Suhosin-Patch (cli) (built: Aug 30 2013 04:30:30) \nCopyright (c) 1997-2013 The PHP Group\nZend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies"
|
51
|
-
@plugin.
|
51
|
+
allow(@plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
|
52
52
|
@plugin.run
|
53
|
-
@plugin.languages[:php][:builddate].
|
53
|
+
expect(@plugin.languages[:php][:builddate]).to eql("Aug 30 2013 04:30:30")
|
54
54
|
end
|
55
55
|
|
56
56
|
end
|
@@ -22,45 +22,45 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
|
22
22
|
describe Ohai::System, "plugin platform" do
|
23
23
|
before(:each) do
|
24
24
|
@plugin = get_plugin("platform")
|
25
|
-
@plugin.
|
25
|
+
allow(@plugin).to receive(:collect_os).and_return(:default)
|
26
26
|
@plugin[:os] = 'monkey'
|
27
27
|
@plugin[:os_version] = 'poop'
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should set the platform and platform family to the os if it was not set earlier" do
|
31
31
|
@plugin.run
|
32
|
-
@plugin[:platform].
|
33
|
-
@plugin[:platform_family].
|
32
|
+
expect(@plugin[:platform]).to eql("monkey")
|
33
|
+
expect(@plugin[:platform_family]).to eql("monkey")
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should not set the platform to the os if it was set earlier" do
|
37
37
|
@plugin[:platform] = 'lars'
|
38
38
|
@plugin.run
|
39
|
-
@plugin[:platform].
|
39
|
+
expect(@plugin[:platform]).to eql("lars")
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should set the platform_family to the platform if platform was set earlier but not platform_family" do
|
43
43
|
@plugin[:platform] = 'lars'
|
44
44
|
@plugin[:platform_family] = 'jack'
|
45
45
|
@plugin.run
|
46
|
-
@plugin[:platform_family].
|
46
|
+
expect(@plugin[:platform_family]).to eql("jack")
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should not set the platform_family if the platform_family was set earlier." do
|
50
50
|
@plugin[:platform] = 'lars'
|
51
51
|
@plugin.run
|
52
|
-
@plugin[:platform].
|
53
|
-
@plugin[:platform_family].
|
52
|
+
expect(@plugin[:platform]).to eql("lars")
|
53
|
+
expect(@plugin[:platform_family]).to eql("lars")
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should set the platform_version to the os_version if it was not set earlier" do
|
57
57
|
@plugin.run
|
58
|
-
@plugin[:os_version].
|
58
|
+
expect(@plugin[:os_version]).to eql("poop")
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should not set the platform to the os if it was set earlier" do
|
62
62
|
@plugin[:platform_version] = 'ulrich'
|
63
63
|
@plugin.run
|
64
|
-
@plugin[:platform_version].
|
64
|
+
expect(@plugin[:platform_version]).to eql("ulrich")
|
65
65
|
end
|
66
66
|
end
|
@@ -43,15 +43,15 @@ PSRemotingProtocolVersion 2.2
|
|
43
43
|
|
44
44
|
END
|
45
45
|
|
46
|
-
@plugin.
|
46
|
+
allow(@plugin).to receive(:shell_out).with(anything()).and_return(mock_shell_out(0, v4_output, ""))
|
47
47
|
@plugin.run
|
48
|
-
@plugin.languages[:powershell][:version].
|
49
|
-
@plugin.languages[:powershell][:ws_man_stack_version].
|
50
|
-
@plugin.languages[:powershell][:serialization_version].
|
51
|
-
@plugin.languages[:powershell][:clr_version].
|
52
|
-
@plugin.languages[:powershell][:build_version].
|
53
|
-
@plugin.languages[:powershell][:compatible_versions].
|
54
|
-
@plugin.languages[:powershell][:remoting_protocol_version].
|
48
|
+
expect(@plugin.languages[:powershell][:version]).to eql("4.0")
|
49
|
+
expect(@plugin.languages[:powershell][:ws_man_stack_version]).to eql("3.0")
|
50
|
+
expect(@plugin.languages[:powershell][:serialization_version]).to eql("1.1.0.1")
|
51
|
+
expect(@plugin.languages[:powershell][:clr_version]).to eql("4.0.30319.34014")
|
52
|
+
expect(@plugin.languages[:powershell][:build_version]).to eql("6.3.9600.16394")
|
53
|
+
expect(@plugin.languages[:powershell][:compatible_versions]).to eql(['1.0', '2.0', '3.0', '4.0'])
|
54
|
+
expect(@plugin.languages[:powershell][:remoting_protocol_version]).to eql("2.2")
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should not set the languages[:powershell] tree up if powershell command fails" do
|
@@ -60,9 +60,9 @@ END
|
|
60
60
|
operable program or batch file.
|
61
61
|
END
|
62
62
|
|
63
|
-
@plugin.
|
63
|
+
allow(@plugin).to receive(:shell_out).with(anything).and_return(mock_shell_out(1, error_output, ""))
|
64
64
|
@plugin.run
|
65
|
-
@plugin.languages.
|
65
|
+
expect(@plugin.languages).not_to have_key(:powershell)
|
66
66
|
end
|
67
67
|
|
68
68
|
end
|