-
Notifications
You must be signed in to change notification settings - Fork 125
/
inventory.t
executable file
·88 lines (75 loc) · 2.1 KB
/
inventory.t
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
#!/usr/bin/perl
use strict;
use warnings;
use Config;
use Test::More;
use Test::Exception;
use XML::TreePP;
use FusionInventory::Agent::XML::Query::Inventory;
use FusionInventory::Agent::Task::Inventory::Inventory;
plan tests => 6;
my $query;
throws_ok {
$query = FusionInventory::Agent::XML::Query::Inventory->new();
} qr/^no content/, 'no content';
my $inventory = FusionInventory::Agent::Task::Inventory::Inventory->new();
throws_ok {
$query = FusionInventory::Agent::XML::Query::Inventory->new(
content => $inventory->getContent()
);
} qr/^no deviceid/, 'no device id';
lives_ok {
$query = FusionInventory::Agent::XML::Query::Inventory->new(
deviceid => 'foo',
content => $inventory->getContent()
);
} 'everything OK';
isa_ok($query, 'FusionInventory::Agent::XML::Query::Inventory');
my $tpp = XML::TreePP->new();
is_deeply(
scalar $tpp->parse($query->getContent()),
{
REQUEST => {
DEVICEID => 'foo',
QUERY => 'INVENTORY',
CONTENT => {
HARDWARE => {
ARCHNAME => $Config{archname},
VMSYSTEM => 'Physical'
},
VERSIONCLIENT => $FusionInventory::Agent::AGENT_STRING,
},
}
},
'empty inventory, expected content'
);
$inventory->addEntry(
section => 'SOFTWARES',
entry => {
NAME => '<&>',
}
);
$query = FusionInventory::Agent::XML::Query::Inventory->new(
deviceid => 'foo',
content => $inventory->getContent()
);
is_deeply(
scalar $tpp->parse($query->getContent()),
{
REQUEST => {
DEVICEID => 'foo',
QUERY => 'INVENTORY',
CONTENT => {
HARDWARE => {
ARCHNAME => $Config{archname},
VMSYSTEM => 'Physical'
},
VERSIONCLIENT => $FusionInventory::Agent::AGENT_STRING,
SOFTWARES => {
NAME => '<&>'
}
},
}
},
'additional content with prohibited characters, expected content'
);