diff options
Diffstat (limited to 'share/perl/test/OpenSimTest/InventoryTester.pm')
-rw-r--r-- | share/perl/test/OpenSimTest/InventoryTester.pm | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/share/perl/test/OpenSimTest/InventoryTester.pm b/share/perl/test/OpenSimTest/InventoryTester.pm new file mode 100644 index 0000000..76615b1 --- /dev/null +++ b/share/perl/test/OpenSimTest/InventoryTester.pm | |||
@@ -0,0 +1,116 @@ | |||
1 | package InventoryTester; | ||
2 | |||
3 | use strict; | ||
4 | use XML::Serializer; | ||
5 | use OpenSim::Utility; | ||
6 | |||
7 | sub init { | ||
8 | &OpenSimTest::Config::registerHandler("create_inventory", \&_create_inventory); | ||
9 | &OpenSimTest::Config::registerHandler("root_folders", \&_root_folders); | ||
10 | &OpenSimTest::Config::registerHandler("get_inventory", \&_get_inventory); | ||
11 | &OpenSimTest::Config::registerHandler("new_item", \&_new_item); | ||
12 | &OpenSimTest::Config::registerHandler("new_folder", \&_new_folder); | ||
13 | } | ||
14 | |||
15 | sub _apache_flag { | ||
16 | my $url = shift; | ||
17 | return $url =~ /inventory.cgi/ ? 1 : 0; | ||
18 | } | ||
19 | |||
20 | sub _new_folder { | ||
21 | my $url = shift || $OpenSimTest::Config::INVENTORY_SERVER_URL; | ||
22 | my $post_data =<<"POSTDATA"; | ||
23 | <InventoryFolderBase> | ||
24 | <name>New Folder</name> | ||
25 | <agentID> | ||
26 | <UUID>b9cb58e8-f3c9-4af5-be47-029762baa68f</UUID> | ||
27 | </agentID> | ||
28 | <parentID> | ||
29 | <UUID>500ea141-2967-49e2-9e18-fcdedffe68df</UUID> | ||
30 | </parentID> | ||
31 | <folderID> | ||
32 | <UUID>aa6f9220-c945-0b23-6141-43c9ef734100</UUID> | ||
33 | </folderID> | ||
34 | <type>-1</type> | ||
35 | <version>0</version> | ||
36 | </InventoryFolderBase> | ||
37 | POSTDATA | ||
38 | if (&_apache_flag($url)) { | ||
39 | $post_data = "POSTDATA=" . $post_data; # TODO: bad temporary solution | ||
40 | } | ||
41 | my $res = &OpenSim::Utility::HttpPostRequest($url . "/NewFolder/", $post_data) . "\n"; | ||
42 | } | ||
43 | |||
44 | sub _new_item { | ||
45 | my $url = shift || $OpenSimTest::Config::INVENTORY_SERVER_URL; | ||
46 | my $post_data =<<"POSTDATA"; | ||
47 | <InventoryItemBase> | ||
48 | <inventoryID> | ||
49 | <UUID>f975d038-3bd7-4e8b-a945-f46b0c962ee3</UUID> | ||
50 | </inventoryID> | ||
51 | <assetID> | ||
52 | <UUID>5f50f162-1cc6-4907-99be-a4c81d7f5e10</UUID> | ||
53 | </assetID> | ||
54 | <assetType>6</assetType> | ||
55 | <invType>6</invType> | ||
56 | <parentFolderID> | ||
57 | <UUID>7018dc23-43a9-493f-b3f7-869a6bbad0f3</UUID> | ||
58 | </parentFolderID> | ||
59 | <avatarID> | ||
60 | <UUID>b9cb58e8-f3c9-4af5-be47-029762baa68f</UUID> | ||
61 | </avatarID> | ||
62 | <creatorsID> | ||
63 | <UUID>b9cb58e8-f3c9-4af5-be47-029762baa68f</UUID> | ||
64 | </creatorsID> | ||
65 | <inventoryName>Primitive</inventoryName> | ||
66 | <inventoryDescription/> | ||
67 | <inventoryNextPermissions>2147483647</inventoryNextPermissions> | ||
68 | <inventoryCurrentPermissions>526053692</inventoryCurrentPermissions> | ||
69 | <inventoryBasePermissions>2147483647</inventoryBasePermissions> | ||
70 | <inventoryEveryOnePermissions>0</inventoryEveryOnePermissions> | ||
71 | </InventoryItemBase> | ||
72 | POSTDATA | ||
73 | if (&_apache_flag($url)) { | ||
74 | $post_data = "POSTDATA=" . $post_data; | ||
75 | } | ||
76 | my $res = &OpenSim::Utility::HttpPostRequest($url . "/NewItem/", $post_data) . "\n"; | ||
77 | } | ||
78 | |||
79 | sub _get_inventory { | ||
80 | my $url = shift || $OpenSimTest::Config::INVENTORY_SERVER_URL; | ||
81 | my $uuid = shift; | ||
82 | my $serializer = new XML::Serializer($uuid, "guid"); | ||
83 | my $post_data = $serializer->to_string(XML::Serializer::WITH_HEADER); | ||
84 | if (&_apache_flag($url)) { | ||
85 | $post_data = "POSTDATA=" . $post_data; | ||
86 | } | ||
87 | my $res = &OpenSim::Utility::HttpPostRequest($url . "/GetInventory/", $post_data) . "\n"; | ||
88 | return 1; | ||
89 | } | ||
90 | |||
91 | sub _create_inventory { | ||
92 | my $url = shift || $OpenSimTest::Config::INVENTORY_SERVER_URL; | ||
93 | my $uuid = shift; | ||
94 | my $serializer = new XML::Serializer($uuid, "guid"); | ||
95 | my $post_data = $serializer->to_string(XML::Serializer::WITH_HEADER); | ||
96 | if (&_apache_flag($url)) { | ||
97 | $post_data = "POSTDATA=" . $post_data; | ||
98 | } | ||
99 | my $res = &OpenSim::Utility::HttpPostRequest($url . "/CreateInventory/", $post_data) . "\n"; | ||
100 | return 1; | ||
101 | } | ||
102 | |||
103 | sub _root_folders { | ||
104 | my $url = shift || $OpenSimTest::Config::INVENTORY_SERVER_URL; | ||
105 | my $uuid = shift; | ||
106 | my $serializer = new XML::Serializer($uuid, "guid"); | ||
107 | my $post_data = $serializer->to_string(XML::Serializer::WITH_HEADER); | ||
108 | if (&_apache_flag($url)) { | ||
109 | $post_data = "POSTDATA=" . $post_data; | ||
110 | } | ||
111 | my $res = &OpenSim::Utility::HttpPostRequest($url . "/RootFolders/", $post_data) . "\n"; | ||
112 | return 1; | ||
113 | } | ||
114 | |||
115 | 1; | ||
116 | |||