diff options
| author | James Turnbull <james@lovedthanlost.net> | 2011-03-08 09:30:03 +1100 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2011-03-09 06:42:08 +1100 |
| commit | ba2601f6eeb0428bf46dbb312241077c6aa37754 (patch) | |
| tree | ad7820ff218d828623860421cc0ce4f3979619a6 /spec/unit | |
| parent | 469d2a26a467c50af9f9732d7f98e8a01ecc369f (diff) | |
| download | facter-ba2601f6eeb0428bf46dbb312241077c6aa37754.tar.gz facter-ba2601f6eeb0428bf46dbb312241077c6aa37754.tar.xz facter-ba2601f6eeb0428bf46dbb312241077c6aa37754.zip | |
Fix for #6495 - Updated interface detection
1. Fixed IP return to not filter lo/localhost and return it
as a proper interface
2. Fixed HP-UX netstat return to remove extraneous first line
of naming.
3. Updated tests to reflect changes
Diffstat (limited to 'spec/unit')
| -rw-r--r-- | spec/unit/data/hpux_netstat_all_interfaces | 9 | ||||
| -rwxr-xr-x | spec/unit/util/ip_spec.rb | 20 |
2 files changed, 13 insertions, 16 deletions
diff --git a/spec/unit/data/hpux_netstat_all_interfaces b/spec/unit/data/hpux_netstat_all_interfaces index 7745fa8..0e8f9dc 100644 --- a/spec/unit/data/hpux_netstat_all_interfaces +++ b/spec/unit/data/hpux_netstat_all_interfaces @@ -1,6 +1,3 @@ -Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll -lan1 1500 15.12.0.0 host1.default.com - 572527659 0 1129421249 0 0 -lan0 1500 172.54.85.0 host2.default.com - 519222647 0 329127145 0 0 -lo0 4136 loopback localhost 14281117 0 14281125 0 0 +lan1 1500 192.168.100.0 192.168.100.182 12964 0 900 0 0 +lan0 1500 192.168.100.0 192.168.100.181 12964 0 715 0 0 +lo0 4136 127.0.0.0 127.0.0.1 98 0 98 0 0 diff --git a/spec/unit/util/ip_spec.rb b/spec/unit/util/ip_spec.rb index ceceb3f..1a545b8 100755 --- a/spec/unit/util/ip_spec.rb +++ b/spec/unit/util/ip_spec.rb @@ -20,11 +20,11 @@ describe Facter::Util::IP do Facter::Util::IP.get_interfaces().should == [] end - it "should return a list with a single interface on Linux with a single interface" do + it "should return a list with a single interface and the loopback interface on Linux with a single interface" do sample_output_file = File.dirname(__FILE__) + '/../data/linux_ifconfig_all_with_single_interface' linux_ifconfig = File.new(sample_output_file).read() Facter::Util::IP.stubs(:get_all_interface_output).returns(linux_ifconfig) - Facter::Util::IP.get_interfaces().should == ["eth0"] + Facter::Util::IP.get_interfaces().should == ["eth0", "lo"] end it "should return a list two interfaces on Darwin with two interfaces" do @@ -46,7 +46,7 @@ describe Facter::Util::IP do hpux_netstat = File.new(sample_output_file).read() Facter::Util::IP.stubs(:get_all_interface_output).returns(hpux_netstat) Facter::Util::IP.get_interfaces().should == ["lan1", "lan0", "lo0"] - end + end it "should return a list of six interfaces on a GNU/kFreeBSD with six interfaces" do sample_output_file = File.dirname(__FILE__) + '/../data/debian_kfreebsd_ifconfig' @@ -102,7 +102,7 @@ describe Facter::Util::IP do Facter.stubs(:value).with(:kernel).returns("HP-UX") Facter::Util::IP.get_interface_value("lan0", "ipaddress").should == "168.24.80.71" - end + end it "should return macaddress information for HP-UX" do sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface" @@ -112,7 +112,7 @@ describe Facter::Util::IP do Facter.stubs(:value).with(:kernel).returns("HP-UX") Facter::Util::IP.get_interface_value("lan0", "macaddress").should == "00:13:21:BD:9C:B7" - end + end it "should return macaddress with leading zeros stripped off for GNU/kFreeBSD" do sample_output_file = File.dirname(__FILE__) + "/../data/debian_kfreebsd_ifconfig" @@ -132,7 +132,7 @@ describe Facter::Util::IP do Facter.stubs(:value).with(:kernel).returns("HP-UX") Facter::Util::IP.get_interface_value("lan0", "netmask").should == "255.255.255.0" - end + end it "should return calculated network information for HP-UX" do sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface" @@ -142,7 +142,7 @@ describe Facter::Util::IP do Facter.stubs(:value).with(:kernel).returns("HP-UX") Facter::Util::IP.get_network_value("lan0").should == "168.24.80.0" - end + end it "should return interface information for FreeBSD supported via an alias" do sample_output_file = File.dirname(__FILE__) + "/../data/6.0-STABLE_FreeBSD_ifconfig" @@ -192,7 +192,7 @@ describe Facter::Util::IP do Facter.stubs(:value).with(:kernel).returns("HP-UX") Facter::Util::IP.get_interface_value("lan0", "netmask").should == "255.255.255.0" - end + end it "should return a human readable netmask on Darwin" do sample_output_file = File.dirname(__FILE__) + "/../data/darwin_ifconfig_single_interface" @@ -204,7 +204,7 @@ describe Facter::Util::IP do Facter::Util::IP.get_interface_value("en1", "netmask").should == "255.255.255.0" end - + it "should return a human readable netmask on GNU/kFreeBSD" do sample_output_file = File.dirname(__FILE__) + "/../data/debian_kfreebsd_ifconfig" @@ -218,7 +218,7 @@ describe Facter::Util::IP do it "should not get bonding master on interface aliases" do Facter.stubs(:value).with(:kernel).returns("Linux") - + Facter::Util::IP.get_bonding_master("eth0:1").should be_nil end |
