コード例 #1
0
        public void TestGiveInventoryFolder()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            Scene               scene = new SceneHelpers().SetupScene();
            UserAccount         user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
            UserAccount         user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
            InventoryFolderBase folder1
                = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1", false);

            scene.GiveInventoryFolder(user2.PrincipalID, user1.PrincipalID, folder1.ID, UUID.Zero);

            InventoryFolderBase retrievedFolder1
                = UserInventoryHelpers.GetInventoryFolder(scene.InventoryService, user2.PrincipalID, "folder1");

            Assert.That(retrievedFolder1, Is.Not.Null);

            // Try giving back the freshly received folder
            scene.GiveInventoryFolder(user1.PrincipalID, user2.PrincipalID, retrievedFolder1.ID, UUID.Zero);

            List <InventoryFolderBase> reretrievedFolders
                = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, "folder1");

            Assert.That(reretrievedFolders.Count, Is.EqualTo(2));
        }
コード例 #2
0
ファイル: Common.cs プロジェクト: BogusCurry/opensim-1
        /// <summary>
        /// The basic environment consists of:
        /// - 3 avatars: A1, A2, A3
        /// - 6 simple boxes inworld belonging to A0 and with Next Owner perms:
        ///   C, CT, MC, MCT, MT, T
        /// - Copies of all of these boxes in A0's inventory in the Objects folder
        /// - One additional box inworld and in A0's inventory which is a copy of MCT, but
        ///   with C removed in inventory. This one is called MCT-C
        /// </summary>
        private void SetUpBasicEnvironment()
        {
            Console.WriteLine("===> SetUpBasicEnvironment <===");

            // Add 3 avatars
            for (int i = 0; i < 3; i++)
            {
                UUID id = TestHelpers.ParseTail(i + 1);

                m_Avatars[i] = AddScenePresence("Bot", "Bot_" + (i + 1), id);
                Assert.That(m_Avatars[i], Is.Not.Null);
                Assert.That(m_Avatars[i].IsChildAgent, Is.False);
                Assert.That(m_Avatars[i].UUID, Is.EqualTo(id));
                Assert.That(m_Scene.GetScenePresences().Count, Is.EqualTo(i + 1));
            }

            AddA1Object("Box C", 10, PermissionMask.Copy);
            AddA1Object("Box CT", 11, PermissionMask.Copy | PermissionMask.Transfer);
            AddA1Object("Box MC", 12, PermissionMask.Modify | PermissionMask.Copy);
            AddA1Object("Box MCT", 13, PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer);
            AddA1Object("Box MT", 14, PermissionMask.Modify | PermissionMask.Transfer);
            AddA1Object("Box T", 15, PermissionMask.Transfer);

            // MCT-C
            AddA1Object("Box MCT-C", 16, PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer);

            Thread.Sleep(5000);

            InventoryFolderBase      objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, m_Avatars[0].UUID, "Objects");
            List <InventoryItemBase> items      = m_Scene.InventoryService.GetFolderItems(m_Avatars[0].UUID, objsFolder.ID);

            Assert.That(items.Count, Is.EqualTo(7));

            RevokePermission(0, "Box MCT-C", PermissionMask.Copy);
        }
コード例 #3
0
        public void SimpleTakeCopy()
        {
            TestHelpers.InMethod();

            // The Objects folder of A2
            InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(Common.TheScene.InventoryService, Common.TheAvatars[1].UUID, "Objects");

            // C, CT, MC, MCT, MT, T
            string[] names = new string[6] {
                "Box C", "Box CT", "Box MC", "Box MCT", "Box MT", "Box T"
            };
            PermissionMask[] perms = new PermissionMask[6] {
                PermissionMask.Copy,
                PermissionMask.Copy | PermissionMask.Transfer,
                PermissionMask.Modify | PermissionMask.Copy,
                PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer,
                PermissionMask.Modify | PermissionMask.Transfer,
                PermissionMask.Transfer
            };

            // Try A2 takes copies of objects that cannot be copied.
            for (int i = 0; i < 6; i++)
            {
                TakeOneBox(Common.TheScene.GetSceneObjectGroups(), names[i], perms[i]);
            }
            // Ad-hoc. Enough time to let the take work.
            Thread.Sleep(5000);

            List <InventoryItemBase> items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[1].UUID, objsFolder.ID);

            Assert.That(items.Count, Is.EqualTo(0));

            // A1 makes the objects copyable
            for (int i = 0; i < 6; i++)
            {
                MakeCopyable(Common.TheScene.GetSceneObjectGroups(), names[i]);
            }

            // Try A2 takes copies of objects that can be copied.
            for (int i = 0; i < 6; i++)
            {
                TakeOneBox(Common.TheScene.GetSceneObjectGroups(), names[i], perms[i]);
            }
            // Ad-hoc. Enough time to let the take work.
            Thread.Sleep(5000);

            items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[1].UUID, objsFolder.ID);
            Assert.That(items.Count, Is.EqualTo(6));

            for (int i = 0; i < 6; i++)
            {
                InventoryItemBase item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", names[i]);
                Assert.That(item, Is.Not.Null);
                Common.TheInstance.AssertPermissions(perms[i], (PermissionMask)item.BasePermissions, Common.TheInstance.IdStr(item));
            }
        }
コード例 #4
0
        public void TestSaveRootFolderToIar()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            string userFirstName = "Jock";
            string userLastName  = "Stirrup";
            string userPassword  = "******";
            UUID   userId        = TestHelpers.ParseTail(0x20);

            UserAccountHelpers.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword);

            MemoryStream archiveWriteStream = new MemoryStream();

            m_archiverModule.OnInventoryArchiveSaved += SaveCompleted;

            mre.Reset();
            m_archiverModule.ArchiveInventory(
                Guid.NewGuid(), userFirstName, userLastName, "/", userPassword, archiveWriteStream);
            mre.WaitOne(60000, false);

            // Test created iar
            byte[]           archive           = archiveWriteStream.ToArray();
            MemoryStream     archiveReadStream = new MemoryStream(archive);
            TarArchiveReader tar = new TarArchiveReader(archiveReadStream);

//            InventoryArchiveUtils.
            bool gotObjectsFolder = false;

            string objectsFolderName
                = string.Format(
                      "{0}{1}",
                      ArchiveConstants.INVENTORY_PATH,
                      InventoryArchiveWriteRequest.CreateArchiveFolderName(
                          UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, userId, "Objects")));

            string filePath;

            TarArchiveReader.TarEntryType tarEntryType;

            while (tar.ReadEntry(out filePath, out tarEntryType) != null)
            {
//                Console.WriteLine("Got {0}", filePath);

                // Lazily, we only bother to look for the system objects folder created when we call CreateUserWithInventory()
                // XXX: But really we need to stop all that stuff being created in tests or check for such folders
                // more thoroughly
                if (filePath == objectsFolderName)
                {
                    gotObjectsFolder = true;
                }
            }

            Assert.That(gotObjectsFolder, Is.True);
        }
コード例 #5
0
ファイル: Common.cs プロジェクト: BogusCurry/opensim-1
        public void TakeCopyToInventory(int userIndex, SceneObjectGroup sog)
        {
            InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, m_Avatars[userIndex].UUID, "Objects");

            Assert.That(objsFolder, Is.Not.Null);

            List <uint> localIds = new List <uint>(); localIds.Add(sog.LocalId);

            // This is an async operation
            m_Scene.DeRezObjects(m_Avatars[userIndex].ControllingClient, localIds, m_Avatars[userIndex].UUID, DeRezAction.TakeCopy, objsFolder.ID);
        }
コード例 #6
0
ファイル: Common.cs プロジェクト: BogusCurry/opensim-1
        public InventoryItemBase GetItemFromInventory(UUID userID, string folderName, string itemName)
        {
            InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, userID, folderName);

            Assert.That(objsFolder, Is.Not.Null);
            List <InventoryItemBase> items = m_Scene.InventoryService.GetFolderItems(userID, objsFolder.ID);
            InventoryItemBase        item  = items.Find(i => i.Name == itemName);

            Assert.That(item, Is.Not.Null);

            return(item);
        }
コード例 #7
0
ファイル: Common.cs プロジェクト: BogusCurry/opensim-1
        public void DeleteObjectsFolders()
        {
            // Delete everything in A2 and A3's Objects folders, so we can restart
            for (int i = 1; i < 3; i++)
            {
                InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(Common.TheScene.InventoryService, Common.TheAvatars[i].UUID, "Objects");
                Assert.That(objsFolder, Is.Not.Null);

                List <InventoryItemBase> items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[i].UUID, objsFolder.ID);
                List <UUID> ids = new List <UUID>();
                foreach (InventoryItemBase it in items)
                {
                    ids.Add(it.ID);
                }

                Common.TheScene.InventoryService.DeleteItems(Common.TheAvatars[i].UUID, ids);
                items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[i].UUID, objsFolder.ID);
                Assert.That(items.Count, Is.EqualTo(0), "A" + (i + 1));
            }
        }
コード例 #8
0
        public void TestRejectGivenFolder()
        {
            TestHelpers.InMethod();
            //            TestHelpers.EnableLogging();

            UUID initialSessionId = TestHelpers.ParseTail(0x10);
            UUID folderId         = TestHelpers.ParseTail(0x100);

            UserAccount ua1
                = UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "One", TestHelpers.ParseTail(0x1), "pw");
            UserAccount ua2
                = UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "Two", TestHelpers.ParseTail(0x2), "pw");

            ScenePresence giverSp     = SceneHelpers.AddScenePresence(m_scene, ua1);
            TestClient    giverClient = (TestClient)giverSp.ControllingClient;

            ScenePresence receiverSp     = SceneHelpers.AddScenePresence(m_scene, ua2);
            TestClient    receiverClient = (TestClient)receiverSp.ControllingClient;

            // Create the folder to test give
            InventoryFolderBase originalFolder
                = UserInventoryHelpers.CreateInventoryFolder(
                      m_scene.InventoryService, giverSp.UUID, folderId, "f1", true);

            GridInstantMessage receivedIm = null;

            receiverClient.OnReceivedInstantMessage += im => receivedIm = im;

            byte[] giveImBinaryBucket = new byte[17];
            giveImBinaryBucket[0] = (byte)AssetType.Folder;
            byte[] itemIdBytes = folderId.GetBytes();
            Array.Copy(itemIdBytes, 0, giveImBinaryBucket, 1, itemIdBytes.Length);

            GridInstantMessage giveIm
                = new GridInstantMessage(
                      m_scene,
                      giverSp.UUID,
                      giverSp.Name,
                      receiverSp.UUID,
                      (byte)InstantMessageDialog.InventoryOffered,
                      false,
                      "inventory offered msg",
                      initialSessionId,
                      false,
                      Vector3.Zero,
                      giveImBinaryBucket,
                      true);

            giverClient.HandleImprovedInstantMessage(giveIm);

            // These details might not all be correct.
            // Session ID is now the created item ID (!)
            GridInstantMessage rejectIm
                = new GridInstantMessage(
                      m_scene,
                      receiverSp.UUID,
                      receiverSp.Name,
                      giverSp.UUID,
                      (byte)InstantMessageDialog.InventoryDeclined,
                      false,
                      "inventory declined msg",
                      new UUID(receivedIm.imSessionID),
                      false,
                      Vector3.Zero,
                      null,
                      true);

            receiverClient.HandleImprovedInstantMessage(rejectIm);

            // Test for item remaining in the giver's inventory (here we assume a copy item)
            // TODO: Test no-copy items.
            InventoryFolderBase originalFolderAfterGive
                = UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, giverSp.UUID, "f1");

            Assert.That(originalFolderAfterGive, Is.Not.Null);
            Assert.That(originalFolderAfterGive.ID, Is.EqualTo(originalFolder.ID));

            // Test for folder successfully making it into the receiver's inventory
            InventoryFolderBase receivedFolder
                = UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, receiverSp.UUID, "Trash/f1");

            InventoryFolderBase trashFolder
                = m_scene.InventoryService.GetFolderForType(receiverSp.UUID, FolderType.Trash);

            Assert.That(receivedFolder, Is.Not.Null);
            Assert.That(receivedFolder.ID, Is.Not.EqualTo(originalFolder.ID));
            Assert.That(receivedFolder.ParentID, Is.EqualTo(trashFolder.ID));

            // Test that on a delete, item still exists and is accessible for the giver.
            m_scene.InventoryService.PurgeFolder(trashFolder);

            InventoryFolderBase originalFolderAfterDelete
                = UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, giverSp.UUID, "f1");

            Assert.That(originalFolderAfterDelete, Is.Not.Null);
        }
コード例 #9
0
        public void TestAcceptGivenFolder()
        {
            TestHelpers.InMethod();
            //            TestHelpers.EnableLogging();

            UUID initialSessionId = TestHelpers.ParseTail(0x10);
            UUID folderId         = TestHelpers.ParseTail(0x100);

            UserAccount ua1
                = UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "One", TestHelpers.ParseTail(0x1), "pw");
            UserAccount ua2
                = UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "Two", TestHelpers.ParseTail(0x2), "pw");

            ScenePresence giverSp     = SceneHelpers.AddScenePresence(m_scene, ua1);
            TestClient    giverClient = (TestClient)giverSp.ControllingClient;

            ScenePresence receiverSp     = SceneHelpers.AddScenePresence(m_scene, ua2);
            TestClient    receiverClient = (TestClient)receiverSp.ControllingClient;

            InventoryFolderBase originalFolder
                = UserInventoryHelpers.CreateInventoryFolder(
                      m_scene.InventoryService, giverSp.UUID, folderId, "f1", true);

            byte[] giveImBinaryBucket = new byte[17];
            giveImBinaryBucket[0] = (byte)AssetType.Folder;
            byte[] itemIdBytes = folderId.GetBytes();
            Array.Copy(itemIdBytes, 0, giveImBinaryBucket, 1, itemIdBytes.Length);

            GridInstantMessage giveIm
                = new GridInstantMessage(
                      m_scene,
                      giverSp.UUID,
                      giverSp.Name,
                      receiverSp.UUID,
                      (byte)InstantMessageDialog.InventoryOffered,
                      false,
                      "inventory offered msg",
                      initialSessionId,
                      false,
                      Vector3.Zero,
                      giveImBinaryBucket,
                      true);

            giverClient.HandleImprovedInstantMessage(giveIm);

            // These details might not all be correct.
            GridInstantMessage acceptIm
                = new GridInstantMessage(
                      m_scene,
                      receiverSp.UUID,
                      receiverSp.Name,
                      giverSp.UUID,
                      (byte)InstantMessageDialog.InventoryAccepted,
                      false,
                      "inventory accepted msg",
                      initialSessionId,
                      false,
                      Vector3.Zero,
                      null,
                      true);

            receiverClient.HandleImprovedInstantMessage(acceptIm);

            // Test for item remaining in the giver's inventory (here we assume a copy item)
            // TODO: Test no-copy items.
            InventoryFolderBase originalFolderAfterGive
                = UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, giverSp.UUID, "f1");

            Assert.That(originalFolderAfterGive, Is.Not.Null);
            Assert.That(originalFolderAfterGive.ID, Is.EqualTo(originalFolder.ID));

            // Test for item successfully making it into the receiver's inventory
            InventoryFolderBase receivedFolder
                = UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, receiverSp.UUID, "f1");

            Assert.That(receivedFolder, Is.Not.Null);
            Assert.That(receivedFolder.ID, Is.Not.EqualTo(originalFolder.ID));

            // Test that on a delete, item still exists and is accessible for the giver.
            m_scene.InventoryService.DeleteFolders(receiverSp.UUID, new List <UUID>()
            {
                receivedFolder.ID
            });

            InventoryFolderBase originalFolderAfterDelete
                = UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, giverSp.UUID, "f1");

            Assert.That(originalFolderAfterDelete, Is.Not.Null);

            // TODO: Test scenario where giver deletes their item first.
        }