summaryrefslogtreecommitdiff
path: root/spec/ohai/plugins/network_spec.rb
blob: 480e9a353fbad6bac01120d8e9547aad409ddc3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
#
#  Author:: Laurent Desarmes <laurent.desarmes@u-picardie.fr>
#  Copyright:: Copyright (c) 2012 Laurent Desarmes
#  License:: Apache License, Version 2.0
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')

def it_does_not_fail
  it "doesn't fail" do
    Ohai::Log.should_receive(:warn).any_number_of_times
    Ohai::Log.should_not_receive(:debug).with(/^Plugin network threw exception/)
    @ohai._require_plugin("network")
    %w[ ipaddress, macaddress, ip6address ].each do |attribute|
      @ohai.should have_key(attribute)
    end
  end
end

describe Ohai::System, "Network Plugin" do

  basic_network_data = {
    "linux" => {
      # pp Hash[node['network']] from  shef to get the network data
      # have just removed the neighbour and route entries by hand
      "interfaces"=>
      {"lo"=>
        {"flags"=>["LOOPBACK", "UP"],
          "addresses"=>
          {"::1"=>{"scope"=>"Node", "prefixlen"=>"128", "family"=>"inet6"},
            "127.0.0.1"=>
            {"scope"=>"Node",
              "netmask"=>"255.0.0.0",
              "prefixlen"=>"8",
              "family"=>"inet"}},
          "mtu"=>"16436",
          "encapsulation"=>"Loopback"},
        "eth0"=>
        {"flags"=>["BROADCAST", "MULTICAST", "UP"],
          "number"=>"0",
          "addresses"=>
          {
            "fe80::216:3eff:fe2f:3679"=> {"scope"=>"Link", "prefixlen"=>"64", "family"=>"inet6"},
            "00:16:3E:2F:36:79"=>{"family"=>"lladdr"},
            "192.168.66.33"=> {"scope"=>"Global",
              "netmask"=>"255.255.255.0",
              "broadcast"=>"192.168.66.255",
              "prefixlen"=>"24",
              "family"=>"inet"},
            "3ffe:1111:2222::33"=> {
              "prefixlen"=> "48",
              "family"=> "inet6",
              "scope"=> "Global"
            }},
          "mtu"=>"1500",
          "type"=>"eth",
          "encapsulation"=>"Ethernet"},
        "eth1"=>
        {"flags"=>["BROADCAST", "MULTICAST", "UP"],
          "number"=>"1",
          "addresses"=>
          {
            "fe80::216:3eff:fe2f:3680"=> {"scope"=>"Link", "prefixlen"=>"64", "family"=>"inet6"},
            "00:16:3E:2F:36:80"=>{"family"=>"lladdr"},
            "192.168.99.11"=> {"scope"=>"Global",
              "netmask"=>"255.255.255.0",
              "broadcast"=>"192.168.99.255",
              "prefixlen"=>"24",
              "family"=>"inet"},
            "3ffe:1111:3333::1"=> {
              "prefixlen"=> "48",
              "family"=> "inet6",
              "scope"=> "Global"
          }},
          "mtu"=>"1500",
          "type"=>"eth",
        "encapsulation"=>"Ethernet"}},
      "default_gateway"=>"192.168.66.15",
      "default_interface" => "eth0",
      "default_inet6_gateway" => "3ffe:1111:2222::",
      "default_inet6_interface" => "eth0"
    }
  }

  %w[ linux ].each do |os|
    describe "with #{os}" do
      before(:each) do
        @ohai = Ohai::System.new
        @ohai.stub!(:require_plugin).twice.and_return(true)
        @ohai["network"] = basic_network_data[os]
      end

      describe "when the #{os}::network plugin hasn't set any of {ip,ip6,mac}address attributes" do
        context "simple setup" do
          it_does_not_fail

          it "logs 2 debug messages" do
            Ohai::Log.should_receive(:debug).with(/^Loading plugin network/).once
            Ohai::Log.should_receive(:debug).with(/^\[inet\] Using default/).once
            Ohai::Log.should_receive(:debug).with(/^\[inet6\] Using default/).once
            @ohai._require_plugin("network")
          end

          it "detects {ip,ip6,mac}address" do
            @ohai._require_plugin("network")
            @ohai["ipaddress"].should == "192.168.66.33"
            @ohai["macaddress"].should == "00:16:3E:2F:36:79"
            @ohai["ip6address"].should == "3ffe:1111:2222::33"
          end
        end

        context "default ipv4 and ipv6 gateway on different interfaces" do
          before do
            @ohai["network"]["default_inet6_gateway"] = "3ffe:1111:3333::"
            @ohai["network"]["default_inet6_interface"] = "eth1"
          end

          it_does_not_fail

          it "detects {ip,ip6,mac}address" do
            @ohai._require_plugin("network")
            @ohai["ipaddress"].should == "192.168.66.33"
            @ohai["macaddress"].should == "00:16:3E:2F:36:79"
            @ohai["ip6address"].should == "3ffe:1111:3333::1"
          end

          it "informs about this setup" do
            Ohai::Log.should_receive(:info).with(/^ipaddress and ip6address are set from different interfaces/)
            @ohai._require_plugin("network")
          end
        end

        describe "conflicting results from the #{os}::network plugin" do
          context "default interface doesn't match the default_gateway" do
            before do
              @ohai["network"]["default_interface"] = "eth1"
              @ohai["network"]["default_inet6_interface"] = "eth1"
            end

            it_does_not_fail

            it "doesn't detect {ip,ip6,mac}address" do
              Ohai::Log.should_receive(:warn).any_number_of_times
              @ohai._require_plugin("network")
              @ohai["ipaddress"].should be_nil
              @ohai["macaddress"].should be_nil
              @ohai["ip6address"].should be_nil
            end

            it "warns about this conflict" do
              Ohai::Log.should_receive(:warn).with(/^\[inet\] no ipaddress\/mask on eth1/).once
              Ohai::Log.should_receive(:warn).with(/^unable to detect ipaddress/).once
              Ohai::Log.should_receive(:warn).with(/^unable to detect macaddress/).once
              Ohai::Log.should_receive(:warn).with(/^\[inet6\] no ipaddress\/mask on eth1/).once
              Ohai::Log.should_receive(:warn).with(/^unable to detect ip6address/).once
              @ohai._require_plugin("network")
            end
          end

          context "no ip address for the given default interface/gateway" do
            before do
              @ohai["network"]["interfaces"]["eth0"]["addresses"].delete_if{|k,v| %w[inet inet6].include? v["family"]}
            end

            it_does_not_fail

            it "doesn't detect {ip,ip6,mac}address" do
              Ohai::Log.should_receive(:warn).any_number_of_times
              @ohai._require_plugin("network")
              @ohai["ipaddress"].should be_nil
              @ohai["macaddress"].should be_nil
              @ohai["ip6address"].should be_nil
            end

            it "warns about this conflict" do
              Ohai::Log.should_receive(:warn).with(/^unable to detect ipaddress/).once
              Ohai::Log.should_receive(:warn).with(/^unable to detect macaddress/).once
              Ohai::Log.should_receive(:warn).with(/^\[inet\] no ip on eth0/).once
              Ohai::Log.should_receive(:warn).with(/^unable to detect ip6address/).once
              Ohai::Log.should_receive(:warn).with(/^\[inet6\] no ip on eth0/).once
              @ohai._require_plugin("network")
            end
          end

          context "no ip at all" do
            before do
              @ohai["network"]["default_gateway"] = nil
              @ohai["network"]["default_interface"] = nil
              @ohai["network"]["default_inet6_gateway"] = nil
              @ohai["network"]["default_inet6_interface"] = nil
              @ohai["network"]["interfaces"].each do |i,iv|
                iv["addresses"].delete_if{|k,kv| %w[inet inet6].include? kv["family"]}
              end
            end

            it_does_not_fail

            it "doesn't detect {ip,ip6,mac}address" do
              Ohai::Log.should_receive(:warn).any_number_of_times
              @ohai._require_plugin("network")
              @ohai["ipaddress"].should be_nil
              @ohai["macaddress"].should be_nil
              @ohai["ip6address"].should be_nil
            end

            it "should warn about it" do
              Ohai::Log.should_receive(:warn).with(/^unable to detect ipaddress/).once
              Ohai::Log.should_receive(:warn).with(/^unable to detect macaddress/).once
              Ohai::Log.should_receive(:warn).with(/^unable to detect ip6address/).once
              @ohai._require_plugin("network")
            end
          end
        end

        context "several ipaddresses matching the default route" do
          context "bigger prefix not set on the default interface" do
            before do
              @ohai["network"]["interfaces"]["eth2"] = {
                "flags" =>["BROADCAST", "MULTICAST", "UP"],
                "number" =>"2",
                "addresses" => {
                  "fe80::216:3eff:fe2f:3681" => { "scope"=>"Link", "prefixlen"=>"64", "family"=>"inet6"},
                  "00:16:3E:2F:36:81" =>{"family"=>"lladdr"},
                  "192.168.66.99" => {
                    "scope"=>"Global",
                    "netmask"=>"255.255.255.128",
                    "broadcast"=>"192.168.99.127",
                    "prefixlen"=>"25",
                    "family"=>"inet"},
                  "3ffe:1111:2222:0:4444::1"=> {
                    "prefixlen"=> "64",
                    "family"=> "inet6",
                    "scope"=> "Global"
                  }
                }
              }
            end

            it_does_not_fail

            it "sets {ip,ip6,mac}address correctly" do
              @ohai._require_plugin("network")
              @ohai["ipaddress"].should == "192.168.66.33"
              @ohai["macaddress"].should == "00:16:3E:2F:36:79"
              @ohai["ip6address"].should == "3ffe:1111:2222::33"
            end
          end

          context "bigger prefix set on the default interface" do
            before do
              @ohai["network"]["interfaces"]["eth0"]["addresses"]["192.168.66.99"] = {
                "scope"=>"Global",
                "netmask"=>"255.255.255.128",
                "broadcast"=>"192.168.66.127",
                "prefixlen"=>"25",
                "family"=>"inet"}
              @ohai["network"]["interfaces"]["eth0"]["addresses"]["3ffe:1111:2222:0:4444::1"] = {
                "prefixlen"=> "64",
                "family"=> "inet6",
                "scope"=> "Global"}
            end

            it_does_not_fail

            it "sets {ip,ip6,mac}address correctly" do
              @ohai._require_plugin("network")
              @ohai["ipaddress"].should == "192.168.66.99"
              @ohai["macaddress"].should == "00:16:3E:2F:36:79"
              @ohai["ip6address"].should == "3ffe:1111:2222:0:4444::1"
            end
          end

          context "smallest ip not set on the default_interface" do
            before do
              @ohai["network"]["interfaces"]["eth2"] = {
                "flags" =>["BROADCAST", "MULTICAST", "UP"],
                "number" =>"2",
                "addresses" => {
                  "fe80::216:3eff:fe2f:3681" => { "scope"=>"Link", "prefixlen"=>"64", "family"=>"inet6"},
                  "00:16:3E:2F:36:81" =>{"family"=>"lladdr"},
                  "192.168.66.32" => {
                    "scope"=>"Global",
                    "netmask"=>"255.255.255.0",
                    "broadcast"=>"192.168.66.255",
                    "prefixlen"=>"24",
                    "family"=>"inet"},
                  "3ffe:1111:2222::32"=> {
                    "prefixlen"=> "48",
                    "family"=> "inet6",
                    "scope"=> "Global"
                  }
                }
              }
            end

            it_does_not_fail

            it "sets {ip,ip6,mac}address correctly" do
              @ohai._require_plugin("network")
              @ohai["ipaddress"].should == "192.168.66.33"
              @ohai["macaddress"].should == "00:16:3E:2F:36:79"
              @ohai["ip6address"].should == "3ffe:1111:2222::33"
            end
          end

          context "smallest ip set on the default_interface" do
            before do
              @ohai["network"]["interfaces"]["eth0"]["addresses"]["192.168.66.32"] = {
                "scope"=>"Global",
                "netmask"=>"255.255.255.0",
                "broadcast"=>"192.168.66.255",
                "prefixlen"=>"24",
                "family"=>"inet"}
              @ohai["network"]["interfaces"]["eth0"]["addresses"]["3ffe:1111:2222::32"] = {
                "prefixlen"=> "48",
                "family"=> "inet6",
                "scope"=> "Global"}
            end

            it_does_not_fail

            it "sets {ip,ip6,mac}address correctly" do
              @ohai._require_plugin("network")
              @ohai["ipaddress"].should == "192.168.66.32"
              @ohai["macaddress"].should == "00:16:3E:2F:36:79"
              @ohai["ip6address"].should == "3ffe:1111:2222::32"
            end
          end
        end

	context "no default route" do
          before do
            @ohai["network"]["default_gateway"] = nil
            @ohai["network"]["default_interface"] = nil
            @ohai["network"]["default_inet6_gateway"] = nil
            @ohai["network"]["default_inet6_interface"] = nil
            # removing inet* addresses from eth0, to complicate things a bit
            @ohai["network"]["interfaces"]["eth0"]["addresses"].delete_if{|k,v| %w[inet inet6].include? v["family"]}
          end

          it_does_not_fail

          it "picks {ip,mac,ip6}address from the first interface" do
            Ohai::Log.should_receive(:warn).with(/^\[inet\] no default interface/).once
            Ohai::Log.should_receive(:warn).with(/^\[inet6\] no default interface/).once
            @ohai._require_plugin("network")
            @ohai["ipaddress"].should == "192.168.99.11"
            @ohai["macaddress"].should == "00:16:3E:2F:36:80"
            @ohai["ip6address"].should == "3ffe:1111:3333::1"
          end
	end

	context "no default route, there are global and link level addresses" do
          before do
            @ohai["network"]["default_gateway"] = nil
            @ohai["network"]["default_interface"] = nil
            @ohai["network"]["default_inet6_gateway"] = nil
            @ohai["network"]["default_inet6_interface"] = nil
            # just changing scopes to lInK for eth0 addresses
            @ohai["network"]["interfaces"]["eth0"]["addresses"].each{|k,v| v[:scope]="lInK" if %w[inet inet6].include? v["family"]}
          end

          it_does_not_fail

          it "prefers {ip,mac,ip6}address with global scope" do
            Ohai::Log.should_receive(:warn).with(/^\[inet\] no default interface/).once
            Ohai::Log.should_receive(:warn).with(/^\[inet6\] no default interface/).once
            @ohai._require_plugin("network")
            @ohai["ipaddress"].should == "192.168.99.11"
            @ohai["macaddress"].should == "00:16:3E:2F:36:80"
            @ohai["ip6address"].should == "3ffe:1111:3333::1"
          end
        end

	context "link level default route" do
          before do
            @ohai["network"]["default_gateway"] = "0.0.0.0"
            @ohai["network"]["default_interface"] = "eth1"
            @ohai["network"]["default_inet6_gateway"] = "::"
            @ohai["network"]["default_inet6_interface"] = "eth1"
          end

          it_does_not_fail

          it "displays debug messages" do
            Ohai::Log.should_receive(:debug).with(/^Loading plugin network/).once
            Ohai::Log.should_receive(:debug).with(/^link level default inet /).once
            Ohai::Log.should_receive(:debug).with(/^link level default inet6 /).once
            @ohai._require_plugin("network")
          end

          it "picks {ip,mac,ip6}address from the default interface" do
            @ohai._require_plugin("network")
            @ohai["ipaddress"].should == "192.168.99.11"
            @ohai["macaddress"].should == "00:16:3E:2F:36:80"
            @ohai["ip6address"].should == "3ffe:1111:3333::1"
          end
        end

        context "point to point address" do
          before do
            @ohai["network"]["interfaces"]["eth2"] = {
              "flags" =>["POINTOPOINT", "BROADCAST", "MULTICAST", "UP"],
              "number" =>"2",
              "addresses" => {
                "fe80::216:3eff:fe2f:3681" => { "scope"=>"Link", "prefixlen"=>"64", "family"=>"inet6"},
                "00:16:3E:2F:36:81" =>{"family"=>"lladdr"},
                "192.168.66.99" => {
                  "scope"=>"Global",
                  "netmask"=>"255.255.255.255",
                  "peer"=>"192.168.99.126",
                  "prefixlen"=>"32",
                  "family"=>"inet"},
                "3ffe:1111:2222:0:4444::1"=> {
                  "prefixlen"=> "128",
                  "peer" => "3ffe:1111:2222:0:4444::2",
                  "family"=> "inet6",
                  "scope"=> "Global"
                }
              }
            }
            @ohai["network"]["default_gateway"] = "192.168.99.126"
            @ohai["network"]["default_interface"] = "eth2"
            @ohai["network"]["default_inet6_gateway"] = "3ffe:1111:2222:0:4444::2"
            @ohai["network"]["default_inet6_interface"] = "eth2"
          end

          it_does_not_fail

          it "picks {ip,mac,ip6}address from the default interface" do
            @ohai._require_plugin("network")
            @ohai["ipaddress"].should == "192.168.66.99"
            @ohai["macaddress"].should == "00:16:3E:2F:36:81"
            @ohai["ip6address"].should == "3ffe:1111:2222:0:4444::1"
          end
        end

        context "ipv6 only node" do
          before do
            @ohai["network"]["default_gateway"] = nil
            @ohai["network"]["default_interface"] = nil
            @ohai["network"]["interfaces"].each do |i,iv|
              iv["addresses"].delete_if{|k,kv| kv["family"] == "inet" }
            end
          end

          it "can't detect {ip,mac}address" do
            Ohai::Log.should_receive(:warn).any_number_of_times
            @ohai._require_plugin("network")
            @ohai["ipaddress"].should be_nil
            @ohai["macaddress"].should be_nil
          end

          # ATM IT WON'T SET MACADDRESS
          it "warns about not being able to set ipv4 related attributes" do
            Ohai::Log.should_receive(:warn).with(/^unable to detect ipaddress/).once
            Ohai::Log.should_receive(:warn).with(/^unable to detect macaddress/).once
            @ohai._require_plugin("network")
          end

          it "sets ip6address" do
            Ohai::Log.should_receive(:warn).any_number_of_times
            @ohai._require_plugin("network")
            @ohai["ip6address"].should == "3ffe:1111:2222::33"
          end
        end

      end

      describe "the #{os}::network has already set some of the {ip,mac,ip6}address attributes" do
        describe "{ip,mac}address are already set" do
          before do
            @ohai["ipaddress"] = "10.11.12.13"
            @ohai["macaddress"] = "00:AA:BB:CC:DD:EE"
          end

          it_does_not_fail

          it "detects ip6address" do
            @ohai._require_plugin("network")
            @ohai["ip6address"].should == "3ffe:1111:2222::33"
          end

          it "doesn't overwrite {ip,mac}address" do
            @ohai._require_plugin("network")
            @ohai["ipaddress"].should == "10.11.12.13"
            @ohai["macaddress"].should == "00:AA:BB:CC:DD:EE"
          end
        end

        describe "ip6address is already set" do
          context "node has ipv4 and ipv6" do
            before do
              @ohai["ip6address"] = "3ffe:8888:9999::1"
            end

            it_does_not_fail

            it "detects {ip,mac}address" do
              @ohai._require_plugin("network")
              @ohai["ipaddress"].should == "192.168.66.33"
              @ohai["macaddress"].should == "00:16:3E:2F:36:79"
            end

            it "doesn't overwrite ip6address" do
              @ohai._require_plugin("network")
              @ohai["ip6address"].should == "3ffe:8888:9999::1"
            end
          end

          context "ipv6 only node" do
            before do
              @ohai["network"]["default_gateway"] = nil
              @ohai["network"]["default_interface"] = nil
              @ohai["network"]["interfaces"].each do |i,iv|
                iv["addresses"].delete_if{|k,kv| kv["family"] == "inet" }
              end
              @ohai["ip6address"] = "3ffe:8888:9999::1"
            end

            it_does_not_fail

            it "can't detect {ip,mac}address" do
              Ohai::Log.should_receive(:warn).any_number_of_times
              @ohai._require_plugin("network")
              @ohai["ipaddress"].should be_nil
              @ohai["macaddress"].should be_nil
            end

            # ATM IT WON'T SET MACADDRESS
            it "warns about not being able to set ipv4 related attributes" do
              Ohai::Log.should_receive(:warn).with(/^unable to detect ipaddress/).once
              Ohai::Log.should_receive(:warn).with(/^unable to detect macaddress/).once
              @ohai._require_plugin("network")
            end

            it "doesn't overwrite ip6address" do
              Ohai::Log.should_receive(:warn).any_number_of_times
              @ohai._require_plugin("network")
              @ohai["ip6address"].should == "3ffe:8888:9999::1"
            end
          end
        end

        describe "{mac,ip6}address are already set" do
          before do
            @ohai["macaddress"] = "00:AA:BB:CC:DD:EE"
            @ohai["ip6address"] = "3ffe:8888:9999::1"
          end

          it_does_not_fail

          it "detects {ip,mac}address" do
            @ohai._require_plugin("network")
            @ohai["ipaddress"].should == "192.168.66.33"
            @ohai["macaddress"].should == "00:16:3E:2F:36:79"
          end

          it "doesn't overwrite ip6address" do
            @ohai._require_plugin("network")
            @ohai["ip6address"].should == "3ffe:8888:9999::1"
          end
        end

        describe "{ip,mac,ip6}address are already set" do
          before do
            @ohai["ipaddress"] = "10.11.12.13"
            @ohai["macaddress"] = "00:AA:BB:CC:DD:EE"
            @ohai["ip6address"] = "3ffe:8888:9999::1"
          end

          it_does_not_fail

          it "doesn't overwrite {ip,mac,ip6}address" do
            @ohai._require_plugin("network")
            @ohai["ipaddress"].should == "10.11.12.13"
            @ohai["macaddress"].should == "00:AA:BB:CC:DD:EE"
            @ohai["ip6address"].should == "3ffe:8888:9999::1"
          end
        end

        describe "{ip,ip6}address are already set" do
          before do
            @ohai["ipaddress"] = "10.11.12.13"
            @ohai["ip6address"] = "3ffe:8888:9999::1"
          end

          it_does_not_fail

          it "doesn't overwrite {ip,mac,ip6}address" do
            @ohai._require_plugin("network")
            @ohai["ipaddress"].should == "10.11.12.13"
            @ohai["macaddress"].should == nil
            @ohai["ip6address"].should == "3ffe:8888:9999::1"
          end
        end

      end
    end

  end
end