facter 1.6.2 → 1.6.3

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.

Files changed (57) hide show
  1. data/CHANGELOG +11 -0
  2. data/LICENSE +1 -1
  3. data/conf/osx/createpackage.sh +1 -1
  4. data/conf/redhat/facter.spec +9 -6
  5. data/conf/solaris/pkginfo +1 -1
  6. data/install.rb +1 -1
  7. data/lib/facter.rb +2 -2
  8. data/lib/facter/architecture.rb +1 -2
  9. data/lib/facter/augeasversion.rb +1 -2
  10. data/lib/facter/domain.rb +3 -3
  11. data/lib/facter/hardwareisa.rb +1 -1
  12. data/lib/facter/ipaddress.rb +2 -2
  13. data/lib/facter/lsbmajdistrelease.rb +1 -1
  14. data/lib/facter/macaddress.rb +2 -2
  15. data/lib/facter/manufacturer.rb +1 -1
  16. data/lib/facter/netmask.rb +0 -3
  17. data/lib/facter/network.rb +2 -3
  18. data/lib/facter/operatingsystem.rb +5 -2
  19. data/lib/facter/operatingsystemrelease.rb +3 -3
  20. data/lib/facter/osfamily.rb +1 -1
  21. data/lib/facter/processor.rb +2 -2
  22. data/lib/facter/selinux.rb +3 -3
  23. data/lib/facter/uniqueid.rb +1 -1
  24. data/lib/facter/uptime_days.rb +0 -1
  25. data/lib/facter/uptime_hours.rb +0 -1
  26. data/lib/facter/util/manufacturer.rb +2 -3
  27. data/lib/facter/util/processor.rb +3 -3
  28. data/lib/facter/util/resolution.rb +3 -3
  29. data/lib/facter/util/values.rb +1 -1
  30. data/lib/facter/virtual.rb +2 -2
  31. data/lib/facter/vlans.rb +1 -2
  32. data/lib/facter/xendomains.rb +0 -1
  33. data/spec/fixtures/unit/util/manufacturer/solaris_sunfire_v120_prtdiag +33 -0
  34. data/spec/fixtures/unit/util/manufacturer/solaris_t5220_prtdiag +136 -0
  35. data/spec/spec_helper.rb +5 -0
  36. data/spec/unit/architecture_spec.rb +40 -40
  37. data/spec/unit/facter_spec.rb +220 -220
  38. data/spec/unit/id_spec.rb +16 -16
  39. data/spec/unit/interfaces_spec.rb +6 -6
  40. data/spec/unit/memory_spec.rb +105 -105
  41. data/spec/unit/operatingsystem_spec.rb +72 -63
  42. data/spec/unit/operatingsystemrelease_spec.rb +44 -43
  43. data/spec/unit/processor_spec.rb +2 -2
  44. data/spec/unit/selinux_spec.rb +53 -53
  45. data/spec/unit/util/collection_spec.rb +183 -183
  46. data/spec/unit/util/confine_spec.rb +92 -92
  47. data/spec/unit/util/fact_spec.rb +96 -96
  48. data/spec/unit/util/ip_spec.rb +218 -218
  49. data/spec/unit/util/loader_spec.rb +193 -193
  50. data/spec/unit/util/macosx_spec.rb +63 -63
  51. data/spec/unit/util/manufacturer_spec.rb +124 -107
  52. data/spec/unit/util/resolution_spec.rb +235 -235
  53. data/spec/unit/util/virtual_spec.rb +167 -167
  54. data/spec/unit/util/vlans_spec.rb +6 -6
  55. data/spec/unit/virtual_spec.rb +246 -246
  56. data/spec/watchr.rb +1 -1
  57. metadata +6 -4
@@ -8,133 +8,133 @@ require 'facter/util/values'
8
8
  include Facter::Util::Values
9
9
 
10
10
  describe Facter::Util::Confine do
11
- it "should require a fact name" do
12
- Facter::Util::Confine.new("yay", true).fact.should == "yay"
11
+ it "should require a fact name" do
12
+ Facter::Util::Confine.new("yay", true).fact.should == "yay"
13
+ end
14
+
15
+ it "should accept a value specified individually" do
16
+ Facter::Util::Confine.new("yay", "test").values.should == ["test"]
17
+ end
18
+
19
+ it "should accept multiple values specified at once" do
20
+ Facter::Util::Confine.new("yay", "test", "other").values.should == ["test", "other"]
21
+ end
22
+
23
+ it "should fail if no fact name is provided" do
24
+ lambda { Facter::Util::Confine.new(nil, :test) }.should raise_error(ArgumentError)
25
+ end
26
+
27
+ it "should fail if no values were provided" do
28
+ lambda { Facter::Util::Confine.new("yay") }.should raise_error(ArgumentError)
29
+ end
30
+
31
+ it "should have a method for testing whether it matches" do
32
+ Facter::Util::Confine.new("yay", :test).should respond_to(:true?)
33
+ end
34
+
35
+ describe "when evaluating" do
36
+ before do
37
+ @confine = Facter::Util::Confine.new("yay", "one", "two", "Four", :xy, true, 1, [3,4])
38
+ @fact = mock 'fact'
39
+ Facter.stubs(:[]).returns @fact
13
40
  end
14
41
 
15
- it "should accept a value specified individually" do
16
- Facter::Util::Confine.new("yay", "test").values.should == ["test"]
17
- end
42
+ it "should return false if the fact does not exist" do
43
+ Facter.expects(:[]).with("yay").returns nil
18
44
 
19
- it "should accept multiple values specified at once" do
20
- Facter::Util::Confine.new("yay", "test", "other").values.should == ["test", "other"]
45
+ @confine.true?.should be_false
21
46
  end
22
47
 
23
- it "should fail if no fact name is provided" do
24
- lambda { Facter::Util::Confine.new(nil, :test) }.should raise_error(ArgumentError)
25
- end
48
+ it "should use the returned fact to get the value" do
49
+ Facter.expects(:[]).with("yay").returns @fact
26
50
 
27
- it "should fail if no values were provided" do
28
- lambda { Facter::Util::Confine.new("yay") }.should raise_error(ArgumentError)
29
- end
51
+ @fact.expects(:value).returns nil
30
52
 
31
- it "should have a method for testing whether it matches" do
32
- Facter::Util::Confine.new("yay", :test).should respond_to(:true?)
53
+ @confine.true?
33
54
  end
34
55
 
35
- describe "when evaluating" do
36
- before do
37
- @confine = Facter::Util::Confine.new("yay", "one", "two", "Four", :xy, true, 1, [3,4])
38
- @fact = mock 'fact'
39
- Facter.stubs(:[]).returns @fact
40
- end
41
-
42
- it "should return false if the fact does not exist" do
43
- Facter.expects(:[]).with("yay").returns nil
44
-
45
- @confine.true?.should be_false
46
- end
47
-
48
- it "should use the returned fact to get the value" do
49
- Facter.expects(:[]).with("yay").returns @fact
56
+ it "should return false if the fact has no value" do
57
+ @fact.stubs(:value).returns nil
50
58
 
51
- @fact.expects(:value).returns nil
52
-
53
- @confine.true?
54
- end
55
-
56
- it "should return false if the fact has no value" do
57
- @fact.stubs(:value).returns nil
58
-
59
- @confine.true?.should be_false
60
- end
59
+ @confine.true?.should be_false
60
+ end
61
61
 
62
- it "should return true if any of the provided values matches the fact's value" do
63
- @fact.stubs(:value).returns "two"
62
+ it "should return true if any of the provided values matches the fact's value" do
63
+ @fact.stubs(:value).returns "two"
64
64
 
65
- @confine.true?.should be_true
66
- end
65
+ @confine.true?.should be_true
66
+ end
67
67
 
68
- it "should return true if any of the provided symbol values matches the fact's value" do
69
- @fact.stubs(:value).returns :xy
68
+ it "should return true if any of the provided symbol values matches the fact's value" do
69
+ @fact.stubs(:value).returns :xy
70
70
 
71
- @confine.true?.should be_true
72
- end
71
+ @confine.true?.should be_true
72
+ end
73
73
 
74
- it "should return true if any of the provided integer values matches the fact's value" do
75
- @fact.stubs(:value).returns 1
74
+ it "should return true if any of the provided integer values matches the fact's value" do
75
+ @fact.stubs(:value).returns 1
76
76
 
77
- @confine.true?.should be_true
78
- end
77
+ @confine.true?.should be_true
78
+ end
79
79
 
80
- it "should return true if any of the provided boolan values matches the fact's value" do
81
- @fact.stubs(:value).returns true
80
+ it "should return true if any of the provided boolan values matches the fact's value" do
81
+ @fact.stubs(:value).returns true
82
82
 
83
- @confine.true?.should be_true
84
- end
83
+ @confine.true?.should be_true
84
+ end
85
85
 
86
- it "should return true if any of the provided array values matches the fact's value" do
87
- @fact.stubs(:value).returns [3,4]
86
+ it "should return true if any of the provided array values matches the fact's value" do
87
+ @fact.stubs(:value).returns [3,4]
88
88
 
89
- @confine.true?.should be_true
90
- end
89
+ @confine.true?.should be_true
90
+ end
91
91
 
92
- it "should return true if any of the provided symbol values matches the fact's string value" do
93
- @fact.stubs(:value).returns :one
92
+ it "should return true if any of the provided symbol values matches the fact's string value" do
93
+ @fact.stubs(:value).returns :one
94
94
 
95
- @confine.true?.should be_true
96
- end
95
+ @confine.true?.should be_true
96
+ end
97
97
 
98
- it "should return true if any of the provided string values matches case-insensitive the fact's value" do
99
- @fact.stubs(:value).returns "four"
98
+ it "should return true if any of the provided string values matches case-insensitive the fact's value" do
99
+ @fact.stubs(:value).returns "four"
100
100
 
101
- @confine.true?.should be_true
102
- end
101
+ @confine.true?.should be_true
102
+ end
103
103
 
104
- it "should return true if any of the provided symbol values matches case-insensitive the fact's string value" do
105
- @fact.stubs(:value).returns :four
104
+ it "should return true if any of the provided symbol values matches case-insensitive the fact's string value" do
105
+ @fact.stubs(:value).returns :four
106
106
 
107
- @confine.true?.should be_true
108
- end
107
+ @confine.true?.should be_true
108
+ end
109
109
 
110
- it "should return true if any of the provided symbol values matches the fact's string value" do
111
- @fact.stubs(:value).returns :Xy
110
+ it "should return true if any of the provided symbol values matches the fact's string value" do
111
+ @fact.stubs(:value).returns :Xy
112
112
 
113
- @confine.true?.should be_true
114
- end
113
+ @confine.true?.should be_true
114
+ end
115
115
 
116
- it "should return false if none of the provided values matches the fact's value" do
117
- @fact.stubs(:value).returns "three"
116
+ it "should return false if none of the provided values matches the fact's value" do
117
+ @fact.stubs(:value).returns "three"
118
118
 
119
- @confine.true?.should be_false
120
- end
119
+ @confine.true?.should be_false
120
+ end
121
121
 
122
- it "should return false if none of the provided integer values matches the fact's value" do
123
- @fact.stubs(:value).returns 2
122
+ it "should return false if none of the provided integer values matches the fact's value" do
123
+ @fact.stubs(:value).returns 2
124
124
 
125
- @confine.true?.should be_false
126
- end
125
+ @confine.true?.should be_false
126
+ end
127
127
 
128
- it "should return false if none of the provided boolan values matches the fact's value" do
129
- @fact.stubs(:value).returns false
128
+ it "should return false if none of the provided boolan values matches the fact's value" do
129
+ @fact.stubs(:value).returns false
130
130
 
131
- @confine.true?.should be_false
132
- end
131
+ @confine.true?.should be_false
132
+ end
133
133
 
134
- it "should return false if none of the provided array values matches the fact's value" do
135
- @fact.stubs(:value).returns [1,2]
134
+ it "should return false if none of the provided array values matches the fact's value" do
135
+ @fact.stubs(:value).returns [1,2]
136
136
 
137
- @confine.true?.should be_false
138
- end
137
+ @confine.true?.should be_false
139
138
  end
139
+ end
140
140
  end
@@ -5,125 +5,125 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
5
5
  require 'facter/util/fact'
6
6
 
7
7
  describe Facter::Util::Fact do
8
- it "should require a name" do
9
- lambda { Facter::Util::Fact.new }.should raise_error(ArgumentError)
10
- end
8
+ it "should require a name" do
9
+ lambda { Facter::Util::Fact.new }.should raise_error(ArgumentError)
10
+ end
11
11
 
12
- it "should always downcase the name and convert it to a symbol" do
13
- Facter::Util::Fact.new("YayNess").name.should == :yayness
14
- end
12
+ it "should always downcase the name and convert it to a symbol" do
13
+ Facter::Util::Fact.new("YayNess").name.should == :yayness
14
+ end
15
15
 
16
- it "should default to its name converted to a string as its ldapname" do
17
- Facter::Util::Fact.new("YayNess").ldapname.should == "yayness"
18
- end
16
+ it "should default to its name converted to a string as its ldapname" do
17
+ Facter::Util::Fact.new("YayNess").ldapname.should == "yayness"
18
+ end
19
19
 
20
- it "should allow specifying the ldap name at initialization" do
21
- Facter::Util::Fact.new("YayNess", :ldapname => "fooness").ldapname.should == "fooness"
22
- end
20
+ it "should allow specifying the ldap name at initialization" do
21
+ Facter::Util::Fact.new("YayNess", :ldapname => "fooness").ldapname.should == "fooness"
22
+ end
23
+
24
+ it "should fail if an unknown option is provided" do
25
+ lambda { Facter::Util::Fact.new('yay', :foo => :bar) }.should raise_error(ArgumentError)
26
+ end
27
+
28
+ it "should have a method for adding resolution mechanisms" do
29
+ Facter::Util::Fact.new("yay").should respond_to(:add)
30
+ end
31
+
32
+ describe "when adding resolution mechanisms" do
33
+ before do
34
+ @fact = Facter::Util::Fact.new("yay")
35
+
36
+ @resolution = mock 'resolution'
37
+ @resolution.stub_everything
23
38
 
24
- it "should fail if an unknown option is provided" do
25
- lambda { Facter::Util::Fact.new('yay', :foo => :bar) }.should raise_error(ArgumentError)
26
39
  end
27
40
 
28
- it "should have a method for adding resolution mechanisms" do
29
- Facter::Util::Fact.new("yay").should respond_to(:add)
41
+ it "should fail if no block is given" do
42
+ lambda { @fact.add }.should raise_error(ArgumentError)
30
43
  end
31
44
 
32
- describe "when adding resolution mechanisms" do
33
- before do
34
- @fact = Facter::Util::Fact.new("yay")
45
+ it "should create a new resolution instance" do
46
+ Facter::Util::Resolution.expects(:new).returns @resolution
47
+
48
+ @fact.add { }
49
+ end
35
50
 
36
- @resolution = mock 'resolution'
37
- @resolution.stub_everything
51
+ it "should instance_eval the passed block on the new resolution" do
52
+ @resolution.expects(:instance_eval)
38
53
 
39
- end
54
+ Facter::Util::Resolution.stubs(:new).returns @resolution
40
55
 
41
- it "should fail if no block is given" do
42
- lambda { @fact.add }.should raise_error(ArgumentError)
43
- end
56
+ @fact.add { }
57
+ end
44
58
 
45
- it "should create a new resolution instance" do
46
- Facter::Util::Resolution.expects(:new).returns @resolution
59
+ it "should re-sort the resolutions by weight, so the most restricted resolutions are first" do
60
+ r1 = stub 'r1', :weight => 1
61
+ r2 = stub 'r2', :weight => 2
62
+ r3 = stub 'r3', :weight => 0
63
+ Facter::Util::Resolution.expects(:new).times(3).returns(r1).returns(r2).returns(r3)
64
+ @fact.add { }
65
+ @fact.add { }
66
+ @fact.add { }
47
67
 
48
- @fact.add { }
49
- end
68
+ @fact.instance_variable_get("@resolves").should == [r2, r1, r3]
69
+ end
70
+ end
50
71
 
51
- it "should instance_eval the passed block on the new resolution" do
52
- @resolution.expects(:instance_eval)
72
+ it "should be able to return a value" do
73
+ Facter::Util::Fact.new("yay").should respond_to(:value)
74
+ end
53
75
 
54
- Facter::Util::Resolution.stubs(:new).returns @resolution
76
+ describe "when returning a value" do
77
+ before do
78
+ @fact = Facter::Util::Fact.new("yay")
79
+ end
55
80
 
56
- @fact.add { }
57
- end
81
+ it "should return nil if there are no resolutions" do
82
+ Facter::Util::Fact.new("yay").value.should be_nil
83
+ end
58
84
 
59
- it "should re-sort the resolutions by weight, so the most restricted resolutions are first" do
60
- r1 = stub 'r1', :weight => 1
61
- r2 = stub 'r2', :weight => 2
62
- r3 = stub 'r3', :weight => 0
63
- Facter::Util::Resolution.expects(:new).times(3).returns(r1).returns(r2).returns(r3)
64
- @fact.add { }
65
- @fact.add { }
66
- @fact.add { }
85
+ it "should return the first value returned by a resolution" do
86
+ r1 = stub 'r1', :weight => 2, :value => nil, :suitable? => true
87
+ r2 = stub 'r2', :weight => 1, :value => "yay", :suitable? => true
88
+ r3 = stub 'r3', :weight => 0, :value => "foo", :suitable? => true
89
+ Facter::Util::Resolution.expects(:new).times(3).returns(r1).returns(r2).returns(r3)
90
+ @fact.add { }
91
+ @fact.add { }
92
+ @fact.add { }
67
93
 
68
- @fact.instance_variable_get("@resolves").should == [r2, r1, r3]
69
- end
94
+ @fact.value.should == "yay"
70
95
  end
71
96
 
72
- it "should be able to return a value" do
73
- Facter::Util::Fact.new("yay").should respond_to(:value)
97
+ it "should short-cut returning the value once one is found" do
98
+ r1 = stub 'r1', :weight => 2, :value => "foo", :suitable? => true
99
+ r2 = stub 'r2', :weight => 1, :suitable? => true # would fail if 'value' were asked for
100
+ Facter::Util::Resolution.expects(:new).times(2).returns(r1).returns(r2)
101
+ @fact.add { }
102
+ @fact.add { }
103
+
104
+ @fact.value
74
105
  end
75
106
 
76
- describe "when returning a value" do
77
- before do
78
- @fact = Facter::Util::Fact.new("yay")
79
- end
80
-
81
- it "should return nil if there are no resolutions" do
82
- Facter::Util::Fact.new("yay").value.should be_nil
83
- end
84
-
85
- it "should return the first value returned by a resolution" do
86
- r1 = stub 'r1', :weight => 2, :value => nil, :suitable? => true
87
- r2 = stub 'r2', :weight => 1, :value => "yay", :suitable? => true
88
- r3 = stub 'r3', :weight => 0, :value => "foo", :suitable? => true
89
- Facter::Util::Resolution.expects(:new).times(3).returns(r1).returns(r2).returns(r3)
90
- @fact.add { }
91
- @fact.add { }
92
- @fact.add { }
93
-
94
- @fact.value.should == "yay"
95
- end
96
-
97
- it "should short-cut returning the value once one is found" do
98
- r1 = stub 'r1', :weight => 2, :value => "foo", :suitable? => true
99
- r2 = stub 'r2', :weight => 1, :suitable? => true # would fail if 'value' were asked for
100
- Facter::Util::Resolution.expects(:new).times(2).returns(r1).returns(r2)
101
- @fact.add { }
102
- @fact.add { }
103
-
104
- @fact.value
105
- end
106
-
107
- it "should skip unsuitable resolutions" do
108
- r1 = stub 'r1', :weight => 2, :suitable? => false # would fail if 'value' were asked for'
109
- r2 = stub 'r2', :weight => 1, :value => "yay", :suitable? => true
110
- Facter::Util::Resolution.expects(:new).times(2).returns(r1).returns(r2)
111
- @fact.add { }
112
- @fact.add { }
113
-
114
- @fact.value.should == "yay"
115
- end
116
-
117
- it "should return nil if the value is the empty string" do
118
- r1 = stub 'r1', :suitable? => true, :value => ""
119
- Facter::Util::Resolution.expects(:new).returns r1
120
- @fact.add { }
121
-
122
- @fact.value.should be_nil
123
- end
107
+ it "should skip unsuitable resolutions" do
108
+ r1 = stub 'r1', :weight => 2, :suitable? => false # would fail if 'value' were asked for'
109
+ r2 = stub 'r2', :weight => 1, :value => "yay", :suitable? => true
110
+ Facter::Util::Resolution.expects(:new).times(2).returns(r1).returns(r2)
111
+ @fact.add { }
112
+ @fact.add { }
113
+
114
+ @fact.value.should == "yay"
124
115
  end
125
116
 
126
- it "should have a method for flushing the cached fact" do
127
- Facter::Util::Fact.new(:foo).should respond_to(:flush)
117
+ it "should return nil if the value is the empty string" do
118
+ r1 = stub 'r1', :suitable? => true, :value => ""
119
+ Facter::Util::Resolution.expects(:new).returns r1
120
+ @fact.add { }
121
+
122
+ @fact.value.should be_nil
128
123
  end
124
+ end
125
+
126
+ it "should have a method for flushing the cached fact" do
127
+ Facter::Util::Fact.new(:foo).should respond_to(:flush)
128
+ end
129
129
  end
@@ -5,295 +5,295 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
5
5
  require 'facter/util/ip'
6
6
 
7
7
  describe Facter::Util::IP do
8
- before :each do
9
- Facter::Util::Config.stubs(:is_windows?).returns(false)
10
- end
11
-
12
- [:freebsd, :linux, :netbsd, :openbsd, :sunos, :darwin, :"hp-ux", :"gnu/kfreebsd", :windows].each do |platform|
13
- it "should be supported on #{platform}" do
14
- Facter::Util::Config.stubs(:is_windows?).returns(platform == :windows)
15
- Facter::Util::IP.supported_platforms.should be_include(platform)
16
- end
17
- end
18
-
19
- it "should return a list of interfaces" do
20
- Facter::Util::IP.should respond_to(:get_interfaces)
21
- end
8
+ before :each do
9
+ Facter::Util::Config.stubs(:is_windows?).returns(false)
10
+ end
11
+
12
+ [:freebsd, :linux, :netbsd, :openbsd, :sunos, :darwin, :"hp-ux", :"gnu/kfreebsd", :windows].each do |platform|
13
+ it "should be supported on #{platform}" do
14
+ Facter::Util::Config.stubs(:is_windows?).returns(platform == :windows)
15
+ Facter::Util::IP.supported_platforms.should be_include(platform)
16
+ end
17
+ end
18
+
19
+ it "should return a list of interfaces" do
20
+ Facter::Util::IP.should respond_to(:get_interfaces)
21
+ end
22
+
23
+ it "should return an empty list of interfaces on an unknown kernel" do
24
+ Facter.stubs(:value).returns("UnknownKernel")
25
+ Facter::Util::IP.get_interfaces().should == []
26
+ end
27
+
28
+ it "should return a list with a single interface and the loopback interface on Linux with a single interface" do
29
+ sample_output_file = File.dirname(__FILE__) + '/../data/linux_ifconfig_all_with_single_interface'
30
+ linux_ifconfig = File.read(sample_output_file)
31
+ Facter::Util::IP.stubs(:get_all_interface_output).returns(linux_ifconfig)
32
+ Facter::Util::IP.get_interfaces().should == ["eth0", "lo"]
33
+ end
34
+
35
+ it "should return a list two interfaces on Darwin with two interfaces" do
36
+ sample_output_file = File.dirname(__FILE__) + '/../data/darwin_ifconfig_all_with_multiple_interfaces'
37
+ darwin_ifconfig = File.read(sample_output_file)
38
+ Facter::Util::IP.stubs(:get_all_interface_output).returns(darwin_ifconfig)
39
+ Facter::Util::IP.get_interfaces().should == ["lo0", "en0"]
40
+ end
41
+
42
+ it "should return a list two interfaces on Solaris with two interfaces multiply reporting" do
43
+ sample_output_file = File.dirname(__FILE__) + '/../data/solaris_ifconfig_all_with_multiple_interfaces'
44
+ solaris_ifconfig = File.read(sample_output_file)
45
+ Facter::Util::IP.stubs(:get_all_interface_output).returns(solaris_ifconfig)
46
+ Facter::Util::IP.get_interfaces().should == ["lo0", "e1000g0"]
47
+ end
48
+
49
+ it "should return a list three interfaces on HP-UX with three interfaces multiply reporting" do
50
+ sample_output_file = File.dirname(__FILE__) + '/../data/hpux_netstat_all_interfaces'
51
+ hpux_netstat = File.read(sample_output_file)
52
+ Facter::Util::IP.stubs(:get_all_interface_output).returns(hpux_netstat)
53
+ Facter::Util::IP.get_interfaces().should == ["lan1", "lan0", "lo0"]
54
+ end
55
+
56
+ it "should return a list of six interfaces on a GNU/kFreeBSD with six interfaces" do
57
+ sample_output_file = File.dirname(__FILE__) + '/../data/debian_kfreebsd_ifconfig'
58
+ kfreebsd_ifconfig = File.read(sample_output_file)
59
+ Facter::Util::IP.stubs(:get_all_interface_output).returns(kfreebsd_ifconfig)
60
+ Facter::Util::IP.get_interfaces().should == ["em0", "em1", "bge0", "bge1", "lo0", "vlan0"]
61
+ end
62
+
63
+ it "should return a list of only connected interfaces on Windows" do
64
+ Facter.fact(:kernel).stubs(:value).returns("windows")
65
+ sample_output_file = File.dirname(__FILE__) + '/../data/windows_netsh_all_interfaces'
66
+ windows_netsh = File.read(sample_output_file)
67
+ Facter::Util::IP.stubs(:get_all_interface_output).returns(windows_netsh)
68
+ Facter::Util::IP.get_interfaces().should == ["Loopback Pseudo-Interface 1", "Local Area Connection", "Teredo Tunneling Pseudo-Interface"]
69
+ end
22
70
 
23
- it "should return an empty list of interfaces on an unknown kernel" do
24
- Facter.stubs(:value).returns("UnknownKernel")
25
- Facter::Util::IP.get_interfaces().should == []
26
- end
71
+ it "should return a value for a specific interface" do
72
+ Facter::Util::IP.should respond_to(:get_interface_value)
73
+ end
27
74
 
28
- it "should return a list with a single interface and the loopback interface on Linux with a single interface" do
29
- sample_output_file = File.dirname(__FILE__) + '/../data/linux_ifconfig_all_with_single_interface'
30
- linux_ifconfig = File.read(sample_output_file)
31
- Facter::Util::IP.stubs(:get_all_interface_output).returns(linux_ifconfig)
32
- Facter::Util::IP.get_interfaces().should == ["eth0", "lo"]
33
- end
75
+ it "should not return interface information for unsupported platforms" do
76
+ Facter.stubs(:value).with(:kernel).returns("bleah")
77
+ Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == []
78
+ end
34
79
 
35
- it "should return a list two interfaces on Darwin with two interfaces" do
36
- sample_output_file = File.dirname(__FILE__) + '/../data/darwin_ifconfig_all_with_multiple_interfaces'
37
- darwin_ifconfig = File.read(sample_output_file)
38
- Facter::Util::IP.stubs(:get_all_interface_output).returns(darwin_ifconfig)
39
- Facter::Util::IP.get_interfaces().should == ["lo0", "en0"]
40
- end
80
+ it "should return ipaddress information for Solaris" do
81
+ sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface"
82
+ solaris_ifconfig_interface = File.read(sample_output_file)
41
83
 
42
- it "should return a list two interfaces on Solaris with two interfaces multiply reporting" do
43
- sample_output_file = File.dirname(__FILE__) + '/../data/solaris_ifconfig_all_with_multiple_interfaces'
44
- solaris_ifconfig = File.read(sample_output_file)
45
- Facter::Util::IP.stubs(:get_all_interface_output).returns(solaris_ifconfig)
46
- Facter::Util::IP.get_interfaces().should == ["lo0", "e1000g0"]
47
- end
84
+ Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface)
85
+ Facter.stubs(:value).with(:kernel).returns("SunOS")
48
86
 
49
- it "should return a list three interfaces on HP-UX with three interfaces multiply reporting" do
50
- sample_output_file = File.dirname(__FILE__) + '/../data/hpux_netstat_all_interfaces'
51
- hpux_netstat = File.read(sample_output_file)
52
- Facter::Util::IP.stubs(:get_all_interface_output).returns(hpux_netstat)
53
- Facter::Util::IP.get_interfaces().should == ["lan1", "lan0", "lo0"]
54
- end
87
+ Facter::Util::IP.get_interface_value("e1000g0", "ipaddress").should == "172.16.15.138"
88
+ end
55
89
 
56
- it "should return a list of six interfaces on a GNU/kFreeBSD with six interfaces" do
57
- sample_output_file = File.dirname(__FILE__) + '/../data/debian_kfreebsd_ifconfig'
58
- kfreebsd_ifconfig = File.read(sample_output_file)
59
- Facter::Util::IP.stubs(:get_all_interface_output).returns(kfreebsd_ifconfig)
60
- Facter::Util::IP.get_interfaces().should == ["em0", "em1", "bge0", "bge1", "lo0", "vlan0"]
61
- end
90
+ it "should return netmask information for Solaris" do
91
+ sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface"
92
+ solaris_ifconfig_interface = File.read(sample_output_file)
62
93
 
63
- it "should return a list of only connected interfaces on Windows" do
64
- Facter.fact(:kernel).stubs(:value).returns("windows")
65
- sample_output_file = File.dirname(__FILE__) + '/../data/windows_netsh_all_interfaces'
66
- windows_netsh = File.read(sample_output_file)
67
- Facter::Util::IP.stubs(:get_all_interface_output).returns(windows_netsh)
68
- Facter::Util::IP.get_interfaces().should == ["Loopback Pseudo-Interface 1", "Local Area Connection", "Teredo Tunneling Pseudo-Interface"]
69
- end
94
+ Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface)
95
+ Facter.stubs(:value).with(:kernel).returns("SunOS")
70
96
 
71
- it "should return a value for a specific interface" do
72
- Facter::Util::IP.should respond_to(:get_interface_value)
73
- end
97
+ Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == "255.255.255.0"
98
+ end
74
99
 
75
- it "should not return interface information for unsupported platforms" do
76
- Facter.stubs(:value).with(:kernel).returns("bleah")
77
- Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == []
78
- end
100
+ it "should return calculated network information for Solaris" do
101
+ sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface"
102
+ solaris_ifconfig_interface = File.read(sample_output_file)
79
103
 
80
- it "should return ipaddress information for Solaris" do
81
- sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface"
82
- solaris_ifconfig_interface = File.read(sample_output_file)
104
+ Facter::Util::IP.stubs(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface)
105
+ Facter.stubs(:value).with(:kernel).returns("SunOS")
83
106
 
84
- Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface)
85
- Facter.stubs(:value).with(:kernel).returns("SunOS")
107
+ Facter::Util::IP.get_network_value("e1000g0").should == "172.16.15.0"
108
+ end
86
109
 
87
- Facter::Util::IP.get_interface_value("e1000g0", "ipaddress").should == "172.16.15.138"
88
- end
110
+ it "should return ipaddress information for HP-UX" do
111
+ sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface"
112
+ hpux_ifconfig_interface = File.read(sample_output_file)
89
113
 
90
- it "should return netmask information for Solaris" do
91
- sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface"
92
- solaris_ifconfig_interface = File.read(sample_output_file)
114
+ Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
115
+ Facter.stubs(:value).with(:kernel).returns("HP-UX")
93
116
 
94
- Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface)
95
- Facter.stubs(:value).with(:kernel).returns("SunOS")
117
+ Facter::Util::IP.get_interface_value("lan0", "ipaddress").should == "168.24.80.71"
118
+ end
96
119
 
97
- Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == "255.255.255.0"
98
- end
120
+ it "should return macaddress information for HP-UX" do
121
+ sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface"
122
+ hpux_ifconfig_interface = File.read(sample_output_file)
99
123
 
100
- it "should return calculated network information for Solaris" do
101
- sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface"
102
- solaris_ifconfig_interface = File.read(sample_output_file)
124
+ Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
125
+ Facter.stubs(:value).with(:kernel).returns("HP-UX")
103
126
 
104
- Facter::Util::IP.stubs(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface)
105
- Facter.stubs(:value).with(:kernel).returns("SunOS")
127
+ Facter::Util::IP.get_interface_value("lan0", "macaddress").should == "00:13:21:BD:9C:B7"
128
+ end
106
129
 
107
- Facter::Util::IP.get_network_value("e1000g0").should == "172.16.15.0"
108
- end
130
+ it "should return macaddress with leading zeros stripped off for GNU/kFreeBSD" do
131
+ sample_output_file = File.dirname(__FILE__) + "/../data/debian_kfreebsd_ifconfig"
132
+ kfreebsd_ifconfig = File.read(sample_output_file)
109
133
 
110
- it "should return ipaddress information for HP-UX" do
111
- sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface"
112
- hpux_ifconfig_interface = File.read(sample_output_file)
134
+ Facter::Util::IP.expects(:get_single_interface_output).with("em0").returns(kfreebsd_ifconfig)
135
+ Facter.stubs(:value).with(:kernel).returns("GNU/kFreeBSD")
113
136
 
114
- Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
115
- Facter.stubs(:value).with(:kernel).returns("HP-UX")
137
+ Facter::Util::IP.get_interface_value("em0", "macaddress").should == "0:11:a:59:67:90"
138
+ end
116
139
 
117
- Facter::Util::IP.get_interface_value("lan0", "ipaddress").should == "168.24.80.71"
118
- end
140
+ it "should return netmask information for HP-UX" do
141
+ sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface"
142
+ hpux_ifconfig_interface = File.read(sample_output_file)
119
143
 
120
- it "should return macaddress information for HP-UX" do
121
- sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface"
122
- hpux_ifconfig_interface = File.read(sample_output_file)
144
+ Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
145
+ Facter.stubs(:value).with(:kernel).returns("HP-UX")
123
146
 
124
- Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
125
- Facter.stubs(:value).with(:kernel).returns("HP-UX")
147
+ Facter::Util::IP.get_interface_value("lan0", "netmask").should == "255.255.255.0"
148
+ end
126
149
 
127
- Facter::Util::IP.get_interface_value("lan0", "macaddress").should == "00:13:21:BD:9C:B7"
128
- end
150
+ it "should return calculated network information for HP-UX" do
151
+ sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface"
152
+ hpux_ifconfig_interface = File.read(sample_output_file)
129
153
 
130
- it "should return macaddress with leading zeros stripped off for GNU/kFreeBSD" do
131
- sample_output_file = File.dirname(__FILE__) + "/../data/debian_kfreebsd_ifconfig"
132
- kfreebsd_ifconfig = File.read(sample_output_file)
154
+ Facter::Util::IP.stubs(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
155
+ Facter.stubs(:value).with(:kernel).returns("HP-UX")
133
156
 
134
- Facter::Util::IP.expects(:get_single_interface_output).with("em0").returns(kfreebsd_ifconfig)
135
- Facter.stubs(:value).with(:kernel).returns("GNU/kFreeBSD")
157
+ Facter::Util::IP.get_network_value("lan0").should == "168.24.80.0"
158
+ end
136
159
 
137
- Facter::Util::IP.get_interface_value("em0", "macaddress").should == "0:11:a:59:67:90"
138
- end
160
+ it "should return interface information for FreeBSD supported via an alias" do
161
+ sample_output_file = File.dirname(__FILE__) + "/../data/6.0-STABLE_FreeBSD_ifconfig"
162
+ ifconfig_interface = File.read(sample_output_file)
139
163
 
140
- it "should return netmask information for HP-UX" do
141
- sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface"
142
- hpux_ifconfig_interface = File.read(sample_output_file)
164
+ Facter::Util::IP.expects(:get_single_interface_output).with("fxp0").returns(ifconfig_interface)
165
+ Facter.stubs(:value).with(:kernel).returns("FreeBSD")
143
166
 
144
- Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
145
- Facter.stubs(:value).with(:kernel).returns("HP-UX")
167
+ Facter::Util::IP.get_interface_value("fxp0", "macaddress").should == "00:0e:0c:68:67:7c"
168
+ end
146
169
 
147
- Facter::Util::IP.get_interface_value("lan0", "netmask").should == "255.255.255.0"
148
- end
170
+ it "should return macaddress information for OS X" do
171
+ sample_output_file = File.dirname(__FILE__) + "/../data/Mac_OS_X_10.5.5_ifconfig"
172
+ ifconfig_interface = File.read(sample_output_file)
149
173
 
150
- it "should return calculated network information for HP-UX" do
151
- sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface"
152
- hpux_ifconfig_interface = File.read(sample_output_file)
174
+ Facter::Util::IP.expects(:get_single_interface_output).with("en1").returns(ifconfig_interface)
175
+ Facter.stubs(:value).with(:kernel).returns("Darwin")
153
176
 
154
- Facter::Util::IP.stubs(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
155
- Facter.stubs(:value).with(:kernel).returns("HP-UX")
177
+ Facter::Util::IP.get_interface_value("en1", "macaddress").should == "00:1b:63:ae:02:66"
178
+ end
156
179
 
157
- Facter::Util::IP.get_network_value("lan0").should == "168.24.80.0"
158
- end
180
+ it "should return all interfaces correctly on OS X" do
181
+ sample_output_file = File.dirname(__FILE__) + "/../data/Mac_OS_X_10.5.5_ifconfig"
182
+ ifconfig_interface = File.read(sample_output_file)
159
183
 
160
- it "should return interface information for FreeBSD supported via an alias" do
161
- sample_output_file = File.dirname(__FILE__) + "/../data/6.0-STABLE_FreeBSD_ifconfig"
162
- ifconfig_interface = File.read(sample_output_file)
184
+ Facter::Util::IP.expects(:get_all_interface_output).returns(ifconfig_interface)
185
+ Facter.stubs(:value).with(:kernel).returns("Darwin")
163
186
 
164
- Facter::Util::IP.expects(:get_single_interface_output).with("fxp0").returns(ifconfig_interface)
165
- Facter.stubs(:value).with(:kernel).returns("FreeBSD")
187
+ Facter::Util::IP.get_interfaces().should == ["lo0", "gif0", "stf0", "en0", "fw0", "en1", "vmnet8", "vmnet1"]
188
+ end
166
189
 
167
- Facter::Util::IP.get_interface_value("fxp0", "macaddress").should == "00:0e:0c:68:67:7c"
168
- end
190
+ it "should return a human readable netmask on Solaris" do
191
+ sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface"
192
+ solaris_ifconfig_interface = File.read(sample_output_file)
169
193
 
170
- it "should return macaddress information for OS X" do
171
- sample_output_file = File.dirname(__FILE__) + "/../data/Mac_OS_X_10.5.5_ifconfig"
172
- ifconfig_interface = File.read(sample_output_file)
194
+ Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface)
195
+ Facter.stubs(:value).with(:kernel).returns("SunOS")
173
196
 
174
- Facter::Util::IP.expects(:get_single_interface_output).with("en1").returns(ifconfig_interface)
175
- Facter.stubs(:value).with(:kernel).returns("Darwin")
197
+ Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == "255.255.255.0"
198
+ end
176
199
 
177
- Facter::Util::IP.get_interface_value("en1", "macaddress").should == "00:1b:63:ae:02:66"
178
- end
200
+ it "should return a human readable netmask on HP-UX" do
201
+ sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface"
202
+ hpux_ifconfig_interface = File.read(sample_output_file)
179
203
 
180
- it "should return all interfaces correctly on OS X" do
181
- sample_output_file = File.dirname(__FILE__) + "/../data/Mac_OS_X_10.5.5_ifconfig"
182
- ifconfig_interface = File.read(sample_output_file)
204
+ Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
205
+ Facter.stubs(:value).with(:kernel).returns("HP-UX")
183
206
 
184
- Facter::Util::IP.expects(:get_all_interface_output).returns(ifconfig_interface)
185
- Facter.stubs(:value).with(:kernel).returns("Darwin")
207
+ Facter::Util::IP.get_interface_value("lan0", "netmask").should == "255.255.255.0"
208
+ end
186
209
 
187
- Facter::Util::IP.get_interfaces().should == ["lo0", "gif0", "stf0", "en0", "fw0", "en1", "vmnet8", "vmnet1"]
188
- end
210
+ it "should return a human readable netmask on Darwin" do
211
+ sample_output_file = File.dirname(__FILE__) + "/../data/darwin_ifconfig_single_interface"
189
212
 
190
- it "should return a human readable netmask on Solaris" do
191
- sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface"
192
- solaris_ifconfig_interface = File.read(sample_output_file)
213
+ darwin_ifconfig_interface = File.read(sample_output_file)
193
214
 
194
- Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface)
195
- Facter.stubs(:value).with(:kernel).returns("SunOS")
215
+ Facter::Util::IP.expects(:get_single_interface_output).with("en1").returns(darwin_ifconfig_interface)
216
+ Facter.stubs(:value).with(:kernel).returns("Darwin")
196
217
 
197
- Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == "255.255.255.0"
198
- end
218
+ Facter::Util::IP.get_interface_value("en1", "netmask").should == "255.255.255.0"
219
+ end
199
220
 
200
- it "should return a human readable netmask on HP-UX" do
201
- sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface"
202
- hpux_ifconfig_interface = File.read(sample_output_file)
221
+ it "should return a human readable netmask on GNU/kFreeBSD" do
222
+ sample_output_file = File.dirname(__FILE__) + "/../data/debian_kfreebsd_ifconfig"
203
223
 
204
- Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
205
- Facter.stubs(:value).with(:kernel).returns("HP-UX")
224
+ kfreebsd_ifconfig = File.read(sample_output_file)
206
225
 
207
- Facter::Util::IP.get_interface_value("lan0", "netmask").should == "255.255.255.0"
208
- end
226
+ Facter::Util::IP.expects(:get_single_interface_output).with("em1").returns(kfreebsd_ifconfig)
227
+ Facter.stubs(:value).with(:kernel).returns("GNU/kFreeBSD")
209
228
 
210
- it "should return a human readable netmask on Darwin" do
211
- sample_output_file = File.dirname(__FILE__) + "/../data/darwin_ifconfig_single_interface"
229
+ Facter::Util::IP.get_interface_value("em1", "netmask").should == "255.255.255.0"
230
+ end
212
231
 
213
- darwin_ifconfig_interface = File.read(sample_output_file)
232
+ it "should not get bonding master on interface aliases" do
233
+ Facter.stubs(:value).with(:kernel).returns("Linux")
214
234
 
215
- Facter::Util::IP.expects(:get_single_interface_output).with("en1").returns(darwin_ifconfig_interface)
216
- Facter.stubs(:value).with(:kernel).returns("Darwin")
235
+ Facter::Util::IP.get_bonding_master("eth0:1").should be_nil
236
+ end
217
237
 
218
- Facter::Util::IP.get_interface_value("en1", "netmask").should == "255.255.255.0"
238
+ [:freebsd, :netbsd, :openbsd, :sunos, :darwin, :"hp-ux"].each do |platform|
239
+ it "should require conversion from hex on #{platform}" do
240
+ Facter::Util::IP.convert_from_hex?(platform).should == true
219
241
  end
242
+ end
220
243
 
221
- it "should return a human readable netmask on GNU/kFreeBSD" do
222
- sample_output_file = File.dirname(__FILE__) + "/../data/debian_kfreebsd_ifconfig"
223
-
224
- kfreebsd_ifconfig = File.read(sample_output_file)
225
-
226
- Facter::Util::IP.expects(:get_single_interface_output).with("em1").returns(kfreebsd_ifconfig)
227
- Facter.stubs(:value).with(:kernel).returns("GNU/kFreeBSD")
228
-
229
- Facter::Util::IP.get_interface_value("em1", "netmask").should == "255.255.255.0"
244
+ [:windows].each do |platform|
245
+ it "should not require conversion from hex on #{platform}" do
246
+ Facter::Util::IP.convert_from_hex?(platform).should be_false
230
247
  end
248
+ end
231
249
 
232
- it "should not get bonding master on interface aliases" do
233
- Facter.stubs(:value).with(:kernel).returns("Linux")
250
+ it "should return an arp address on Linux" do
251
+ Facter.stubs(:value).with(:kernel).returns("Linux")
234
252
 
235
- Facter::Util::IP.get_bonding_master("eth0:1").should be_nil
236
- end
253
+ Facter::Util::IP.expects(:get_arp_value).with("eth0").returns("00:00:0c:9f:f0:04")
254
+ Facter::Util::IP.get_arp_value("eth0").should == "00:00:0c:9f:f0:04"
255
+ end
237
256
 
238
- [:freebsd, :netbsd, :openbsd, :sunos, :darwin, :"hp-ux"].each do |platform|
239
- it "should require conversion from hex on #{platform}" do
240
- Facter::Util::IP.convert_from_hex?(platform).should == true
241
- end
257
+ describe "on Windows" do
258
+ before :each do
259
+ Facter.stubs(:value).with(:kernel).returns("windows")
242
260
  end
243
261
 
244
- [:windows].each do |platform|
245
- it "should not require conversion from hex on #{platform}" do
246
- Facter::Util::IP.convert_from_hex?(platform).should be_false
247
- end
248
- end
262
+ it "should return ipaddress information" do
263
+ sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface"
264
+ windows_netsh = File.read(sample_output_file)
249
265
 
250
- it "should return an arp address on Linux" do
251
- Facter.stubs(:value).with(:kernel).returns("Linux")
266
+ Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Local Area Connection", "ipaddress").returns(windows_netsh)
252
267
 
253
- Facter::Util::IP.expects(:get_arp_value).with("eth0").returns("00:00:0c:9f:f0:04")
254
- Facter::Util::IP.get_arp_value("eth0").should == "00:00:0c:9f:f0:04"
268
+ Facter::Util::IP.get_interface_value("Local Area Connection", "ipaddress").should == "172.16.138.216"
255
269
  end
256
270
 
257
- describe "on Windows" do
258
- before :each do
259
- Facter.stubs(:value).with(:kernel).returns("windows")
260
- end
261
-
262
- it "should return ipaddress information" do
263
- sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface"
264
- windows_netsh = File.read(sample_output_file)
271
+ it "should return a human readable netmask" do
272
+ sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface"
273
+ windows_netsh = File.read(sample_output_file)
265
274
 
266
- Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Local Area Connection", "ipaddress").returns(windows_netsh)
275
+ Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Local Area Connection", "netmask").returns(windows_netsh)
267
276
 
268
- Facter::Util::IP.get_interface_value("Local Area Connection", "ipaddress").should == "172.16.138.216"
269
- end
270
-
271
- it "should return a human readable netmask" do
272
- sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface"
273
- windows_netsh = File.read(sample_output_file)
274
-
275
- Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Local Area Connection", "netmask").returns(windows_netsh)
276
-
277
- Facter::Util::IP.get_interface_value("Local Area Connection", "netmask").should == "255.255.255.0"
278
- end
277
+ Facter::Util::IP.get_interface_value("Local Area Connection", "netmask").should == "255.255.255.0"
278
+ end
279
279
 
280
- it "should return network information" do
281
- sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface"
282
- windows_netsh = File.read(sample_output_file)
280
+ it "should return network information" do
281
+ sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface"
282
+ windows_netsh = File.read(sample_output_file)
283
283
 
284
- Facter::Util::IP.stubs(:get_output_for_interface_and_label).with("Local Area Connection", "ipaddress").returns(windows_netsh)
285
- Facter::Util::IP.stubs(:get_output_for_interface_and_label).with("Local Area Connection", "netmask").returns(windows_netsh)
284
+ Facter::Util::IP.stubs(:get_output_for_interface_and_label).with("Local Area Connection", "ipaddress").returns(windows_netsh)
285
+ Facter::Util::IP.stubs(:get_output_for_interface_and_label).with("Local Area Connection", "netmask").returns(windows_netsh)
286
286
 
287
- Facter::Util::IP.get_network_value("Local Area Connection").should == "172.16.138.0"
288
- end
287
+ Facter::Util::IP.get_network_value("Local Area Connection").should == "172.16.138.0"
288
+ end
289
289
 
290
- it "should return ipaddress6 information" do
291
- sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface6"
292
- windows_netsh = File.read(sample_output_file)
290
+ it "should return ipaddress6 information" do
291
+ sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface6"
292
+ windows_netsh = File.read(sample_output_file)
293
293
 
294
- Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Teredo Tunneling Pseudo-Interface", "ipaddress6").returns(windows_netsh)
294
+ Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Teredo Tunneling Pseudo-Interface", "ipaddress6").returns(windows_netsh)
295
295
 
296
- Facter::Util::IP.get_interface_value("Teredo Tunneling Pseudo-Interface", "ipaddress6").should == "2001:0:4137:9e76:2087:77a:53ef:7527"
297
- end
296
+ Facter::Util::IP.get_interface_value("Teredo Tunneling Pseudo-Interface", "ipaddress6").should == "2001:0:4137:9e76:2087:77a:53ef:7527"
298
297
  end
298
+ end
299
299
  end