facter 1.7.2 → 1.7.3.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of facter might be problematic. Click here for more details.
- data/README.md +8 -0
- data/Rakefile +10 -4
- data/ext/build_defaults.yaml +4 -3
- data/ext/debian/changelog.erb +7 -1
- data/ext/debian/control +2 -2
- data/ext/redhat/facter.spec.erb +1 -1
- data/install.rb +1 -1
- data/lib/facter/domain.rb +11 -3
- data/lib/facter/hardwaremodel.rb +7 -2
- data/lib/facter/ipaddress.rb +16 -4
- data/lib/facter/ipaddress6.rb +12 -3
- data/lib/facter/macaddress.rb +1 -1
- data/lib/facter/netmask.rb +19 -0
- data/lib/facter/util/directory_loader.rb +1 -1
- data/lib/facter/util/ip.rb +14 -18
- data/lib/facter/util/ip/windows.rb +215 -0
- data/lib/facter/util/macaddress.rb +3 -9
- data/lib/facter/util/netmask.rb +1 -1
- data/lib/facter/util/parser.rb +30 -19
- data/lib/facter/version.rb +1 -1
- data/lib/facter/virtual.rb +5 -5
- data/spec/fixtures/unit/ipaddress/ifconfig_non_english_locale.txt +18 -0
- data/spec/lib/facter_spec/windows_network.rb +64 -0
- data/spec/spec_helper.rb +25 -7
- data/spec/unit/architecture_spec.rb +1 -0
- data/spec/unit/domain_spec.rb +37 -6
- data/spec/unit/ec2_spec.rb +1 -1
- data/spec/unit/facter_spec.rb +2 -2
- data/spec/unit/hardwaremodel_spec.rb +16 -1
- data/spec/unit/ipaddress6_spec.rb +106 -13
- data/spec/unit/ipaddress_spec.rb +100 -22
- data/spec/unit/macaddress_spec.rb +0 -4
- data/spec/unit/memory_spec.rb +8 -7
- data/spec/unit/netmask_spec.rb +62 -5
- data/spec/unit/util/ip/windows_spec.rb +48 -0
- data/spec/unit/util/ip_spec.rb +9 -21
- data/spec/unit/util/macaddress_spec.rb +52 -10
- data/spec/unit/util/parser_spec.rb +32 -3
- data/spec/unit/util/virtual_spec.rb +9 -4
- data/spec/unit/zfs_version_spec.rb +4 -5
- data/spec/unit/zpool_version_spec.rb +4 -5
- metadata +480 -477
- data/ext/osx/PackageInfo.plist +0 -36
- data/ext/osx/createpackage.sh +0 -179
- data/spec/fixtures/netsh/windows_netsh_addresses_with_multiple_interfaces +0 -35
data/spec/unit/ipaddress_spec.rb
CHANGED
@@ -3,34 +3,112 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
require 'facter/util/ip'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
Facter
|
9
|
-
subject.value.should == address
|
6
|
+
describe "ipaddress fact" do
|
7
|
+
before do
|
8
|
+
Facter.collection.internal_loader.load(:ipaddress)
|
10
9
|
end
|
11
|
-
end
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
context 'using `ifconfig`' do
|
12
|
+
before :each do
|
13
|
+
Facter.fact(:hostname).stubs(:value)
|
14
|
+
end
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
context "on Linux" do
|
17
|
+
before :each do
|
18
|
+
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
19
|
+
end
|
20
|
+
|
21
|
+
def expect_ifconfig_parse(address, fixture)
|
22
|
+
Facter::Util::IP.stubs(:exec_ifconfig).returns(my_fixture_read(fixture))
|
23
|
+
Facter.fact(:ipaddress).value.should == address
|
24
|
+
end
|
25
|
+
|
26
|
+
it "parses correctly on Ubuntu 12.04" do
|
27
|
+
expect_ifconfig_parse "10.87.80.110", "ifconfig_ubuntu_1204.txt"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "parses correctly on Fedora 17" do
|
31
|
+
expect_ifconfig_parse "131.252.209.153", "ifconfig_net_tools_1.60.txt"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "parses a real address over multiple loopback addresses" do
|
35
|
+
expect_ifconfig_parse "10.0.222.20", "ifconfig_multiple_127_addresses.txt"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "parses nothing with a non-english locale" do
|
39
|
+
expect_ifconfig_parse nil, "ifconfig_non_english_locale.txt"
|
40
|
+
end
|
41
|
+
end
|
21
42
|
end
|
22
|
-
|
43
|
+
|
44
|
+
context "on Windows" do
|
45
|
+
require 'facter/util/wmi'
|
46
|
+
require 'facter/util/registry'
|
47
|
+
require 'facter/util/ip/windows'
|
48
|
+
require 'facter_spec/windows_network'
|
49
|
+
|
50
|
+
include FacterSpec::WindowsNetwork
|
51
|
+
|
23
52
|
before :each do
|
24
|
-
Facter.fact(:kernel).stubs(:value).returns(
|
53
|
+
Facter.fact(:kernel).stubs(:value).returns(:windows)
|
54
|
+
Facter.fact(:kernelrelease).stubs(:value).returns('6.1.7601')
|
55
|
+
Facter::Util::Registry.stubs(:hklm_read).returns(nic_bindings)
|
25
56
|
end
|
26
57
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
58
|
+
it "should do what when VPN is turned on?"
|
59
|
+
|
60
|
+
context "when you have no active network adapter" do
|
61
|
+
it "should return nil if there are no active (or any) network adapters" do
|
62
|
+
Facter::Util::WMI.expects(:execquery).with(Facter::Util::IP::Windows::WMI_IP_INFO_QUERY).returns([])
|
63
|
+
Facter::Util::Resolution.stubs(:exec)
|
64
|
+
|
65
|
+
Facter.value(:ipaddress).should == nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "when you have one network adapter" do
|
70
|
+
it "should return the ip address properly" do
|
71
|
+
nic = given_a_valid_windows_nic_with_ipv4_and_ipv6
|
72
|
+
Facter::Util::WMI.expects(:execquery).returns([nic])
|
73
|
+
|
74
|
+
Facter.value(:ipaddress).should == ipAddress0
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context "when you have more than one network adapter" do
|
79
|
+
it "should return the ip of the adapter with the lowest IP connection metric (best connection)" do
|
80
|
+
nics = given_two_valid_windows_nics_with_ipv4_and_ipv6
|
81
|
+
nics[:nic1].expects(:IPConnectionMetric).returns(5)
|
82
|
+
Facter::Util::WMI.expects(:execquery).returns(nics.values)
|
83
|
+
|
84
|
+
Facter.value(:ipaddress).should == ipAddress1
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should return the ip of the adapter with the lowest IP connection metric (best connection) that has ipv4 enabled" do
|
88
|
+
nics = given_two_valid_windows_nics_with_ipv4_and_ipv6
|
89
|
+
nics[:nic1].expects(:IPConnectionMetric).returns(5)
|
90
|
+
nics[:nic1].expects(:IPAddress).returns([ipv6Address1])
|
91
|
+
Facter::Util::WMI.expects(:execquery).returns(nics.values)
|
92
|
+
|
93
|
+
Facter.value(:ipaddress).should == ipAddress0
|
94
|
+
end
|
95
|
+
|
96
|
+
context "when the IP connection metric is the same" do
|
97
|
+
it "should return the ip of the adapter with the lowest binding order" do
|
98
|
+
nics = given_two_valid_windows_nics_with_ipv4_and_ipv6
|
99
|
+
Facter::Util::WMI.expects(:execquery).returns(nics.values)
|
100
|
+
|
101
|
+
Facter.value(:ipaddress).should == ipAddress0
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should return the ip of the adapter with the lowest binding order even if the adapter is not first" do
|
105
|
+
nics = given_two_valid_windows_nics_with_ipv4_and_ipv6
|
106
|
+
Facter::Util::WMI.expects(:execquery).returns(nics.values)
|
107
|
+
Facter::Util::Registry.stubs(:hklm_read).returns(["\\Device\\#{settingId1}", "\\Device\\#{settingId0}" ])
|
108
|
+
|
109
|
+
Facter.value(:ipaddress).should == ipAddress1
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
35
113
|
end
|
36
114
|
end
|
data/spec/unit/memory_spec.rb
CHANGED
@@ -3,15 +3,15 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe "Memory facts" do
|
6
|
-
|
6
|
+
before(:each) do
|
7
|
+
Facter.collection.internal_loader.load(:memory)
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:each) do
|
7
11
|
Facter.clear
|
8
12
|
end
|
9
13
|
|
10
14
|
describe "when returning scaled sizes" do
|
11
|
-
before(:each) do
|
12
|
-
Facter.collection.internal_loader.load(:memory)
|
13
|
-
end
|
14
|
-
|
15
15
|
[ "memorysize",
|
16
16
|
"memoryfree",
|
17
17
|
"swapsize",
|
@@ -46,6 +46,7 @@ describe "Memory facts" do
|
|
46
46
|
|
47
47
|
describe "on Darwin" do
|
48
48
|
before(:each) do
|
49
|
+
Facter.clear
|
49
50
|
Facter.fact(:kernel).stubs(:value).returns("Darwin")
|
50
51
|
Facter::Util::Resolution.stubs(:exec).with('sysctl -n hw.memsize').returns('8589934592')
|
51
52
|
sample_vm_stat = <<VMSTAT
|
@@ -515,8 +516,8 @@ SWAP
|
|
515
516
|
end
|
516
517
|
|
517
518
|
it "should use the memorysize fact for the memorytotal fact" do
|
518
|
-
Facter.fact("memorysize").expects(:value).once.returns "
|
519
|
+
Facter.fact("memorysize").expects(:value).once.returns "16.00 GB"
|
519
520
|
Facter::Util::Resolution.expects(:exec).never
|
520
|
-
Facter.fact(
|
521
|
+
Facter.fact(:memorytotal).value.should == "16.00 GB"
|
521
522
|
end
|
522
523
|
end
|
data/spec/unit/netmask_spec.rb
CHANGED
@@ -13,12 +13,12 @@ shared_examples_for "netmask from ifconfig output" do |platform, address, fixtur
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
describe "netmask fact" do
|
17
|
-
before :each do
|
18
|
-
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
19
|
-
end
|
20
|
-
|
16
|
+
describe "The netmask fact" do
|
21
17
|
context "on Linux" do
|
18
|
+
before :each do
|
19
|
+
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
20
|
+
end
|
21
|
+
|
22
22
|
example_behavior_for "netmask from ifconfig output",
|
23
23
|
"Archlinux (net-tools 1.60)", "255.255.255.0",
|
24
24
|
"ifconfig_net_tools_1.60.txt"
|
@@ -26,4 +26,61 @@ describe "netmask fact" do
|
|
26
26
|
"Ubuntu 12.04", "255.255.255.255",
|
27
27
|
"ifconfig_ubuntu_1204.txt"
|
28
28
|
end
|
29
|
+
|
30
|
+
context "on Windows" do
|
31
|
+
require 'facter/util/wmi'
|
32
|
+
require 'facter/util/registry'
|
33
|
+
require 'facter_spec/windows_network'
|
34
|
+
|
35
|
+
include FacterSpec::WindowsNetwork
|
36
|
+
|
37
|
+
before :each do
|
38
|
+
Facter.fact(:kernel).stubs(:value).returns(:windows)
|
39
|
+
Facter::Util::Registry.stubs(:hklm_read).returns(nic_bindings)
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "when you have no active network adapter" do
|
43
|
+
it "should return nil if there are no active (or any) network adapters" do
|
44
|
+
Facter::Util::WMI.expects(:execquery).returns([])
|
45
|
+
|
46
|
+
Facter.value(:netmask).should == nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "when you have one network adapter" do
|
51
|
+
it "should return properly" do
|
52
|
+
nic = given_a_valid_windows_nic_with_ipv4_and_ipv6
|
53
|
+
Facter::Util::WMI.expects(:execquery).returns([nic])
|
54
|
+
|
55
|
+
Facter.value(:netmask).should == subnet0
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "when you have more than one network adapter" do
|
60
|
+
it "should return the netmask of the adapter with the lowest IP connection metric (best connection)" do
|
61
|
+
nics = given_two_valid_windows_nics_with_ipv4_and_ipv6
|
62
|
+
nics[:nic1].expects(:IPConnectionMetric).returns(5)
|
63
|
+
Facter::Util::WMI.expects(:execquery).returns(nics.values)
|
64
|
+
|
65
|
+
Facter.value(:netmask).should == subnet1
|
66
|
+
end
|
67
|
+
|
68
|
+
context "when the IP connection metric is the same" do
|
69
|
+
it "should return the netmask of the adapter with the lowest binding order" do
|
70
|
+
nics = given_two_valid_windows_nics_with_ipv4_and_ipv6
|
71
|
+
Facter::Util::WMI.expects(:execquery).returns(nics.values)
|
72
|
+
|
73
|
+
Facter.value(:netmask).should == subnet0
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should return the netmask of the adapter with the lowest binding even if the adapter is not first" do
|
77
|
+
nics = given_two_valid_windows_nics_with_ipv4_and_ipv6
|
78
|
+
Facter::Util::WMI.expects(:execquery).returns(nics.values)
|
79
|
+
Facter::Util::Registry.stubs(:hklm_read).returns(["\\Device\\#{settingId1}", "\\Device\\#{settingId0}" ])
|
80
|
+
|
81
|
+
Facter.value(:netmask).should == subnet1
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
29
86
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'facter/util/ip/windows'
|
5
|
+
|
6
|
+
describe Facter::Util::IP::Windows do
|
7
|
+
before :each do
|
8
|
+
Facter.fact(:kernel).stubs(:value).returns('windows')
|
9
|
+
end
|
10
|
+
|
11
|
+
describe ".to_s" do
|
12
|
+
let(:to_s) { described_class.to_s }
|
13
|
+
|
14
|
+
it { to_s.should eq 'windows' }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".convert_netmask_from_hex?" do
|
18
|
+
let :convert_netmask_from_hex? do
|
19
|
+
described_class.convert_netmask_from_hex?
|
20
|
+
end
|
21
|
+
|
22
|
+
it { convert_netmask_from_hex?.should be false }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe ".bonding_master" do
|
26
|
+
let(:bonding_master) { described_class.bonding_master('eth0') }
|
27
|
+
|
28
|
+
pending("porting to Windows") do
|
29
|
+
it { bonding_master.should be_nil }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ".interfaces" do
|
34
|
+
let(:name) { 'Local Area Connection' }
|
35
|
+
let(:index) { 7 }
|
36
|
+
let(:nic_config) { mock('nic_config', :Index => index) }
|
37
|
+
let(:nic) { mock('nic', :NetConnectionId => name ) }
|
38
|
+
|
39
|
+
it "should return an array of only connected interfaces" do
|
40
|
+
Facter::Util::WMI.expects(:execquery).with(Facter::Util::IP::Windows::WMI_IP_INFO_QUERY).
|
41
|
+
returns([nic_config])
|
42
|
+
Facter::Util::WMI.expects(:execquery).with("SELECT * FROM Win32_NetworkAdapter WHERE Index = #{index}").
|
43
|
+
returns([nic])
|
44
|
+
|
45
|
+
described_class.interfaces.should == [name]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/spec/unit/util/ip_spec.rb
CHANGED
@@ -52,8 +52,8 @@ describe Facter::Util::IP do
|
|
52
52
|
|
53
53
|
it "should return a list of only connected interfaces on Windows" do
|
54
54
|
Facter.fact(:kernel).stubs(:value).returns("windows")
|
55
|
-
|
56
|
-
Facter::Util::IP.
|
55
|
+
|
56
|
+
Facter::Util::IP::Windows.expects(:interfaces).returns(["Loopback Pseudo-Interface 1", "Local Area Connection", "Teredo Tunneling Pseudo-Interface"])
|
57
57
|
Facter::Util::IP.get_interfaces().should == ["Loopback Pseudo-Interface 1", "Local Area Connection", "Teredo Tunneling Pseudo-Interface"]
|
58
58
|
end
|
59
59
|
|
@@ -373,41 +373,29 @@ describe Facter::Util::IP do
|
|
373
373
|
end
|
374
374
|
|
375
375
|
describe "on Windows" do
|
376
|
+
require 'facter/util/ip/windows'
|
377
|
+
|
376
378
|
before :each do
|
377
379
|
Facter.stubs(:value).with(:kernel).returns("windows")
|
378
380
|
end
|
379
381
|
|
380
382
|
it "should return ipaddress information" do
|
381
|
-
|
382
|
-
|
383
|
-
Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Local Area Connection", "ipaddress").returns(windows_netsh)
|
383
|
+
Facter::Util::IP::Windows.expects(:value_for_interface_and_label).with("Local Area Connection", "ipaddress").returns('172.16.138.216')
|
384
384
|
|
385
385
|
Facter::Util::IP.get_interface_value("Local Area Connection", "ipaddress").should == "172.16.138.216"
|
386
386
|
end
|
387
387
|
|
388
|
-
it "should return a human readable netmask" do
|
389
|
-
windows_netsh = my_fixture_read("windows_netsh_single_interface")
|
390
|
-
|
391
|
-
Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Local Area Connection", "netmask").returns(windows_netsh)
|
392
|
-
|
393
|
-
Facter::Util::IP.get_interface_value("Local Area Connection", "netmask").should == "255.255.255.0"
|
394
|
-
end
|
395
|
-
|
396
388
|
it "should return network information" do
|
397
|
-
|
398
|
-
|
399
|
-
Facter::Util::IP.stubs(:get_output_for_interface_and_label).with("Local Area Connection", "ipaddress").returns(windows_netsh)
|
400
|
-
Facter::Util::IP.stubs(:get_output_for_interface_and_label).with("Local Area Connection", "netmask").returns(windows_netsh)
|
389
|
+
Facter::Util::IP::Windows.expects(:value_for_interface_and_label).with("Local Area Connection", "ipaddress").returns('172.16.138.216')
|
390
|
+
Facter::Util::IP::Windows.expects(:value_for_interface_and_label).with("Local Area Connection", "netmask").returns('255.255.255.0')
|
401
391
|
|
402
392
|
Facter::Util::IP.get_network_value("Local Area Connection").should == "172.16.138.0"
|
403
393
|
end
|
404
394
|
|
405
395
|
it "should return ipaddress6 information" do
|
406
|
-
|
407
|
-
|
408
|
-
Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Teredo Tunneling Pseudo-Interface", "ipaddress6").returns(windows_netsh)
|
396
|
+
Facter::Util::IP::Windows.expects(:value_for_interface_and_label).with("Local Area Connection", "ipaddress6").returns("2001:0:4137:9e76:2087:77a:53ef:7527")
|
409
397
|
|
410
|
-
Facter::Util::IP.get_interface_value("
|
398
|
+
Facter::Util::IP.get_interface_value("Local Area Connection", "ipaddress6").should == "2001:0:4137:9e76:2087:77a:53ef:7527"
|
411
399
|
end
|
412
400
|
end
|
413
401
|
|
@@ -81,19 +81,61 @@ describe "Darwin", :unless => Facter::Util::Config.is_windows? do
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
describe "
|
85
|
-
|
86
|
-
|
84
|
+
describe "The macaddress fact" do
|
85
|
+
context "on Windows" do
|
86
|
+
require 'facter/util/wmi'
|
87
|
+
require 'facter/util/registry'
|
88
|
+
require 'facter_spec/windows_network'
|
87
89
|
|
88
|
-
|
89
|
-
nic.stubs(:MacAddress).returns("00:0C:29:0C:9E:9F")
|
90
|
+
include FacterSpec::WindowsNetwork
|
90
91
|
|
91
|
-
|
92
|
-
|
92
|
+
before :each do
|
93
|
+
Facter.fact(:kernel).stubs(:value).returns(:windows)
|
94
|
+
Facter::Util::Registry.stubs(:hklm_read).returns(nic_bindings)
|
95
|
+
end
|
93
96
|
|
94
|
-
|
95
|
-
|
97
|
+
describe "when you have no active network adapter" do
|
98
|
+
it "should return nil if there are no active (or any) network adapters" do
|
99
|
+
Facter::Util::WMI.expects(:execquery).returns([])
|
100
|
+
|
101
|
+
Facter.value(:macaddress).should == nil
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "when you have one network adapter" do
|
106
|
+
it "should return properly" do
|
107
|
+
nic = given_a_valid_windows_nic_with_ipv4_and_ipv6
|
108
|
+
Facter::Util::WMI.expects(:execquery).returns([nic])
|
109
|
+
|
110
|
+
Facter.value(:macaddress).should == macAddress0
|
111
|
+
end
|
112
|
+
end
|
96
113
|
|
97
|
-
|
114
|
+
describe "when you have more than one network adapter" do
|
115
|
+
it "should return the macaddress of the adapter with the lowest IP connection metric (best connection)" do
|
116
|
+
nics = given_two_valid_windows_nics_with_ipv4_and_ipv6
|
117
|
+
nics[:nic1].expects(:IPConnectionMetric).returns(5)
|
118
|
+
Facter::Util::WMI.expects(:execquery).returns(nics.values)
|
119
|
+
|
120
|
+
Facter.value(:macaddress).should == macAddress1
|
121
|
+
end
|
122
|
+
|
123
|
+
context "when the IP connection metric is the same" do
|
124
|
+
it "should return the macaddress of the adapter with the lowest binding order" do
|
125
|
+
nics = given_two_valid_windows_nics_with_ipv4_and_ipv6
|
126
|
+
Facter::Util::WMI.expects(:execquery).returns(nics.values)
|
127
|
+
|
128
|
+
Facter.value(:macaddress).should == macAddress0
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should return the macaddress of the adapter with the lowest MACAddress when multiple adapters have the same IP connection metric when the lowest MACAddress is not first" do
|
132
|
+
nics = given_two_valid_windows_nics_with_ipv4_and_ipv6
|
133
|
+
Facter::Util::WMI.expects(:execquery).returns(nics.values)
|
134
|
+
Facter::Util::Registry.stubs(:hklm_read).returns(["\\Device\\#{settingId1}", "\\Device\\#{settingId0}" ])
|
135
|
+
|
136
|
+
Facter.value(:macaddress).should == macAddress1
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
98
140
|
end
|
99
141
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
-
|
5
4
|
require 'facter/util/parser'
|
6
5
|
require 'tempfile'
|
7
6
|
require 'tmpdir.rb'
|
@@ -121,12 +120,42 @@ describe Facter::Util::Parser do
|
|
121
120
|
Facter::Util::Parser.parser_for(cmd)
|
122
121
|
end
|
123
122
|
|
124
|
-
it "should
|
125
|
-
|
123
|
+
it "should not parse a directory" do
|
124
|
+
File.stubs(:file?).with(cmd).returns(false)
|
125
|
+
Facter::Util::Parser.parser_for(cmd).results.should be_nil
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should return the data properly" do
|
129
|
+
File.stubs(:file?).with(cmd).returns(true)
|
130
|
+
parser.results.should == data
|
126
131
|
end
|
127
132
|
end
|
128
133
|
end
|
129
134
|
|
135
|
+
describe "powershell parser" do
|
136
|
+
let :ps1 do "/tmp/foo.ps1" end
|
137
|
+
let :data_in_ps1 do "one=two\nthree=four\n" end
|
138
|
+
|
139
|
+
before :each do
|
140
|
+
Facter::Util::Config.stubs(:is_windows?).returns(true)
|
141
|
+
Facter::Util::Resolution.stubs(:exec).returns(data_in_ps1)
|
142
|
+
end
|
143
|
+
|
144
|
+
let :parser do
|
145
|
+
Facter::Util::Parser.parser_for(ps1)
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should not parse a directory" do
|
149
|
+
File.stubs(:file?).with(ps1).returns(false)
|
150
|
+
Facter::Util::Parser.parser_for(ps1).results.should be_nil
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should return data properly" do
|
154
|
+
File.stubs(:file?).with(ps1).returns(true)
|
155
|
+
parser.results.should == data
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
130
159
|
describe "nothing parser" do
|
131
160
|
it "uses the nothing parser when there is no other parser" do
|
132
161
|
Facter::Util::Parser.parser_for("this.is.not.valid").results.should be_nil
|