InventoryTester.pm 3.4 KB

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