コード例 #1
0
        public void TestGiveInventoryItem()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            Scene             scene = new SceneHelpers().SetupScene();
            UserAccount       user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
            UserAccount       user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
            InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID);

            scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID);

            InventoryItemBase retrievedItem1
                = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Notecards/item1");

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

            // Try giving back the freshly received item
            scene.GiveInventoryItem(user1.PrincipalID, user2.PrincipalID, retrievedItem1.ID);

            List <InventoryItemBase> reretrievedItems
                = UserInventoryHelpers.GetInventoryItems(scene.InventoryService, user1.PrincipalID, "Notecards/item1");

            Assert.That(reretrievedItems.Count, Is.EqualTo(2));
        }
コード例 #2
0
        public void TestLlGiveInventoryO2DifferentAvatarNoMod()
        {
            TestHelpers.InMethod();
            //            TestHelpers.EnableLogging();

            UUID   user1Id           = TestHelpers.ParseTail(0x1);
            UUID   user2Id           = TestHelpers.ParseTail(0x2);
            string inventoryItemName = "item1";

            SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10);

            m_scene.AddSceneObject(so1);
            LSL_Api api = new LSL_Api();

            api.Initialize(m_engine, so1.RootPart, null);

            // Create an object embedded inside the first
            UUID itemId = TestHelpers.ParseTail(0x20);
            TaskInventoryItem tii
                = TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, user1Id);

            tii.NextPermissions &= ~((uint)PermissionMask.Modify);

            UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id);

            api.llGiveInventory(user2Id.ToString(), inventoryItemName);

            InventoryItemBase receivedItem
                = UserInventoryHelpers.GetInventoryItem(
                      m_scene.InventoryService, user2Id, string.Format("Objects/{0}", inventoryItemName));

            Assert.IsNotNull(receivedItem);
            Assert.AreEqual(0, receivedItem.CurrentPermissions & (uint)PermissionMask.Modify);
        }
コード例 #3
0
        public void TestTakeCopyWhenCopierIsNotOwnerWithPerms()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            IConfigSource config = new IniConfigSource();

            config.AddConfig("Modules");
            config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");

            TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config);

            SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule());
            UserAccount ua     = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1));
            TestClient  client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient;

            // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
            AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;

            sogd.Enabled = false;

            SceneObjectGroup so        = SceneHelpers.AddSceneObject(scene, "so1", TestHelpers.ParseTail(0x2));
            uint             soLocalId = so.LocalId;

            // Base must allow transfer and copy
            so.RootPart.BaseMask = (uint)(OpenMetaverse.PermissionMask.Copy | OpenMetaverse.PermissionMask.Transfer);
            // Must be set so anyone can copy
            so.RootPart.EveryoneMask = (uint)OpenMetaverse.PermissionMask.Copy;

            List <uint> localIds = new List <uint>();

            localIds.Add(so.LocalId);

            // Specifying a UUID.Zero in this case will plop it in the Objects folder
            scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero);

            // Check that object isn't copied until we crank the sogd handle.
            SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);

            Assert.That(retrievedPart, Is.Not.Null);
            Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False);

            sogd.InventoryDeQueueAndDelete();

            // Check that object is still there.
            SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);

            Assert.That(retrievedPart2, Is.Not.Null);
            Assert.That(client.ReceivedKills.Count, Is.EqualTo(0));

            // Check that we have a copy in inventory
            InventoryItemBase item
                = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1");

            Assert.That(item, Is.Not.Null);
        }
コード例 #4
0
        public void TestGiveInventoryItemFullPerms()
        {
            TestHelpers.InMethod();

            List <Object> modules = new List <object>();
            IConfigSource config  = DefaultConfig(modules);
            Scene         scene   = new SceneHelpers().SetupScene("Inventory Permissions", UUID.Random(), 1000, 1000, config);

            SceneHelpers.SetupSceneModules(scene, config, modules.ToArray());

            UserAccount   user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
            UserAccount   user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
            ScenePresence sp1   = SceneHelpers.AddScenePresence(scene, user1.PrincipalID);
            ScenePresence sp2   = SceneHelpers.AddScenePresence(scene, user2.PrincipalID);

            InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "SomeObject", user1.PrincipalID, InventoryType.Object);

            // Set All perms in inventory
            item1.NextPermissions = (uint)OpenMetaverse.PermissionMask.All;
            scene.UpdateInventoryItemAsset(sp1.ControllingClient, UUID.Zero, item1.ID, item1);
            //Assert.That((item1.NextPermissions & (uint)OpenMetaverse.PermissionMask.All) == (uint)OpenMetaverse.PermissionMask.All);

            string message;

            InventoryItemBase retrievedItem1 = scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID, out message);

            Assert.That(retrievedItem1, Is.Not.Null);
            //Assert.That((retrievedItem1.CurrentPermissions & (uint)OpenMetaverse.PermissionMask.All) == (uint)OpenMetaverse.PermissionMask.All);

            retrievedItem1
                = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Objects/SomeObject");
            Assert.That(retrievedItem1, Is.Not.Null);
            //Assert.That((retrievedItem1.BasePermissions & (uint)OpenMetaverse.PermissionMask.All) == (uint)OpenMetaverse.PermissionMask.All);
            //Assert.That((retrievedItem1.CurrentPermissions & (uint)OpenMetaverse.PermissionMask.All) == (uint)OpenMetaverse.PermissionMask.All);

            // Rez the object
            scene.RezObject(sp2.ControllingClient, retrievedItem1.ID, UUID.Zero, Vector3.Zero, Vector3.Zero, UUID.Zero, 0, false, false, false, UUID.Zero);
            SceneObjectGroup sog = scene.GetSceneObjectGroup("SomeObject");

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

            // This is failing for all sorts of reasons. We'll fix it after perms are fixed.
            //Console.WriteLine("Item Perms " + retrievedItem1.CurrentPermissions + " Obj Owner Perms " + sog.RootPart.OwnerMask + " Base Perms " + sog.RootPart.BaseMask + "\n");
            //Assert.True((sog.RootPart.OwnerMask & (uint)OpenMetaverse.PermissionMask.All) == (uint)OpenMetaverse.PermissionMask.All);
        }
コード例 #5
0
        public void TestDeleteSceneObjectAsyncToUserInventory()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID   agentId      = UUID.Parse("00000000-0000-0000-0000-000000000001");
            string myObjectName = "Fred";

            TestScene scene = new SceneHelpers().SetupScene();

            IConfigSource configSource = new IniConfigSource();
            IConfig       config       = configSource.AddConfig("Modules");

            config.Set("InventoryAccessModule", "BasicInventoryAccessModule");
            SceneHelpers.SetupSceneModules(
                scene, configSource, new object[] { new BasicInventoryAccessModule() });

            SceneHelpers.SetupSceneModules(scene, new object[] { });

            // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
            AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;

            sogd.Enabled = false;

            SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, myObjectName, agentId);

            UserAccount         ua = UserAccountHelpers.CreateUserWithInventory(scene, agentId);
            InventoryFolderBase folder1
                = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1", false);

            IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient;

            scene.DeRezObjects(client, new List <uint>()
            {
                so.LocalId
            }, UUID.Zero, DeRezAction.Take, folder1.ID);

//            SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);

//            Assert.That(retrievedPart, Is.Not.Null);
//            Assert.That(so.IsDeleted, Is.False);

            sogd.InventoryDeQueueAndDelete();

            Assert.That(so.IsDeleted, Is.True);

            SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);

            Assert.That(retrievedPart2, Is.Null);

//            SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client);

            InventoryItemBase retrievedItem
                = UserInventoryHelpers.GetInventoryItem(
                      scene.InventoryService, ua.PrincipalID, "folder1/" + myObjectName);

            // Check that we now have the taken part in our inventory
            Assert.That(retrievedItem, Is.Not.Null);

            // Check that the taken part has actually disappeared
//            SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
//            Assert.That(retrievedPart, Is.Null);
        }
コード例 #6
0
        public void TestAcceptGivenItem()
        {
            //            TestHelpers.EnableLogging();

            UUID initialSessionId = TestHelpers.ParseTail(0x10);
            UUID itemId           = TestHelpers.ParseTail(0x100);
            UUID assetId          = TestHelpers.ParseTail(0x200);

            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 object to test give
            InventoryItemBase originalItem
                = UserInventoryHelpers.CreateInventoryItem(
                      m_scene, "givenObj", itemId, assetId, giverSp.UUID, InventoryType.Object);

            byte[] giveImBinaryBucket = new byte[17];
            byte[] itemIdBytes        = itemId.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.
            InventoryItemBase originalItemAfterGive
                = UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, giverSp.UUID, "Objects/givenObj");

            Assert.That(originalItemAfterGive, Is.Not.Null);
            Assert.That(originalItemAfterGive.ID, Is.EqualTo(originalItem.ID));

            // Test for item successfully making it into the receiver's inventory
            InventoryItemBase receivedItem
                = UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, receiverSp.UUID, "Objects/givenObj");

            Assert.That(receivedItem, Is.Not.Null);
            Assert.That(receivedItem.ID, Is.Not.EqualTo(originalItem.ID));

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

            InventoryItemBase originalItemAfterDelete
                = UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, giverSp.UUID, "Objects/givenObj");

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

            // TODO: Test scenario where giver deletes their item first.
        }
コード例 #7
0
        public void TestTakeCopyWhenCopierIsOwnerWithPerms()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            IConfigSource config = new IniConfigSource();

            config.AddConfig("Modules");
            config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");

            TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config);

            SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule());
            UserAccount ua     = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1));
            TestClient  client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient;

            // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
            AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;

            sogd.Enabled = false;

            SceneObjectGroup so        = SceneHelpers.AddSceneObject(scene, "so1", ua.PrincipalID);
            uint             soLocalId = so.LocalId;

//            so.UpdatePermissions(
//                ua.PrincipalID, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Copy, 1);
//            so.UpdatePermissions(
//                ua.PrincipalID, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0);
//            so.UpdatePermissions(
//                ua.PrincipalID, (byte)PermissionWho.Base, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0);
//            scene.HandleObjectPermissionsUpdate(client, client.AgentId, client.SessionId, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0);

            // Ideally we might change these via client-focussed method calls as commented out above.  However, this
            // becomes very convoluted so we will set only the copy perm directly.
            so.RootPart.BaseMask = (uint)OpenMetaverse.PermissionMask.Copy;
//            so.RootPart.OwnerMask = (uint)OpenMetaverse.PermissionMask.Copy;

            List <uint> localIds = new List <uint>();

            localIds.Add(so.LocalId);

            // Specifying a UUID.Zero in this case will currently plop it in Lost and Found
            scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero);

            // Check that object isn't copied until we crank the sogd handle.
            SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);

            Assert.That(retrievedPart, Is.Not.Null);
            Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False);

            sogd.InventoryDeQueueAndDelete();

            // Check that object is still there.
            SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);

            Assert.That(retrievedPart2, Is.Not.Null);
            Assert.That(client.ReceivedKills.Count, Is.EqualTo(0));

            // Check that we have a copy in inventory
            InventoryItemBase item
                = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Lost And Found/so1");

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