File: netinventory.t

package info (click to toggle)
fusioninventory-agent 1%3A2.6-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 27,492 kB
  • sloc: perl: 120,896; xml: 9,459; sh: 760; python: 26; makefile: 13
file content (99 lines) | stat: -rwxr-xr-x 2,227 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;
use FusionInventory::Agent::XML::Query;

# each item is an arrayref of three elements:
# - input data structure
# - expected xml output
# - test explication
my @tests = (
    [
        {
            PORTS => {
                PORT => [
                    {
                        CONNECTIONS => {
                            CONNECTION => {
                                MAC => [
                                    '00:00:74:D2:09:6A',
                                ]
                            }
                        }
                    },
                ]
            }
        },
        <<EOF,
<?xml version="1.0" encoding="UTF-8" ?>
<REQUEST>
  <CONTENT>
    <PORTS>
      <PORT>
        <CONNECTIONS>
          <CONNECTION>
            <MAC>00:00:74:D2:09:6A</MAC>
          </CONNECTION>
        </CONNECTIONS>
      </PORT>
    </PORTS>
  </CONTENT>
  <DEVICEID>foobar</DEVICEID>
  <QUERY>SNMPQUERY</QUERY>
</REQUEST>
EOF
        'single mac address'
    ],
    [
        {
            PORTS => {
                PORT => [
                    {
                        CONNECTIONS => {
                            CONNECTION => {
                                MAC => [
                                    '00:00:74:D2:09:6A',
                                    '00:00:74:D2:09:6B'
                                ]
                            }
                        }
                    },
                ]
            }
        },
        <<EOF,
<?xml version="1.0" encoding="UTF-8" ?>
<REQUEST>
  <CONTENT>
    <PORTS>
      <PORT>
        <CONNECTIONS>
          <CONNECTION>
            <MAC>00:00:74:D2:09:6A</MAC>
            <MAC>00:00:74:D2:09:6B</MAC>
          </CONNECTION>
        </CONNECTIONS>
      </PORT>
    </PORTS>
  </CONTENT>
  <DEVICEID>foobar</DEVICEID>
  <QUERY>SNMPQUERY</QUERY>
</REQUEST>
EOF
        'multiple mac addresses'
    ],
);

plan tests => scalar @tests;

foreach my $test (@tests) {
    my $message = FusionInventory::Agent::XML::Query->new(
       deviceid => 'foobar',
       query    => 'SNMPQUERY',
       content  => $test->[0]
    );
    is($message->getContent(), $test->[1], $test->[2]);
}