aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/share/perl/test/OpenSimTest
diff options
context:
space:
mode:
Diffstat (limited to 'share/perl/test/OpenSimTest')
-rw-r--r--share/perl/test/OpenSimTest/AssetTester.pm17
-rw-r--r--share/perl/test/OpenSimTest/Config.pm53
-rw-r--r--share/perl/test/OpenSimTest/GridTester.pm62
-rw-r--r--share/perl/test/OpenSimTest/InventoryTester.pm116
-rw-r--r--share/perl/test/OpenSimTest/UserTester.pm53
5 files changed, 301 insertions, 0 deletions
diff --git a/share/perl/test/OpenSimTest/AssetTester.pm b/share/perl/test/OpenSimTest/AssetTester.pm
new file mode 100644
index 0000000..ba05205
--- /dev/null
+++ b/share/perl/test/OpenSimTest/AssetTester.pm
@@ -0,0 +1,17 @@
1package AssetTester;
2
3use strict;
4use XML::Serializer;
5use OpenSim::Utility;
6
7sub init {
8 &OpenSimTest::Config::registerHandler("get_asset", \&_get_asset);
9}
10
11sub _get_asset {
12 my $url = shift || $OpenSimTest::Config::ASSET_SERVER_URL;
13 my $asset_id = shift;
14 my $res = &OpenSim::Utility::HttpGetRequest($url . "/assets/" . $asset_id) . "\n";
15}
16
171;
diff --git a/share/perl/test/OpenSimTest/Config.pm b/share/perl/test/OpenSimTest/Config.pm
new file mode 100644
index 0000000..14ab3ed
--- /dev/null
+++ b/share/perl/test/OpenSimTest/Config.pm
@@ -0,0 +1,53 @@
1package OpenSimTest::Config;
2
3use strict;
4
5my $apache_server_host = "localhost";
6my $opensim_server_host = "localhost";
7
8# REGION
9our $SIM_RECV_KEY = "";
10our $SIM_SEND_KEY = "";
11# ASSET
12#our $ASSET_SERVER_URL = "http://127.0.0.1:8003/";
13our $ASSET_SERVER_URL = "http://$apache_server_host/opensim/asset.cgi";
14our $ASSET_RECV_KEY = "";
15our $ASSET_SEND_KEY = "";
16# USER
17#our $USER_SERVER_URL = "http://127.0.0.1:8001/";
18our $USER_SERVER_URL = "http://$apache_server_host/opensim/user.cgi";
19our $USER_RECV_KEY = "";
20our $USER_SEND_KEY = "";
21# GRID
22#our $GRID_SERVER_URL = "http://127.0.0.1:8001/";
23our $GRID_SERVER_URL = "http://$apache_server_host/opensim/grid.cgi";
24our $GRID_RECV_KEY = "";
25our $GRID_SEND_KEY = "";
26# INVENTORY
27#our $INVENTORY_SERVER_URL = "http://127.0.0.1:8004";
28our $INVENTORY_SERVER_URL = "http://$apache_server_host/opensim/inventory.cgi";
29# handler list
30our %HANDLER_LIST = ();
31
32our %APACHE_SERVERS = (
33 user => "http://$apache_server_host/opensim/user.cgi",
34 grid => "http://$apache_server_host/opensim/grid.cgi",
35 asset => "http://$apache_server_host/opensim/asset.cgi",
36 inventory => "http://$apache_server_host/opensim/inventory.cgi",
37);
38
39our %OPENSIM_SERVERS = (
40 user => "http://$opensim_server_host:8002",
41 grid => "http://$opensim_server_host:8001",
42 asset => "http://$opensim_server_host:8003",
43 inventory => "http://$opensim_server_host:8004",
44);
45
46sub registerHandler {
47 my ($name, $func) = @_;
48 $HANDLER_LIST{$name} = $func;
49}
50
51
521;
53
diff --git a/share/perl/test/OpenSimTest/GridTester.pm b/share/perl/test/OpenSimTest/GridTester.pm
new file mode 100644
index 0000000..61fef6b
--- /dev/null
+++ b/share/perl/test/OpenSimTest/GridTester.pm
@@ -0,0 +1,62 @@
1package GridTester;
2
3use strict;
4use OpenSim::Utility;
5
6sub init {
7 &OpenSimTest::Config::registerHandler("simulator_login", \&_simulator_login);
8 &OpenSimTest::Config::registerHandler("simulator_data_request", \&_simulator_data_request);
9 &OpenSimTest::Config::registerHandler("simulator_after_region_moved", \&_simulator_after_region_moved);
10 &OpenSimTest::Config::registerHandler("map_block", \&_map_block);
11}
12
13sub _simulator_login {
14 my $url = shift || $OpenSimTest::Config::GRID_SERVER_URL;
15 my @param = @_;
16 my %xml_rpc_param = (
17 "authkey" => "null",
18 "UUID" => $param[0],
19 "sim_ip" => $param[1],
20 "sim_port" => $param[2],
21 "region_locx" => 1000,
22 "region_locy" => 1000,
23 "sim_name" => "OpenTest",
24 "http_port" => 9000,
25 "remoting_port" => 8895,
26 "map-image-id" => "0e5a5e87-08d9-4b37-9b8e-a4c3c4e409ab",
27 );
28 return &OpenSim::Utility::XMLRPCCall($url, "simulator_login", \%xml_rpc_param);
29}
30
31sub _map_block {
32 my $url = shift || $OpenSimTest::Config::GRID_SERVER_URL;
33 my @param = @_;
34 my %xml_rpc_param = (
35 xmin => $param[0],
36 ymin => $param[1],
37 xmax => $param[2],
38 ymax => $param[3],
39 );
40 return &OpenSim::Utility::XMLRPCCall($url, "map_block", \%xml_rpc_param);
41}
42
43sub _simulator_data_request {
44 my $url = shift || $OpenSimTest::Config::GRID_SERVER_URL;
45 my @param = @_;
46 my %xml_rpc_param = (
47 region_handle => $param[0],
48 authkey => undef,
49 );
50 return &OpenSim::Utility::XMLRPCCall($url, "simulator_data_request", \%xml_rpc_param);
51}
52
53sub _simulator_after_region_moved {
54 my $url = shift || $OpenSimTest::Config::GRID_SERVER_URL;
55 my @param = @_;
56 my %xml_rpc_param = (
57 UUID => $param[0],
58 );
59 return &OpenSim::Utility::XMLRPCCall($url, "simulator_after_region_moved", \%xml_rpc_param);
60}
61
621;
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 @@
1package InventoryTester;
2
3use strict;
4use XML::Serializer;
5use OpenSim::Utility;
6
7sub 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
15sub _apache_flag {
16 my $url = shift;
17 return $url =~ /inventory.cgi/ ? 1 : 0;
18}
19
20sub _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>
37POSTDATA
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
44sub _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>
72POSTDATA
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
79sub _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
91sub _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
103sub _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
1151;
116
diff --git a/share/perl/test/OpenSimTest/UserTester.pm b/share/perl/test/OpenSimTest/UserTester.pm
new file mode 100644
index 0000000..194102a
--- /dev/null
+++ b/share/perl/test/OpenSimTest/UserTester.pm
@@ -0,0 +1,53 @@
1package UserTester;
2
3use strict;
4use Digest::MD5;
5use OpenSim::Utility;
6
7my $user_server_url;
8
9sub init {
10 &OpenSimTest::Config::registerHandler("login_to_simulator", \&_login_to_simulator);
11 &OpenSimTest::Config::registerHandler("get_user_by_name", \&_get_user_by_name);
12 &OpenSimTest::Config::registerHandler("get_user_by_uuid", \&_get_user_by_uuid);
13 &OpenSimTest::Config::registerHandler("get_avatar_picker_avatar", \&_get_avatar_picker_avatar);
14}
15
16sub _login_to_simulator {
17 my $url = shift || $OpenSimTest::Config::USER_SERVER_URL;
18 my @param = @_;
19 my %xml_rpc_param = (
20 first => $param[0],
21 last => $param[1],
22 passwd => "\$1\$" . Digest::MD5::md5_hex($param[2]),
23 start => "last",
24 version => "1.18.3.5",
25 mac => "cc82e1e2bfd24e5424d66b4fd3f70d55",
26 );
27 return &OpenSim::Utility::XMLRPCCall($url, "login_to_simulator", \%xml_rpc_param);
28}
29
30sub _get_user_by_name {
31 my $url = shift || $OpenSimTest::Config::USER_SERVER_URL;
32 my @param = @_;
33 my %xml_rpc_param = (
34 avatar_name => $param[0],
35 );
36 return &OpenSim::Utility::XMLRPCCall($url, "get_user_by_name", \%xml_rpc_param);
37}
38
39# sample uuid:
40# db836502-de98-49c9-9edc-b90a67beb0a8
41sub _get_user_by_uuid {
42 my $url = shift || $OpenSimTest::Config::USER_SERVER_URL;
43 my @param = @_;
44 my %xml_rpc_param = (
45 avatar_uuid => $param[0],
46 );
47 return &OpenSim::Utility::XMLRPCCall($url, "get_user_by_uuid", \%xml_rpc_param);
48}
49
50sub _get_avatar_picker_avatar {
51}
52
531;