From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 21:24:15 +1000 Subject: Dump OpenSim 0.9.0.1 into it's own branch. --- OpenSim/Tests/Clients/Grid/GridClient.cs | 205 +++++++++++ OpenSim/Tests/Common/DatabaseTestAttribute.cs | 6 +- OpenSim/Tests/Common/Helpers/AssetHelpers.cs | 32 +- .../Common/Helpers/BaseRequestHandlerHelpers.cs | 2 +- OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs | 6 +- .../Tests/Common/Helpers/EntityTransferHelpers.cs | 12 +- OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 74 ++-- .../Tests/Common/Helpers/TaskInventoryHelpers.cs | 12 +- OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs | 4 +- .../Tests/Common/Helpers/UserInventoryHelpers.cs | 20 +- OpenSim/Tests/Common/LongRunningAttribute.cs | 4 +- OpenSim/Tests/Common/Mock/BaseAssetRepository.cs | 8 +- OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs | 3 +- .../Common/Mock/MockGroupsServicesConnector.cs | 28 +- OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs | 58 +++- OpenSim/Tests/Common/Mock/MockScriptEngine.cs | 10 +- OpenSim/Tests/Common/Mock/TestClient.cs | 128 +++++-- .../Tests/Common/Mock/TestEventQueueGetModule.cs | 27 +- OpenSim/Tests/Common/Mock/TestGroupsDataPlugin.cs | 339 +++++++++++++++++++ OpenSim/Tests/Common/Mock/TestHttpClientContext.cs | 16 +- OpenSim/Tests/Common/Mock/TestHttpRequest.cs | 82 ++--- OpenSim/Tests/Common/Mock/TestHttpResponse.cs | 38 ++- .../Tests/Common/Mock/TestInventoryDataPlugin.cs | 40 +-- OpenSim/Tests/Common/Mock/TestLLUDPServer.cs | 30 +- OpenSim/Tests/Common/Mock/TestLandChannel.cs | 9 +- OpenSim/Tests/Common/Mock/TestScene.cs | 6 +- .../Tests/Common/Mock/TestXInventoryDataPlugin.cs | 10 +- OpenSim/Tests/Common/TestHelpers.cs | 8 +- OpenSim/Tests/Performance/NPCPerformanceTests.cs | 4 +- OpenSim/Tests/Permissions/Common.cs | 374 +++++++++++++++++++++ OpenSim/Tests/Permissions/DirectTransferTests.cs | 153 +++++++++ OpenSim/Tests/Permissions/IndirectTransferTests.cs | 132 ++++++++ OpenSim/Tests/Robust/Clients/Grid/GridClient.cs | 4 +- .../Robust/Clients/Inventory/InventoryClient.cs | 7 +- OpenSim/Tests/Robust/Server/DemonServer.cs | 4 +- .../Tests/Stress/VectorRenderModuleStressTests.cs | 7 +- 36 files changed, 1621 insertions(+), 281 deletions(-) create mode 100644 OpenSim/Tests/Clients/Grid/GridClient.cs create mode 100644 OpenSim/Tests/Common/Mock/TestGroupsDataPlugin.cs create mode 100644 OpenSim/Tests/Permissions/Common.cs create mode 100644 OpenSim/Tests/Permissions/DirectTransferTests.cs create mode 100644 OpenSim/Tests/Permissions/IndirectTransferTests.cs (limited to 'OpenSim/Tests') diff --git a/OpenSim/Tests/Clients/Grid/GridClient.cs b/OpenSim/Tests/Clients/Grid/GridClient.cs new file mode 100644 index 0000000..7d3aee3 --- /dev/null +++ b/OpenSim/Tests/Clients/Grid/GridClient.cs @@ -0,0 +1,205 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; +using System.Reflection; + +using OpenMetaverse; +using log4net; +using log4net.Appender; +using log4net.Layout; + +using OpenSim.Framework; +using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using OpenSim.Services.Connectors; + +namespace OpenSim.Tests.Clients.GridClient +{ + public class GridClient + { +// private static readonly ILog m_log = +// LogManager.GetLogger( +// MethodBase.GetCurrentMethod().DeclaringType); + + public static void Main(string[] args) + { + ConsoleAppender consoleAppender = new ConsoleAppender(); + consoleAppender.Layout = + new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"); + log4net.Config.BasicConfigurator.Configure(consoleAppender); + + string serverURI = "http://127.0.0.1:8001"; + GridServicesConnector m_Connector = new GridServicesConnector(serverURI); + + GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000); + GridRegion r2 = CreateRegion("Test Region 2", 1001, 1000); + GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000); + + Console.WriteLine("[GRID CLIENT]: *** Registering region 1"); + string msg = m_Connector.RegisterRegion(UUID.Zero, r1); + if (msg == String.Empty) + Console.WriteLine("[GRID CLIENT]: Successfully registered region 1"); + else + Console.WriteLine("[GRID CLIENT]: region 1 failed to register"); + + Console.WriteLine("[GRID CLIENT]: *** Registering region 2"); + msg = m_Connector.RegisterRegion(UUID.Zero, r2); + if (msg == String.Empty) + Console.WriteLine("[GRID CLIENT]: Successfully registered region 2"); + else + Console.WriteLine("[GRID CLIENT]: region 2 failed to register"); + + Console.WriteLine("[GRID CLIENT]: *** Registering region 3"); + msg = m_Connector.RegisterRegion(UUID.Zero, r3); + if (msg == String.Empty) + Console.WriteLine("[GRID CLIENT]: Successfully registered region 3"); + else + Console.WriteLine("[GRID CLIENT]: region 3 failed to register"); + + + bool success; + Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3"); + success = m_Connector.DeregisterRegion(r3.RegionID); + if (success) + Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3"); + else + Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister"); + Console.WriteLine("[GRID CLIENT]: *** Registering region 3 again"); + msg = m_Connector.RegisterRegion(UUID.Zero, r3); + if (msg == String.Empty) + Console.WriteLine("[GRID CLIENT]: Successfully registered region 3"); + else + Console.WriteLine("[GRID CLIENT]: region 3 failed to register"); + + Console.WriteLine("[GRID CLIENT]: *** GetNeighbours of region 1"); + List regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID); + if (regions == null) + Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 failed"); + else if (regions.Count > 0) + { + if (regions.Count != 1) + Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned more neighbours than expected: " + regions.Count); + else + Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned the right neighbour " + regions[0].RegionName); + } + else + Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned 0 neighbours"); + + + Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of region 2 (this should succeed)"); + GridRegion region = m_Connector.GetRegionByUUID(UUID.Zero, r2.RegionID); + if (region == null) + Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null"); + else + Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName); + + Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of non-existent region (this should fail)"); + region = m_Connector.GetRegionByUUID(UUID.Zero, UUID.Random()); + if (region == null) + Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null"); + else + Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName); + + Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of region 3 (this should succeed)"); + region = m_Connector.GetRegionByName(UUID.Zero, r3.RegionName); + if (region == null) + Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null"); + else + Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName); + + Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of non-existent region (this should fail)"); + region = m_Connector.GetRegionByName(UUID.Zero, "Foo"); + if (region == null) + Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null"); + else + Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName); + + Console.WriteLine("[GRID CLIENT]: *** GetRegionsByName (this should return 3 regions)"); + regions = m_Connector.GetRegionsByName(UUID.Zero, "Test", 10); + if (regions == null) + Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned null"); + else + Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned " + regions.Count + " regions"); + + Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 2 regions)"); + regions = m_Connector.GetRegionRange(UUID.Zero, + (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002), + (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002) ); + if (regions == null) + Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null"); + else + Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions"); + Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 0 regions)"); + regions = m_Connector.GetRegionRange(UUID.Zero, + (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950), + (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950) ); + if (regions == null) + Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null"); + else + Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions"); + + Console.Write("Proceed to deregister? Press enter..."); + Console.ReadLine(); + + // Deregister them all + Console.WriteLine("[GRID CLIENT]: *** Deregistering region 1"); + success = m_Connector.DeregisterRegion(r1.RegionID); + if (success) + Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 1"); + else + Console.WriteLine("[GRID CLIENT]: region 1 failed to deregister"); + Console.WriteLine("[GRID CLIENT]: *** Deregistering region 2"); + success = m_Connector.DeregisterRegion(r2.RegionID); + if (success) + Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 2"); + else + Console.WriteLine("[GRID CLIENT]: region 2 failed to deregister"); + Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3"); + success = m_Connector.DeregisterRegion(r3.RegionID); + if (success) + Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3"); + else + Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister"); + + } + + private static GridRegion CreateRegion(string name, uint xcell, uint ycell) + { + GridRegion region = new GridRegion(xcell, ycell); + region.RegionName = name; + region.RegionID = UUID.Random(); + region.ExternalHostName = "127.0.0.1"; + region.HttpPort = 9000; + region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 9000); + + return region; + } + } +} diff --git a/OpenSim/Tests/Common/DatabaseTestAttribute.cs b/OpenSim/Tests/Common/DatabaseTestAttribute.cs index d027d59..d6a03cd 100644 --- a/OpenSim/Tests/Common/DatabaseTestAttribute.cs +++ b/OpenSim/Tests/Common/DatabaseTestAttribute.cs @@ -32,13 +32,13 @@ using NUnit.Framework; namespace OpenSim.Tests.Common { - [AttributeUsage(AttributeTargets.All, - AllowMultiple=false, + [AttributeUsage(AttributeTargets.All, + AllowMultiple=false, Inherited=true)] public class DatabaseTestAttribute : LongRunningAttribute { public DatabaseTestAttribute() : base("Database") - { + { } } } \ No newline at end of file diff --git a/OpenSim/Tests/Common/Helpers/AssetHelpers.cs b/OpenSim/Tests/Common/Helpers/AssetHelpers.cs index 7af8bed..974da4c 100644 --- a/OpenSim/Tests/Common/Helpers/AssetHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/AssetHelpers.cs @@ -66,7 +66,7 @@ namespace OpenSim.Tests.Common { return CreateAsset(assetId, AssetType.Notecard, text, UUID.Random()); } - + // /// // /// Create and store a notecard asset with a random uuid and dummy text. // /// @@ -92,7 +92,7 @@ namespace OpenSim.Tests.Common { return CreateAsset(new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", assetUuidTail)), sog); } - + /// /// Create an asset from the given object. /// @@ -102,12 +102,12 @@ namespace OpenSim.Tests.Common public static AssetBase CreateAsset(UUID assetUuid, SceneObjectGroup sog) { return CreateAsset( - assetUuid, - AssetType.Object, - Encoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog)), + assetUuid, + AssetType.Object, + Encoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog)), sog.OwnerID); } - + /// /// Create an asset from the given scene object. /// @@ -120,8 +120,8 @@ namespace OpenSim.Tests.Common public static AssetBase CreateAsset(int assetUuidTail, CoalescedSceneObjects coa) { return CreateAsset(new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", assetUuidTail)), coa); - } - + } + /// /// Create an asset from the given scene object. /// @@ -131,12 +131,12 @@ namespace OpenSim.Tests.Common public static AssetBase CreateAsset(UUID assetUuid, CoalescedSceneObjects coa) { return CreateAsset( - assetUuid, - AssetType.Object, - Encoding.ASCII.GetBytes(CoalescedSceneObjectsSerializer.ToXml(coa)), + assetUuid, + AssetType.Object, + Encoding.ASCII.GetBytes(CoalescedSceneObjectsSerializer.ToXml(coa)), coa.CreatorId); - } - + } + /// /// Create an asset from the given data. /// @@ -148,7 +148,7 @@ namespace OpenSim.Tests.Common return CreateAsset(assetUuid, assetType, anc.AssetData, creatorID); } - + /// /// Create an asset from the given data. /// @@ -158,9 +158,9 @@ namespace OpenSim.Tests.Common asset.Data = data; return asset; } - + public static string ReadAssetAsString(IAssetService assetService, UUID uuid) - { + { byte[] assetData = assetService.GetData(uuid.ToString()); return Encoding.ASCII.GetString(assetData); } diff --git a/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs b/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs index 82ecf9a..b27c719 100644 --- a/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs @@ -59,7 +59,7 @@ namespace OpenSim.Tests.Common Assert.AreEqual(m_emptyStringArray, handler.SplitParams(null), "Failed on null."); Assert.AreEqual(m_emptyStringArray, handler.SplitParams(""), "Failed on empty path."); Assert.AreEqual(m_emptyStringArray, handler.SplitParams("corruptUrl"), "Failed on corrupt url."); - + Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath), "Failed on empty params."); Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath + "/"), "Failed on single slash."); diff --git a/OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs b/OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs index 33cd8a2..753830f 100644 --- a/OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs @@ -48,7 +48,7 @@ namespace OpenSim.Tests.Common { public static ScenePresence AddChildClient( Scene scene, LLUDPServer udpServer, UUID agentId, UUID sessionId, uint circuitCode) - { + { IPEndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999); UseCircuitCodePacket uccp = new UseCircuitCodePacket(); @@ -86,10 +86,10 @@ namespace OpenSim.Tests.Common uint port = 0; AgentCircuitManager acm = scene.AuthenticateHandler; - TestLLUDPServer udpServer = new TestLLUDPServer(IPAddress.Any, ref port, 0, false, configSource, acm); + TestLLUDPServer udpServer = new TestLLUDPServer(IPAddress.Any, ref port, 0, configSource, acm); udpServer.AddScene(scene); return udpServer; } } -} \ No newline at end of file +} diff --git a/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs b/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs index b215f1e..b0c9596 100644 --- a/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs @@ -56,7 +56,7 @@ namespace OpenSim.Tests.Common /// /// /// - /// A list that will be populated with any TestClients set up in response to + /// A list that will be populated with any TestClients set up in response to /// being informed about a destination region. /// public static void SetupInformClientOfNeighbourTriggersNeighbourClientCreate( @@ -71,7 +71,7 @@ namespace OpenSim.Tests.Common Util.RegionHandleToRegionLoc(neighbourHandle, out x, out y); m_log.DebugFormat( - "[TEST CLIENT]: Processing inform client of neighbour located at {0},{1} at {2}", + "[TEST CLIENT]: Processing inform client of neighbour located at {0},{1} at {2}", x, y, neighbourExternalEndPoint); AgentCircuitData newAgent = tc.RequestClientInfo(); @@ -91,20 +91,20 @@ namespace OpenSim.Tests.Common /// /// /// - /// A list that will be populated with any TestClients set up in response to + /// A list that will be populated with any TestClients set up in response to /// being informed about a destination region. /// public static void SetupSendRegionTeleportTriggersDestinationClientCreateAndCompleteMovement( TestClient client, List destinationClients) { - client.OnTestClientSendRegionTeleport + client.OnTestClientSendRegionTeleport += (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL) => { uint x, y; Util.RegionHandleToRegionLoc(regionHandle, out x, out y); m_log.DebugFormat( - "[TEST CLIENT]: Processing send region teleport for destination at {0},{1} at {2}", + "[TEST CLIENT]: Processing send region teleport for destination at {0},{1} at {2}", x, y, regionExternalEndPoint); AgentCircuitData newAgent = client.RequestClientInfo(); @@ -120,4 +120,4 @@ namespace OpenSim.Tests.Common }; } } -} \ No newline at end of file +} diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index df8b14c..7902fb1 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs @@ -102,7 +102,7 @@ namespace OpenSim.Tests.Common m_physicsScene = StartPhysicsScene(); - SimDataService + SimDataService = OpenSim.Server.Base.ServerUtils.LoadPlugin("OpenSim.Tests.Common.dll", null); } @@ -146,7 +146,7 @@ namespace OpenSim.Tests.Common // We must set up a console otherwise setup of some modules may fail MainConsole.Instance = new MockConsole(); - + RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); regInfo.RegionName = name; regInfo.RegionID = id; @@ -156,6 +156,9 @@ namespace OpenSim.Tests.Common TestScene testScene = new TestScene( regInfo, m_acm, SimDataService, m_estateDataService, configSource, null); + testScene.RegionInfo.EstateSettings = new EstateSettings(); + testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); + INonSharedRegionModule godsModule = new GodsModule(); godsModule.Initialise(new IniConfigSource()); godsModule.AddRegion(testScene); @@ -196,14 +199,13 @@ namespace OpenSim.Tests.Common m_presenceService.AddRegion(testScene); m_presenceService.RegionLoaded(testScene); testScene.AddRegionModule(m_presenceService.Name, m_presenceService); - - testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); + + testScene.SetModuleInterfaces(); testScene.LandChannel = new TestLandChannel(testScene); - testScene.LoadWorldMap(); + testScene.LoadWorldMap(); - testScene.RegionInfo.EstateSettings = new EstateSettings(); testScene.LoginsEnabled = true; testScene.RegisterRegionWithGrid(); @@ -215,10 +217,10 @@ namespace OpenSim.Tests.Common private static LocalAssetServicesConnector StartAssetService(CoreAssetCache cache) { IConfigSource config = new IniConfigSource(); - config.AddConfig("Modules"); - config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); + config.AddConfig("Modules"); + config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); config.AddConfig("AssetService"); - config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); + config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); LocalAssetServicesConnector assetService = new LocalAssetServicesConnector(); @@ -233,7 +235,7 @@ namespace OpenSim.Tests.Common cache.Initialise(cacheConfig); } - + return assetService; } @@ -255,7 +257,7 @@ namespace OpenSim.Tests.Common private static LocalInventoryServicesConnector StartInventoryService() { - IConfigSource config = new IniConfigSource(); + IConfigSource config = new IniConfigSource(); config.AddConfig("Modules"); config.AddConfig("InventoryService"); config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector"); @@ -264,8 +266,8 @@ namespace OpenSim.Tests.Common LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector(); inventoryService.Initialise(config); - - return inventoryService; + + return inventoryService; } private static LocalGridServicesConnector StartGridService() @@ -280,7 +282,7 @@ namespace OpenSim.Tests.Common LocalGridServicesConnector gridService = new LocalGridServicesConnector(); gridService.Initialise(config); - + return gridService; } @@ -301,7 +303,7 @@ namespace OpenSim.Tests.Common LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector(); userAccountService.Initialise(config); - + return userAccountService; } @@ -326,7 +328,7 @@ namespace OpenSim.Tests.Common LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector(); presenceService.Initialise(config); - + return presenceService; } @@ -382,8 +384,8 @@ namespace OpenSim.Tests.Common /// /// /// If called directly, then all the modules must be shared modules. - /// - /// We are emulating here the normal calls made to setup region modules + /// + /// We are emulating here the normal calls made to setup region modules /// (Initialise(), PostInitialise(), AddRegion, RegionLoaded()). /// TODO: Need to reuse normal runtime module code. /// @@ -606,7 +608,7 @@ namespace OpenSim.Tests.Common /// public static SceneObjectGroup AddSceneObject(Scene scene) { - return AddSceneObject(scene, "Test Object", UUID.Zero); + return AddSceneObject(scene, "Test Object", UUID.Random()); } /// @@ -624,6 +626,7 @@ namespace OpenSim.Tests.Common //part.ObjectFlags |= (uint)PrimFlags.Phantom; scene.AddNewSceneObject(so, true); + so.InvalidateDeepEffectivePerms(); return so; } @@ -650,10 +653,11 @@ namespace OpenSim.Tests.Common SceneObjectGroup so = CreateSceneObject(parts, ownerId, partNamePrefix, uuidTail); scene.AddNewSceneObject(so, false); + so.InvalidateDeepEffectivePerms(); return so; } - + /// /// Create a scene object part. /// @@ -662,10 +666,10 @@ namespace OpenSim.Tests.Common /// /// public static SceneObjectPart CreateSceneObjectPart(string name, UUID id, UUID ownerId) - { + { return new SceneObjectPart( - ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) - { Name = name, UUID = id, Scale = new Vector3(1, 1, 1) }; + ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) + { Name = name, UUID = id, Scale = new Vector3(1, 1, 1) }; } /// @@ -680,10 +684,10 @@ namespace OpenSim.Tests.Common /// /// public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId) - { + { return CreateSceneObject(parts, ownerId, 0x1); } - + /// /// Create a scene object but do not add it to the scene. /// @@ -695,10 +699,10 @@ namespace OpenSim.Tests.Common /// /// public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId, int uuidTail) - { + { return CreateSceneObject(parts, ownerId, "", uuidTail); - } - + } + /// /// Create a scene object but do not add it to the scene. /// @@ -716,22 +720,22 @@ namespace OpenSim.Tests.Common /// /// public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId, string partNamePrefix, int uuidTail) - { + { string rawSogId = string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail); - - SceneObjectGroup sog + + SceneObjectGroup sog = new SceneObjectGroup( CreateSceneObjectPart(string.Format("{0}Part1", partNamePrefix), new UUID(rawSogId), ownerId)); - + if (parts > 1) for (int i = 2; i <= parts; i++) sog.AddPart( CreateSceneObjectPart( - string.Format("{0}Part{1}", partNamePrefix, i), + string.Format("{0}Part{1}", partNamePrefix, i), new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail + i - 1)), ownerId)); - + return sog; - } + } } } diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs index 3a3b33a..e3110f6 100644 --- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs @@ -78,12 +78,12 @@ namespace OpenSim.Tests.Common = AssetHelpers.CreateAsset(assetID, AssetType.Notecard, nc.AssetData, UUID.Zero); assetService.Store(ncAsset); - TaskInventoryItem ncItem - = new TaskInventoryItem + TaskInventoryItem ncItem + = new TaskInventoryItem { Name = itemName, AssetID = assetID, ItemID = itemID, Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard }; - part.Inventory.AddInventoryItem(ncItem, true); - + part.Inventory.AddInventoryItem(ncItem, true); + return ncItem; } @@ -119,7 +119,7 @@ namespace OpenSim.Tests.Common { return AddScript(assetService, part, UUID.Random(), UUID.Random(), scriptName, scriptSource); } - + /// /// Add a simple script to the given part. /// @@ -145,7 +145,7 @@ namespace OpenSim.Tests.Common = AssetHelpers.CreateAsset(assetId, AssetType.LSLText, ast.AssetData, UUID.Zero); assetService.Store(asset); TaskInventoryItem item - = new TaskInventoryItem + = new TaskInventoryItem { Name = scriptName, AssetID = assetId, ItemID = itemId, Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL }; part.Inventory.AddInventoryItem(item, true); diff --git a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs index c62b58e..e6af34b 100644 --- a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs @@ -83,7 +83,7 @@ namespace OpenSim.Tests.Common // /// // /// // public static CachedUserInfo CreateUserWithInventory( -// CommunicationsManager commsManager, string firstName, string lastName, +// CommunicationsManager commsManager, string firstName, string lastName, // UUID userId, OnInventoryReceivedDelegate callback) // { // return CreateUserWithInventory(commsManager, firstName, lastName, "troll", userId, callback); @@ -147,7 +147,7 @@ namespace OpenSim.Tests.Common CreateUserWithInventory(scene, ua, pw); return ua; } - + public static void CreateUserWithInventory(Scene scene, UserAccount ua, string pw) { // FIXME: This should really be set up by UserAccount itself diff --git a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs index 5a36332..e188665 100644 --- a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs @@ -101,7 +101,7 @@ namespace OpenSim.Tests.Common Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId) { return AddInventoryItem( - scene, itemName, itemId, itemType, asset, userId, + scene, itemName, itemId, itemType, asset, userId, scene.InventoryService.GetFolderForType(userId, (FolderType)asset.Type).Name); } @@ -128,6 +128,10 @@ namespace OpenSim.Tests.Common item.Owner = userId; item.AssetType = asset.Type; item.InvType = (int)itemType; + item.BasePermissions = (uint)OpenMetaverse.PermissionMask.All | + (uint)(Framework.PermissionMask.FoldedMask | Framework.PermissionMask.FoldedCopy | Framework.PermissionMask.FoldedModify | Framework.PermissionMask.FoldedTransfer); + item.CurrentPermissions = (uint)OpenMetaverse.PermissionMask.All | + (uint)(Framework.PermissionMask.FoldedMask | Framework.PermissionMask.FoldedCopy | Framework.PermissionMask.FoldedModify | Framework.PermissionMask.FoldedTransfer); InventoryFolderBase folder = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, userId, path)[0]; @@ -207,7 +211,7 @@ namespace OpenSim.Tests.Common /// /// /// If true, then folders in the path which already the same name are - /// used. This applies to the terminal folder as well. + /// used. This applies to the terminal folder as well. /// If false, then all folders in the path are created, even if there is already a folder at a particular /// level with the same name. /// @@ -232,7 +236,7 @@ namespace OpenSim.Tests.Common /// /// /// If true, then folders in the path which already the same name are - /// used. This applies to the terminal folder as well. + /// used. This applies to the terminal folder as well. /// If false, then all folders in the path are created, even if there is already a folder at a particular /// level with the same name. /// @@ -255,7 +259,7 @@ namespace OpenSim.Tests.Common /// Create inventory folders starting from a given parent folder /// /// - /// If any stem of the path names folders that already exist then these are not recreated. This includes the + /// If any stem of the path names folders that already exist then these are not recreated. This includes the /// final folder. /// TODO: May need to make it an option to create duplicate folders. /// @@ -267,7 +271,7 @@ namespace OpenSim.Tests.Common /// /// /// If true, then folders in the path which already the same name are - /// used. This applies to the terminal folder as well. + /// used. This applies to the terminal folder as well. /// If false, then all folders in the path are created, even if there is already a folder at a particular /// level with the same name. /// @@ -295,10 +299,10 @@ namespace OpenSim.Tests.Common else folderIdForCreate = folderId; - folder + folder = new InventoryFolderBase( folderIdForCreate, components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0); - + inventoryService.AddFolder(folder); } // else @@ -367,4 +371,4 @@ namespace OpenSim.Tests.Common return InventoryArchiveUtils.FindItemsByPath(inventoryService, userId, path); } } -} \ No newline at end of file +} diff --git a/OpenSim/Tests/Common/LongRunningAttribute.cs b/OpenSim/Tests/Common/LongRunningAttribute.cs index 9831ea8..6013fcb 100644 --- a/OpenSim/Tests/Common/LongRunningAttribute.cs +++ b/OpenSim/Tests/Common/LongRunningAttribute.cs @@ -35,11 +35,11 @@ namespace OpenSim.Tests.Common [AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)] - public class LongRunningAttribute : CategoryAttribute + public class LongRunningAttribute : CategoryAttribute { public LongRunningAttribute() : this("Long Running Test") { - + } protected LongRunningAttribute(string category) : base(category) diff --git a/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs b/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs index cb4fb80..d0430ff 100644 --- a/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs +++ b/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs @@ -36,7 +36,7 @@ namespace OpenSim.Tests.Common { protected Dictionary Assets = new Dictionary(); - public AssetBase FetchAsset(UUID uuid) + public AssetBase FetchAsset(UUID uuid) { if (AssetsExist(new[] { uuid })[0]) return Assets[uuid]; @@ -44,17 +44,17 @@ namespace OpenSim.Tests.Common return null; } - public void CreateAsset(AssetBase asset) + public void CreateAsset(AssetBase asset) { Assets[asset.FullID] = asset; } - public void UpdateAsset(AssetBase asset) + public void UpdateAsset(AssetBase asset) { CreateAsset(asset); } - public bool[] AssetsExist(UUID[] uuids) + public bool[] AssetsExist(UUID[] uuids) { return Array.ConvertAll(uuids, id => Assets.ContainsKey(id)); } diff --git a/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs index dddf75d..aaf61e7 100644 --- a/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs @@ -54,9 +54,10 @@ namespace OpenSim.Tests.Common return assets.Find(x=>x.FullID == uuid); } - public void StoreAsset(AssetBase asset) + public bool StoreAsset(AssetBase asset) { assets.Add(asset); + return true; } public List FetchAssetMetadataSet(int start, int count) { return new List(count); } diff --git a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs index 7f530d0..e9deac7 100644 --- a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs +++ b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs @@ -85,8 +85,8 @@ namespace OpenSim.Tests.Common { } - public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID, - int membershipFee, bool openEnrollment, bool allowPublish, + public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID, + int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID) { XGroup group = new XGroup() @@ -118,13 +118,13 @@ namespace OpenSim.Tests.Common } } - public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList, - UUID insigniaID, int membershipFee, bool openEnrollment, + public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList, + UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) { } - public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, + public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers) { } @@ -133,7 +133,7 @@ namespace OpenSim.Tests.Common { } - public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, + public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers) { } @@ -144,7 +144,7 @@ namespace OpenSim.Tests.Common if (group == null) - m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: No group found with ID {0}", groupID); + m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: No group found with ID {0}", groupID); return group; } @@ -152,7 +152,7 @@ namespace OpenSim.Tests.Common public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName) { m_log.DebugFormat( - "[MOCK GROUPS SERVICES CONNECTOR]: Processing GetGroupRecord() for groupID {0}, name {1}", + "[MOCK GROUPS SERVICES CONNECTOR]: Processing GetGroupRecord() for groupID {0}, name {1}", groupID, groupName); XGroup xg = GetXGroup(groupID, groupName); @@ -194,7 +194,7 @@ namespace OpenSim.Tests.Common public void SetAgentGroupInfo(UUID requestingAgentID, UUID agentID, UUID groupID, bool acceptNotices, bool listInProfile) { m_log.DebugFormat( - "[MOCK GROUPS SERVICES CONNECTOR]: SetAgentGroupInfo, requestingAgentID {0}, agentID {1}, groupID {2}, acceptNotices {3}, listInProfile {4}", + "[MOCK GROUPS SERVICES CONNECTOR]: SetAgentGroupInfo, requestingAgentID {0}, agentID {1}, groupID {2}, acceptNotices {3}, listInProfile {4}", requestingAgentID, agentID, groupID, acceptNotices, listInProfile); XGroup group = GetXGroup(groupID, null); @@ -228,7 +228,7 @@ namespace OpenSim.Tests.Common public void AddAgentToGroup(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID) { m_log.DebugFormat( - "[MOCK GROUPS SERVICES CONNECTOR]: AddAgentToGroup, requestingAgentID {0}, agentID {1}, groupID {2}, roleID {3}", + "[MOCK GROUPS SERVICES CONNECTOR]: AddAgentToGroup, requestingAgentID {0}, agentID {1}, groupID {2}, roleID {3}", requestingAgentID, agentID, groupID, roleID); XGroup group = GetXGroup(groupID, null); @@ -348,7 +348,7 @@ namespace OpenSim.Tests.Common return notices; } - + public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID) { m_log.DebugFormat( @@ -378,14 +378,14 @@ namespace OpenSim.Tests.Common return gni; } } - + return null; } - + public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) { m_log.DebugFormat( - "[MOCK GROUPS SERVICES CONNECTOR]: AddGroupNotice, requestingAgentID {0}, groupID {1}, noticeID {2}, fromName {3}, subject {4}, message {5}, binaryBucket.Length {6}", + "[MOCK GROUPS SERVICES CONNECTOR]: AddGroupNotice, requestingAgentID {0}, groupID {1}, noticeID {2}, fromName {3}, subject {4}, message {5}, binaryBucket.Length {6}", requestingAgentID, groupID, noticeID, fromName, subject, message, binaryBucket.Length); XGroup group = GetXGroup(groupID, null); diff --git a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs index 5df8e04..a73a0b8 100644 --- a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs @@ -74,6 +74,11 @@ namespace OpenSim.Data.Null m_store.StoreTerrain(terrain, regionID); } + public void StoreBakedTerrain(TerrainData terrain, UUID regionID) + { + m_store.StoreBakedTerrain(terrain, regionID); + } + public double[,] LoadTerrain(UUID regionID) { return m_store.LoadTerrain(regionID); @@ -84,6 +89,11 @@ namespace OpenSim.Data.Null return m_store.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ); } + public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) + { + return m_store.LoadBakedTerrain(regionID, pSizeX, pSizeY, pSizeZ); + } + public void StoreLandObject(ILandObject Parcel) { m_store.StoreLandObject(Parcel); @@ -138,6 +148,11 @@ namespace OpenSim.Data.Null m_store.RemoveRegionEnvironmentSettings(regionUUID); } + public UUID[] GetObjectIDs(UUID regionID) + { + return new UUID[0]; + } + public void SaveExtra(UUID regionID, string name, string value) { } @@ -159,14 +174,15 @@ namespace OpenSim.Data.Null public class NullDataStore : ISimulationDataStore { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + protected Dictionary m_regionSettings = new Dictionary(); protected Dictionary m_sceneObjectParts = new Dictionary(); - protected Dictionary> m_primItems + protected Dictionary> m_primItems = new Dictionary>(); protected Dictionary m_terrains = new Dictionary(); + protected Dictionary m_bakedterrains = new Dictionary(); protected Dictionary m_landData = new Dictionary(); - + public void Initialise(string dbfile) { return; @@ -180,14 +196,14 @@ namespace OpenSim.Data.Null { m_regionSettings[rs.RegionUUID] = rs; } - + public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) { //This connector doesn't support the windlight module yet //Return default LL windlight settings return new RegionLightShareData(); } - + public void RemoveRegionWindlightSettings(UUID regionID) { } @@ -222,7 +238,7 @@ namespace OpenSim.Data.Null if (rs == null) rs = new RegionSettings(); - + return rs; } @@ -234,9 +250,9 @@ namespace OpenSim.Data.Null foreach (SceneObjectPart prim in obj.Parts) { // m_log.DebugFormat( -// "[MOCK REGION DATA PLUGIN]: Storing part {0} {1} in object {2} {3} in region {4}", +// "[MOCK REGION DATA PLUGIN]: Storing part {0} {1} in object {2} {3} in region {4}", // prim.Name, prim.UUID, obj.Name, obj.UUID, regionUUID); - + m_sceneObjectParts[prim.UUID] = prim; } } @@ -250,7 +266,7 @@ namespace OpenSim.Data.Null if (part.ParentGroup.UUID == obj) { // m_log.DebugFormat( -// "[MOCK REGION DATA PLUGIN]: Removing part {0} {1} as part of object {2} from {3}", +// "[MOCK REGION DATA PLUGIN]: Removing part {0} {1} as part of object {2} from {3}", // part.Name, part.UUID, obj, regionUUID); m_sceneObjectParts.Remove(part.UUID); } @@ -265,7 +281,7 @@ namespace OpenSim.Data.Null public List LoadObjects(UUID regionUUID) { Dictionary objects = new Dictionary(); - + // Create all of the SOGs from the root prims first foreach (SceneObjectPart prim in m_sceneObjectParts.Values) { @@ -302,10 +318,10 @@ namespace OpenSim.Data.Null } } } - + // TODO: Load items. This is assymetric - we store items as a separate method but don't retrieve them that // way! - + return new List(objects.Values); } @@ -314,6 +330,11 @@ namespace OpenSim.Data.Null m_terrains[regionID] = ter; } + public void StoreBakedTerrain(TerrainData ter, UUID regionID) + { + m_bakedterrains[regionID] = ter; + } + public void StoreTerrain(double[,] ter, UUID regionID) { m_terrains[regionID] = new HeightmapTerrainData(ter); @@ -327,6 +348,14 @@ namespace OpenSim.Data.Null return null; } + public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) + { + if (m_bakedterrains.ContainsKey(regionID)) + return m_bakedterrains[regionID]; + else + return null; + } + public double[,] LoadTerrain(UUID regionID) { if (m_terrains.ContainsKey(regionID)) @@ -355,6 +384,11 @@ namespace OpenSim.Data.Null { } + public UUID[] GetObjectIDs(UUID regionID) + { + return new UUID[0]; + } + public void SaveExtra(UUID regionID, string name, string value) { } diff --git a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs index d7a144c..9d426f6 100644 --- a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs +++ b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs @@ -40,7 +40,7 @@ using OpenSim.Region.ScriptEngine.Shared; namespace OpenSim.Tests.Common { public class MockScriptEngine : INonSharedRegionModule, IScriptModule, IScriptEngine - { + { public IConfigSource ConfigSource { get; private set; } public IConfig Config { get; private set; } @@ -89,7 +89,7 @@ namespace OpenSim.Tests.Common { } - public string Name { get { return "Mock Script Engine"; } } + public string Name { get { return "Mock Script Engine"; } } public string ScriptEngineName { get { return Name; } } public Type ReplaceableInterface { get { return null; } } @@ -200,7 +200,7 @@ namespace OpenSim.Tests.Common { throw new System.NotImplementedException (); } - + public IScriptWorkItem QueueEventHandler(object parms) { throw new System.NotImplementedException (); @@ -221,7 +221,7 @@ namespace OpenSim.Tests.Common throw new System.NotImplementedException (); } - public void SetScriptState(UUID itemID, bool state) + public void SetScriptState(UUID itemID, bool state, bool self) { throw new System.NotImplementedException (); } @@ -258,7 +258,7 @@ namespace OpenSim.Tests.Common public string[] ScriptReferencedAssemblies { get { throw new System.NotImplementedException (); } } - public ParameterInfo[] ScriptBaseClassParameters { get { throw new System.NotImplementedException (); } } + public ParameterInfo[] ScriptBaseClassParameters { get { throw new System.NotImplementedException (); } } public void ClearPostedEvents() { diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 0e1bc8f..449716b 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -88,7 +88,7 @@ namespace OpenSim.Tests.Common public event MoneyTransferRequest OnMoneyTransferRequest; public event ParcelBuy OnParcelBuy; public event Action OnConnectionClosed; - + public event MoveItemsAndLeaveCopy OnMoveItemsAndLeaveCopy; public event ImprovedInstantMessage OnInstantMessage; public event ChatMessage OnChatFromClient; public event TextureRequest OnRequestTexture; @@ -105,6 +105,7 @@ namespace OpenSim.Tests.Common public event ObjectDrop OnObjectDrop; public event StartAnim OnStartAnim; public event StopAnim OnStopAnim; + public event ChangeAnim OnChangeAnim; public event LinkObjects OnLinkObjects; public event DelinkObjects OnDelinkObjects; public event RequestMapBlocks OnRequestMapBlocks; @@ -117,6 +118,7 @@ namespace OpenSim.Tests.Common public event SetAlwaysRun OnSetAlwaysRun; public event DeRezObject OnDeRezObject; + public event RezRestoreToWorld OnRezRestoreToWorld; public event Action OnRegionHandShakeReply; public event GenericCall1 OnRequestWearables; public event Action OnCompleteMovementToRegion; @@ -153,6 +155,7 @@ namespace OpenSim.Tests.Common public event GenericCall7 OnObjectMaterial; public event UpdatePrimFlags OnUpdatePrimFlags; public event UpdatePrimTexture OnUpdatePrimTexture; + public event ClientChangeObject onClientChangeObject; public event UpdateVector OnUpdatePrimGroupPosition; public event UpdateVector OnUpdatePrimSinglePosition; public event UpdatePrimRotation OnUpdatePrimGroupRotation; @@ -295,7 +298,7 @@ namespace OpenSim.Tests.Common public event ClassifiedInfoRequest OnClassifiedInfoRequest; public event ClassifiedInfoUpdate OnClassifiedInfoUpdate; public event ClassifiedDelete OnClassifiedDelete; - public event ClassifiedDelete OnClassifiedGodDelete; + public event ClassifiedGodDelete OnClassifiedGodDelete; public event EventNotificationAddRequest OnEventNotificationAddRequest; public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest; @@ -318,7 +321,7 @@ namespace OpenSim.Tests.Common public event AvatarInterestUpdate OnAvatarInterestUpdate; public event PlacesQuery OnPlacesQuery; - + public event FindAgentUpdate OnFindAgent; public event TrackAgentUpdate OnTrackAgent; public event NewUserReport OnUserReport; @@ -334,11 +337,12 @@ namespace OpenSim.Tests.Common public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest; public event SimWideDeletesDelegate OnSimWideDeletes; public event SendPostcard OnSendPostcard; + public event ChangeInventoryItemFlags OnChangeInventoryItemFlags; public event MuteListEntryUpdate OnUpdateMuteListEntry; public event MuteListEntryRemove OnRemoveMuteListEntry; public event GodlikeMessage onGodlikeMessage; public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate; - + public event GenericCall2 OnUpdateThrottles; #pragma warning restore 67 /// @@ -387,6 +391,8 @@ namespace OpenSim.Tests.Common get { return FirstName + " " + LastName; } } + public int PingTimeMS { get { return 0; } } + public bool IsActive { get { return true; } @@ -398,16 +404,19 @@ namespace OpenSim.Tests.Common public UUID ActiveGroupId { get { return UUID.Zero; } + set { } } public string ActiveGroupName { get { return String.Empty; } + set { } } public ulong ActiveGroupPowers { get { return 0; } + set { } } public bool IsGroupMember(UUID groupID) @@ -415,6 +424,13 @@ namespace OpenSim.Tests.Common return false; } + public Dictionary GetGroupPowers() + { + return new Dictionary(); + } + + public void SetGroupPowers(Dictionary powers) { } + public ulong GetGroupPowers(UUID groupID) { return 0; @@ -448,6 +464,8 @@ namespace OpenSim.Tests.Common get { return new IPEndPoint(IPAddress.Loopback, (ushort)m_circuitCode); } } + public List SelectedObjects {get; private set;} + /// /// Constructor /// @@ -570,10 +588,27 @@ namespace OpenSim.Tests.Common ReceivedKills.AddRange(localID); } + public void SendPartFullUpdate(ISceneEntity ent, uint? parentID) + { + } + public virtual void SetChildAgentThrottle(byte[] throttle) { } + public virtual void SetChildAgentThrottle(byte[] throttle, float factor) + { + } + + public void SetAgentThrottleSilent(int throttle, int setting) + { + } + + public int GetAgentThrottleSilent(int throttle) + { + return 0; + } + public byte[] GetThrottlesPacked(float multiplier) { return new byte[0]; @@ -608,6 +643,11 @@ namespace OpenSim.Tests.Common } + public virtual bool CanSendLayerData() + { + return false; + } + public virtual void SendLayerData(float[] map) { } @@ -619,9 +659,9 @@ namespace OpenSim.Tests.Common { } - public virtual void SendWindData(Vector2[] windSpeeds) { } + public virtual void SendWindData(int version, Vector2[] windSpeeds) { } - public virtual void SendCloudData(float[] cloudCover) { } + public virtual void SendCloudData(int version, float[] cloudCover) { } public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) { @@ -633,7 +673,7 @@ namespace OpenSim.Tests.Common { AgentCircuitData agentData = new AgentCircuitData(); agentData.AgentID = AgentId; - agentData.SessionID = SessionId; + agentData.SessionID = SessionId; agentData.SecureSessionID = UUID.Zero; agentData.circuitcode = m_circuitCode; agentData.child = false; @@ -673,7 +713,7 @@ namespace OpenSim.Tests.Common public virtual void SendTeleportFailed(string reason) { m_log.DebugFormat( - "[TEST CLIENT]: Teleport failed for {0} {1} on {2} with reason {3}", + "[TEST CLIENT]: Teleport failed for {0} {1} on {2} with reason {3}", m_firstName, m_lastName, m_scene.Name, reason); } @@ -720,7 +760,11 @@ namespace OpenSim.Tests.Common { } - public void SendAvatarDataImmediate(ISceneEntity avatar) + public void SendEntityFullUpdateImmediate(ISceneEntity ent) + { + } + + public void SendEntityTerseUpdateImmediate(ISceneEntity ent) { } @@ -741,7 +785,7 @@ namespace OpenSim.Tests.Common public virtual void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List items, List folders, - int version, + int version, bool fetchFolders, bool fetchItems) { @@ -755,6 +799,10 @@ namespace OpenSim.Tests.Common { } + public void SendInventoryItemCreateUpdate(InventoryItemBase Item, UUID transactionID, uint callbackId) + { + } + public virtual void SendRemoveInventoryItem(UUID itemID) { } @@ -771,7 +819,7 @@ namespace OpenSim.Tests.Common { } - public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data) + public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory) { } @@ -817,6 +865,10 @@ namespace OpenSim.Tests.Common { } + public void SendAlertMessage(string message, string info) + { + } + public void SendSystemAlertMessage(string message) { } @@ -833,7 +885,7 @@ namespace OpenSim.Tests.Common OnRegionHandShakeReply(this); } } - + public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) { } @@ -910,8 +962,13 @@ namespace OpenSim.Tests.Common ReceivedOnlineNotifications.AddRange(agentIDs); } - public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, - Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook) + public void SendFindAgent(UUID HunterID, UUID PreyID, double GlobalX, double GlobalY) + { + } + + public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, + Quaternion SitOrientation, bool autopilot, + Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook) { } @@ -937,7 +994,7 @@ namespace OpenSim.Tests.Common { } - public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember, + public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] membershipType, string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID) { @@ -966,10 +1023,10 @@ namespace OpenSim.Tests.Common public void Close() { - Close(false); + Close(true, false); } - public void Close(bool force) + public void Close(bool sendStop, bool force) { // Fire the callback for this connection closing // This is necesary to get the presence detector to notice that a client has logged out. @@ -1175,6 +1232,10 @@ namespace OpenSim.Tests.Common { } + public void SendAgentGroupDataUpdate(UUID avatarID, GroupMembershipData[] data) + { + } + public void SendJoinGroupReply(UUID groupID, bool success) { } @@ -1238,14 +1299,30 @@ namespace OpenSim.Tests.Common { } + public void UpdateGroupMembership(GroupMembershipData[] data) + { + } + + public void GroupMembershipRemove(UUID GroupID) + { + } + + public void GroupMembershipAddReplace(UUID GroupID,ulong GroupPowers) + { + } + public void SendUseCachedMuteList() { } + public void SendEmpytMuteList() + { + } + public void SendMuteListUpdate(string filename) { } - + public void SendPickInfoReply(UUID pickID,UUID creatorID, bool topPick, UUID parcelID, string name, string desc, UUID snapshotID, string user, string originalName, string simName, Vector3 posGlobal, int sortOrder, bool enabled) { } @@ -1265,7 +1342,7 @@ namespace OpenSim.Tests.Common { } - public void Disconnect() + public void Disconnect() { } @@ -1274,19 +1351,19 @@ namespace OpenSim.Tests.Common if (OnReceivedSendRebakeAvatarTextures != null) OnReceivedSendRebakeAvatarTextures(textureID); } - + public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages) { } - + public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt) { } - + public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier) { } - + public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID,int amt) { } @@ -1315,9 +1392,12 @@ namespace OpenSim.Tests.Common { } - public void SendPartPhysicsProprieties(ISceneEntity entity) + public void SendSelectedPartsProprieties(List parts) { } + public void SendPartPhysicsProprieties(ISceneEntity entity) + { + } } } diff --git a/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs index f2bae58..f2ce064 100644 --- a/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs +++ b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs @@ -46,7 +46,7 @@ namespace OpenSim.Tests.Common { public class TestEventQueueGetModule : IEventQueue, INonSharedRegionModule { - public class Event + public class Event { public string Name { get; set; } public object[] Args { get; set; } @@ -64,7 +64,7 @@ namespace OpenSim.Tests.Common public void Close() {} - public void AddRegion(Scene scene) + public void AddRegion(Scene scene) { Events = new Dictionary>(); scene.RegisterModuleInterface(this); @@ -108,12 +108,12 @@ namespace OpenSim.Tests.Common AddEvent(avatarID, "Enqueue", o); return true; } - +/* public void DisableSimulator(ulong handle, UUID avatarID) { AddEvent(avatarID, "DisableSimulator", handle); } - +*/ public void EnableSimulator (ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY) { AddEvent(avatarID, "EnableSimulator", handle); @@ -138,18 +138,23 @@ namespace OpenSim.Tests.Common } public void ChatterboxInvitation( - UUID sessionID, string sessionName, UUID fromAgent, string message, UUID toAgent, string fromName, - byte dialog, uint timeStamp, bool offline, int parentEstateID, Vector3 position, uint ttl, + UUID sessionID, string sessionName, UUID fromAgent, string message, UUID toAgent, string fromName, + byte dialog, uint timeStamp, bool offline, int parentEstateID, Vector3 position, uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket) { AddEvent( - toAgent, "ChatterboxInvitation", sessionID, sessionName, fromAgent, message, toAgent, fromName, dialog, + toAgent, "ChatterboxInvitation", sessionID, sessionName, fromAgent, message, toAgent, fromName, dialog, timeStamp, offline, parentEstateID, position, ttl, transactionID, fromGroup, binaryBucket); } - public void ChatterBoxSessionAgentListUpdates (UUID sessionID, UUID fromAgent, UUID toAgent, bool canVoiceChat, bool isModerator, bool textMute) + public void ChatterBoxSessionAgentListUpdates (UUID sessionID, UUID fromAgent, UUID toAgent, bool canVoiceChat, bool isModerator, bool textMute , bool isEnterorLeave) + { + AddEvent(toAgent, "ChatterBoxSessionAgentListUpdates", sessionID, fromAgent, canVoiceChat, isModerator, textMute, isEnterorLeave); + } + + public void ChatterBoxForceClose (UUID toAgent, UUID sessionID, string reason) { - AddEvent(toAgent, "ChatterBoxSessionAgentListUpdates", sessionID, fromAgent, canVoiceChat, isModerator, textMute); + AddEvent(toAgent, "ForceCloseChatterBoxSession", sessionID, reason); } public void ParcelProperties (OpenMetaverse.Messages.Linden.ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID) @@ -157,9 +162,9 @@ namespace OpenSim.Tests.Common AddEvent(avatarID, "ParcelProperties", parcelPropertiesMessage); } - public void GroupMembership (OpenMetaverse.Packets.AgentGroupDataUpdatePacket groupUpdate, UUID avatarID) + public void GroupMembershipData(UUID receiverAgent, GroupMembershipData[] data) { - AddEvent(avatarID, "GroupMembership", groupUpdate); + AddEvent(receiverAgent, "AgentGroupDataUpdate", data); } public OSD ScriptRunningEvent (UUID objectID, UUID itemID, bool running, bool mono) diff --git a/OpenSim/Tests/Common/Mock/TestGroupsDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestGroupsDataPlugin.cs new file mode 100644 index 0000000..8e2d8e6 --- /dev/null +++ b/OpenSim/Tests/Common/Mock/TestGroupsDataPlugin.cs @@ -0,0 +1,339 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using OpenMetaverse; +using OpenSim.Data; + +namespace OpenSim.Tests.Common.Mock +{ + public class TestGroupsDataPlugin : IGroupsData + { + class CompositeKey + { + private readonly string _key; + public string Key + { + get { return _key; } + } + + public CompositeKey(UUID _k1, string _k2) + { + _key = _k1.ToString() + _k2; + } + + public CompositeKey(UUID _k1, string _k2, string _k3) + { + _key = _k1.ToString() + _k2 + _k3; + } + + public override bool Equals(object obj) + { + if (obj is CompositeKey) + { + return Key == ((CompositeKey)obj).Key; + } + return false; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + + public override string ToString() + { + return Key; + } + } + + private Dictionary m_Groups; + private Dictionary m_Membership; + private Dictionary m_Roles; + private Dictionary m_RoleMembership; + private Dictionary m_Invites; + private Dictionary m_Notices; + private Dictionary m_Principals; + + public TestGroupsDataPlugin(string connectionString, string realm) + { + m_Groups = new Dictionary(); + m_Membership = new Dictionary(); + m_Roles = new Dictionary(); + m_RoleMembership = new Dictionary(); + m_Invites = new Dictionary(); + m_Notices = new Dictionary(); + m_Principals = new Dictionary(); + } + + #region groups table + public bool StoreGroup(GroupData data) + { + return false; + } + + public GroupData RetrieveGroup(UUID groupID) + { + if (m_Groups.ContainsKey(groupID)) + return m_Groups[groupID]; + + return null; + } + + public GroupData RetrieveGroup(string name) + { + return m_Groups.Values.First(g => g.Data.ContainsKey("Name") && g.Data["Name"] == name); + } + + public GroupData[] RetrieveGroups(string pattern) + { + if (string.IsNullOrEmpty(pattern)) + pattern = "1"; + + IEnumerable groups = m_Groups.Values.Where(g => g.Data.ContainsKey("Name") && (g.Data["Name"].StartsWith(pattern) || g.Data["Name"].EndsWith(pattern))); + + return (groups != null) ? groups.ToArray() : new GroupData[0]; + } + + public bool DeleteGroup(UUID groupID) + { + return m_Groups.Remove(groupID); + } + + public int GroupsCount() + { + return m_Groups.Count; + } + #endregion + + #region membership table + public MembershipData RetrieveMember(UUID groupID, string pricipalID) + { + CompositeKey dkey = new CompositeKey(groupID, pricipalID); + if (m_Membership.ContainsKey(dkey)) + return m_Membership[dkey]; + + return null; + } + + public MembershipData[] RetrieveMembers(UUID groupID) + { + IEnumerable keys = m_Membership.Keys.Where(k => k.Key.StartsWith(groupID.ToString())); + return keys.Where(m_Membership.ContainsKey).Select(x => m_Membership[x]).ToArray(); + } + + public MembershipData[] RetrieveMemberships(string principalID) + { + IEnumerable keys = m_Membership.Keys.Where(k => k.Key.EndsWith(principalID.ToString())); + return keys.Where(m_Membership.ContainsKey).Select(x => m_Membership[x]).ToArray(); + } + + public MembershipData[] RetrievePrincipalGroupMemberships(string principalID) + { + return RetrieveMemberships(principalID); + } + + public MembershipData RetrievePrincipalGroupMembership(string principalID, UUID groupID) + { + CompositeKey dkey = new CompositeKey(groupID, principalID); + if (m_Membership.ContainsKey(dkey)) + return m_Membership[dkey]; + return null; + } + + public bool StoreMember(MembershipData data) + { + CompositeKey dkey = new CompositeKey(data.GroupID, data.PrincipalID); + m_Membership[dkey] = data; + return true; + } + + public bool DeleteMember(UUID groupID, string principalID) + { + CompositeKey dkey = new CompositeKey(groupID, principalID); + if (m_Membership.ContainsKey(dkey)) + return m_Membership.Remove(dkey); + + return false; + } + + public int MemberCount(UUID groupID) + { + return m_Membership.Count; + } + #endregion + + #region roles table + public bool StoreRole(RoleData data) + { + CompositeKey dkey = new CompositeKey(data.GroupID, data.RoleID.ToString()); + m_Roles[dkey] = data; + return true; + } + + public RoleData RetrieveRole(UUID groupID, UUID roleID) + { + CompositeKey dkey = new CompositeKey(groupID, roleID.ToString()); + if (m_Roles.ContainsKey(dkey)) + return m_Roles[dkey]; + + return null; + } + + public RoleData[] RetrieveRoles(UUID groupID) + { + IEnumerable keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString())); + return keys.Where(m_Roles.ContainsKey).Select(x => m_Roles[x]).ToArray(); + } + + public bool DeleteRole(UUID groupID, UUID roleID) + { + CompositeKey dkey = new CompositeKey(groupID, roleID.ToString()); + if (m_Roles.ContainsKey(dkey)) + return m_Roles.Remove(dkey); + + return false; + } + + public int RoleCount(UUID groupID) + { + return m_Roles.Count; + } + #endregion + + #region rolememberhip table + public RoleMembershipData[] RetrieveRolesMembers(UUID groupID) + { + IEnumerable keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString())); + return keys.Where(m_RoleMembership.ContainsKey).Select(x => m_RoleMembership[x]).ToArray(); + } + + public RoleMembershipData[] RetrieveRoleMembers(UUID groupID, UUID roleID) + { + IEnumerable keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString() + roleID.ToString())); + return keys.Where(m_RoleMembership.ContainsKey).Select(x => m_RoleMembership[x]).ToArray(); + } + + public RoleMembershipData[] RetrieveMemberRoles(UUID groupID, string principalID) + { + IEnumerable keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString()) && k.Key.EndsWith(principalID)); + return keys.Where(m_RoleMembership.ContainsKey).Select(x => m_RoleMembership[x]).ToArray(); + } + + public RoleMembershipData RetrieveRoleMember(UUID groupID, UUID roleID, string principalID) + { + CompositeKey dkey = new CompositeKey(groupID, roleID.ToString(), principalID); + if (m_RoleMembership.ContainsKey(dkey)) + return m_RoleMembership[dkey]; + + return null; + } + + public int RoleMemberCount(UUID groupID, UUID roleID) + { + return m_RoleMembership.Count; + } + + public bool StoreRoleMember(RoleMembershipData data) + { + CompositeKey dkey = new CompositeKey(data.GroupID, data.RoleID.ToString(), data.PrincipalID); + m_RoleMembership[dkey] = data; + return true; + } + + public bool DeleteRoleMember(RoleMembershipData data) + { + CompositeKey dkey = new CompositeKey(data.GroupID, data.RoleID.ToString(), data.PrincipalID); + if (m_RoleMembership.ContainsKey(dkey)) + return m_RoleMembership.Remove(dkey); + + return false; + } + + public bool DeleteMemberAllRoles(UUID groupID, string principalID) + { + List keys = m_RoleMembership.Keys.Where(k => k.Key.StartsWith(groupID.ToString()) && k.Key.EndsWith(principalID)).ToList(); + foreach (CompositeKey k in keys) + m_RoleMembership.Remove(k); + return true; + } + #endregion + + #region principals table + public bool StorePrincipal(PrincipalData data) + { + m_Principals[data.PrincipalID] = data; + return true; + } + + public PrincipalData RetrievePrincipal(string principalID) + { + if (m_Principals.ContainsKey(principalID)) + return m_Principals[principalID]; + + return null; + } + + public bool DeletePrincipal(string principalID) + { + if (m_Principals.ContainsKey(principalID)) + return m_Principals.Remove(principalID); + return false; + } + #endregion + + #region invites table + public bool StoreInvitation(InvitationData data) + { + return false; + } + + public InvitationData RetrieveInvitation(UUID inviteID) + { + return null; + } + + public InvitationData RetrieveInvitation(UUID groupID, string principalID) + { + return null; + } + + public bool DeleteInvite(UUID inviteID) + { + return false; + } + + public void DeleteOldInvites() + { + } + #endregion + + #region notices table + public bool StoreNotice(NoticeData data) + { + return false; + } + + public NoticeData RetrieveNotice(UUID noticeID) + { + return null; + } + + public NoticeData[] RetrieveNotices(UUID groupID) + { + return new NoticeData[0]; + } + + public bool DeleteNotice(UUID noticeID) + { + return false; + } + + public void DeleteOldNotices() + { + } + #endregion + + } +} diff --git a/OpenSim/Tests/Common/Mock/TestHttpClientContext.cs b/OpenSim/Tests/Common/Mock/TestHttpClientContext.cs index 5a55b09..7b20b8c 100644 --- a/OpenSim/Tests/Common/Mock/TestHttpClientContext.cs +++ b/OpenSim/Tests/Common/Mock/TestHttpClientContext.cs @@ -36,13 +36,14 @@ using OpenSim.Framework; namespace OpenSim.Tests.Common { +/* public class TestHttpClientContext: IHttpClientContext { /// /// Bodies of responses from the server. /// public string ResponseBody - { + { get { return Encoding.UTF8.GetString(m_responseStream.ToArray()); } } @@ -55,8 +56,8 @@ namespace OpenSim.Tests.Common public bool IsSecured { get; set; } - public bool Secured - { + public bool Secured + { get { return IsSecured; } set { IsSecured = value; } } @@ -66,7 +67,7 @@ namespace OpenSim.Tests.Common Secured = secured; } - public void Disconnect(SocketError error) + public void Disconnect(SocketError error) { // Console.WriteLine("TestHttpClientContext.Disconnect Received disconnect with status {0}", error); } @@ -75,18 +76,18 @@ namespace OpenSim.Tests.Common public void Respond(string httpVersion, HttpStatusCode statusCode, string reason) {Console.WriteLine("xx");} public void Respond(string body) { Console.WriteLine("xxx");} - public void Send(byte[] buffer) + public void Send(byte[] buffer) { // Getting header data here // Console.WriteLine("xxxx: Got {0}", Encoding.UTF8.GetString(buffer)); } - public void Send(byte[] buffer, int offset, int size) + public void Send(byte[] buffer, int offset, int size) { // Util.PrintCallStack(); // // Console.WriteLine( -// "TestHttpClientContext.Send(byte[], int, int) got offset={0}, size={1}, buffer={2}", +// "TestHttpClientContext.Send(byte[], int, int) got offset={0}, size={1}, buffer={2}", // offset, size, Encoding.UTF8.GetString(buffer)); m_responseStream.Write(buffer, offset, size); @@ -107,4 +108,5 @@ namespace OpenSim.Tests.Common /// public event EventHandler RequestReceived = delegate { }; } +*/ } \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/TestHttpRequest.cs b/OpenSim/Tests/Common/Mock/TestHttpRequest.cs index b868895..4c5ea4a 100644 --- a/OpenSim/Tests/Common/Mock/TestHttpRequest.cs +++ b/OpenSim/Tests/Common/Mock/TestHttpRequest.cs @@ -33,88 +33,89 @@ using HttpServer.FormDecoders; namespace OpenSim.Tests.Common { +/* public class TestHttpRequest: IHttpRequest { private string _uriPath; - public bool BodyIsComplete - { - get { return true; } + public bool BodyIsComplete + { + get { return true; } } - public string[] AcceptTypes - { + public string[] AcceptTypes + { get {return _acceptTypes; } } private string[] _acceptTypes; - public Stream Body - { - get { return _body; } - set { _body = value;} + public Stream Body + { + get { return _body; } + set { _body = value;} } private Stream _body; - public ConnectionType Connection - { + public ConnectionType Connection + { get { return _connection; } set { _connection = value; } } private ConnectionType _connection; - public int ContentLength - { + public int ContentLength + { get { return _contentLength; } set { _contentLength = value; } } private int _contentLength; - public NameValueCollection Headers - { + public NameValueCollection Headers + { get { return _headers; } } private NameValueCollection _headers = new NameValueCollection(); public string HttpVersion { get; set; } - public string Method - { + public string Method + { get { return _method; } set { _method = value; } } private string _method = null; - public HttpInput QueryString - { + public HttpInput QueryString + { get { return _queryString; } } private HttpInput _queryString = null; - public Uri Uri - { + public Uri Uri + { get { return _uri; } - set { _uri = value; } + set { _uri = value; } } private Uri _uri = null; - public string[] UriParts - { + public string[] UriParts + { get { return _uri.Segments; } } - public HttpParam Param - { - get { return null; } + public HttpParam Param + { + get { return null; } } - public HttpForm Form - { - get { return null; } + public HttpForm Form + { + get { return null; } } - public bool IsAjax - { - get { return false; } + public bool IsAjax + { + get { return false; } } - public RequestCookies Cookies - { - get { return null; } + public RequestCookies Cookies + { + get { return null; } } - public TestHttpRequest() + public TestHttpRequest() { HttpVersion = "HTTP/1.1"; } - public TestHttpRequest(string contentEncoding, string contentType, string userAgent, + public TestHttpRequest(string contentEncoding, string contentType, string userAgent, string remoteAddr, string remotePort, string[] acceptTypes, ConnectionType connectionType, int contentLength, Uri uri) : base() { @@ -136,7 +137,7 @@ namespace OpenSim.Tests.Common { _headers.Add(name, value); } - public int AddToBody(byte[] bytes, int offset, int length) + public int AddToBody(byte[] bytes, int offset, int length) { return 0; } @@ -167,8 +168,9 @@ namespace OpenSim.Tests.Common set { _uriPath = value; - + } } } +*/ } \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/TestHttpResponse.cs b/OpenSim/Tests/Common/Mock/TestHttpResponse.cs index ff47c10..190f6d5 100644 --- a/OpenSim/Tests/Common/Mock/TestHttpResponse.cs +++ b/OpenSim/Tests/Common/Mock/TestHttpResponse.cs @@ -33,9 +33,10 @@ using HttpServer; namespace OpenSim.Tests.Common { +/* public class TestHttpResponse: IHttpResponse { - public Stream Body + public Stream Body { get { return _body; } @@ -43,14 +44,14 @@ namespace OpenSim.Tests.Common } private Stream _body; - public string ProtocolVersion - { + public string ProtocolVersion + { get { return _protocolVersion; } set { _protocolVersion = value; } } private string _protocolVersion; - public bool Chunked + public bool Chunked { get { return _chunked; } @@ -58,7 +59,7 @@ namespace OpenSim.Tests.Common } private bool _chunked; - public ConnectionType Connection + public ConnectionType Connection { get { return _connection; } @@ -66,7 +67,7 @@ namespace OpenSim.Tests.Common } private ConnectionType _connection; - public Encoding Encoding + public Encoding Encoding { get { return _encoding; } @@ -74,7 +75,7 @@ namespace OpenSim.Tests.Common } private Encoding _encoding; - public int KeepAlive + public int KeepAlive { get { return _keepAlive; } @@ -82,7 +83,7 @@ namespace OpenSim.Tests.Common } private int _keepAlive; - public HttpStatusCode Status + public HttpStatusCode Status { get { return _status; } @@ -90,7 +91,7 @@ namespace OpenSim.Tests.Common } private HttpStatusCode _status; - public string Reason + public string Reason { get { return _reason; } @@ -98,7 +99,7 @@ namespace OpenSim.Tests.Common } private string _reason; - public long ContentLength + public long ContentLength { get { return _contentLength; } @@ -106,7 +107,7 @@ namespace OpenSim.Tests.Common } private long _contentLength; - public string ContentType + public string ContentType { get { return _contentType; } @@ -114,19 +115,19 @@ namespace OpenSim.Tests.Common } private string _contentType; - public bool HeadersSent + public bool HeadersSent { get { return _headersSent; } } private bool _headersSent; - public bool Sent + public bool Sent { get { return _sent; } } private bool _sent; - public ResponseCookies Cookies + public ResponseCookies Cookies { get { return _cookies; } } @@ -140,26 +141,26 @@ namespace OpenSim.Tests.Common public void AddHeader(string name, string value) {} - public void Send() + public void Send() { if (!_headersSent) SendHeaders(); if (_sent) throw new InvalidOperationException("stuff already sent"); _sent = true; } - public void SendBody(byte[] buffer, int offset, int count) + public void SendBody(byte[] buffer, int offset, int count) { if (!_headersSent) SendHeaders(); _sent = true; } - public void SendBody(byte[] buffer) + public void SendBody(byte[] buffer) { if (!_headersSent) SendHeaders(); _sent = true; } - public void SendHeaders() + public void SendHeaders() { if (_headersSent) throw new InvalidOperationException("headers already sent"); _headersSent = true; @@ -168,4 +169,5 @@ namespace OpenSim.Tests.Common public void Redirect(Uri uri) {} public void Redirect(string url) {} } +*/ } \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs index c97a765..0ff6f7f 100644 --- a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs @@ -43,7 +43,7 @@ namespace OpenSim.Tests.Common public class TestInventoryDataPlugin : IInventoryDataPlugin { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + /// /// Inventory folders /// @@ -85,9 +85,9 @@ namespace OpenSim.Tests.Common public List getInventoryInFolder(UUID folderID) { // InventoryFolderBase folder = m_folders[folderID]; - + // m_log.DebugFormat("[MOCK INV DB]: Getting items in folder {0} {1}", folder.Name, folder.ID); - + List items = new List(); foreach (InventoryItemBase item in m_items.Values) @@ -98,7 +98,7 @@ namespace OpenSim.Tests.Common items.Add(item); } } - + return items; } @@ -107,7 +107,7 @@ namespace OpenSim.Tests.Common public InventoryFolderBase getUserRootFolder(UUID user) { // m_log.DebugFormat("[MOCK INV DB]: Looking for root folder for {0}", user); - + InventoryFolderBase folder = null; m_rootFolders.TryGetValue(user, out folder); @@ -117,9 +117,9 @@ namespace OpenSim.Tests.Common public List getInventoryFolders(UUID parentID) { // InventoryFolderBase parentFolder = m_folders[parentID]; - + // m_log.DebugFormat("[MOCK INV DB]: Getting folders in folder {0} {1}", parentFolder.Name, parentFolder.ID); - + List folders = new List(); foreach (InventoryFolderBase folder in m_folders.Values) @@ -127,9 +127,9 @@ namespace OpenSim.Tests.Common if (folder.ParentID == parentID) { // m_log.DebugFormat( -// "[MOCK INV DB]: Found folder {0} {1} in {2} {3}", +// "[MOCK INV DB]: Found folder {0} {1} in {2} {3}", // folder.Name, folder.ID, parentFolder.Name, parentFolder.ID); - + folders.Add(folder); } } @@ -153,9 +153,9 @@ namespace OpenSim.Tests.Common public void addInventoryFolder(InventoryFolderBase folder) { // m_log.DebugFormat( -// "[MOCK INV DB]: Adding inventory folder {0} {1} type {2}", +// "[MOCK INV DB]: Adding inventory folder {0} {1} type {2}", // folder.Name, folder.ID, (AssetType)folder.Type); - + m_folders[folder.ID] = folder; if (folder.ParentID == UUID.Zero) @@ -183,30 +183,30 @@ namespace OpenSim.Tests.Common m_folders.Remove(folderId); } - public void addInventoryItem(InventoryItemBase item) + public void addInventoryItem(InventoryItemBase item) { InventoryFolderBase folder = m_folders[item.Folder]; - + // m_log.DebugFormat( // "[MOCK INV DB]: Adding inventory item {0} {1} in {2} {3}", item.Name, item.ID, folder.Name, folder.ID); - + m_items[item.ID] = item; } - + public void updateInventoryItem(InventoryItemBase item) { addInventoryItem(item); } - - public void deleteInventoryItem(UUID itemId) + + public void deleteInventoryItem(UUID itemId) { if (m_items.ContainsKey(itemId)) m_items.Remove(itemId); } - - public InventoryItemBase getInventoryItem(UUID itemId) + + public InventoryItemBase getInventoryItem(UUID itemId) { if (m_items.ContainsKey(itemId)) return m_items[itemId]; else - return null; + return null; } public InventoryItemBase queryInventoryItem(UUID item) diff --git a/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs b/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs index 26887c9..388b56b 100644 --- a/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs +++ b/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs @@ -43,8 +43,8 @@ namespace OpenSim.Tests.Common { public List PacketsSent { get; private set; } - public TestLLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) - : base(listenIP, ref port, proxyPortOffsetParm, allow_alternate_port, configSource, circuitManager) + public TestLLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, IConfigSource configSource, AgentCircuitManager circuitManager) + : base(listenIP, ref port, proxyPortOffsetParm, configSource, circuitManager) { PacketsSent = new List(); } @@ -73,7 +73,7 @@ namespace OpenSim.Tests.Common //// /// The chunks of data to pass to the LLUDPServer when it calls EndReceive //// /// //// protected Queue m_chunksToLoad = new Queue(); -// +// //// protected override void BeginReceive() //// { //// if (m_chunksToLoad.Count > 0 && m_chunksToLoad.Peek().BeginReceiveException) @@ -83,29 +83,29 @@ namespace OpenSim.Tests.Common //// throw new SocketException(); //// } //// } -// +// //// protected override bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender) //// { //// numBytes = 0; //// //// //m_log.Debug("Queue size " + m_chunksToLoad.Count); -//// +//// //// if (m_chunksToLoad.Count <= 0) //// return false; -//// +//// //// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue(); //// RecvBuffer = tuple.Data; //// numBytes = tuple.Data.Length; //// epSender = tuple.Sender; -//// +//// //// return true; //// } -// +// //// public override void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) //// { //// // Don't do anything just yet //// } -// +// // /// // /// Signal that this chunk should throw an exception on Socket.BeginReceive() // /// @@ -116,7 +116,7 @@ namespace OpenSim.Tests.Common // tuple.BeginReceiveException = true; // m_chunksToLoad.Enqueue(tuple); // } -// +// // /// // /// Load some data to be received by the LLUDPServer on the next receive call // /// @@ -126,7 +126,7 @@ namespace OpenSim.Tests.Common // { // m_chunksToLoad.Enqueue(new ChunkSenderTuple(data, epSender)); // } -// +// // /// // /// Load a packet to be received by the LLUDPServer on the next receive call // /// @@ -135,7 +135,7 @@ namespace OpenSim.Tests.Common // { // LoadReceive(packet.ToBytes(), epSender); // } -// +// // /// // /// Calls the protected asynchronous result method. This fires out all data chunks currently queued for send // /// @@ -147,7 +147,7 @@ namespace OpenSim.Tests.Common //// OnReceivedData(result); // } } - + /// /// Record the data and sender tuple /// @@ -156,13 +156,13 @@ namespace OpenSim.Tests.Common public byte[] Data; public EndPoint Sender; public bool BeginReceiveException; - + public ChunkSenderTuple(byte[] data, EndPoint sender) { Data = data; Sender = sender; } - + public ChunkSenderTuple(EndPoint sender) { Sender = sender; diff --git a/OpenSim/Tests/Common/Mock/TestLandChannel.cs b/OpenSim/Tests/Common/Mock/TestLandChannel.cs index 89ebcd5..05db03fe 100644 --- a/OpenSim/Tests/Common/Mock/TestLandChannel.cs +++ b/OpenSim/Tests/Common/Mock/TestLandChannel.cs @@ -65,7 +65,7 @@ namespace OpenSim.Tests.Common { return m_parcels; } - + public void Clear(bool setupDefaultParcel) { m_parcels.Clear(); @@ -96,6 +96,11 @@ namespace OpenSim.Tests.Common return GetNoLand(); } + public ILandObject GetLandObject(UUID ID) + { + return GetNoLand(); + } + public ILandObject GetLandObject(float x, float y) { return GetNoLand(); @@ -104,6 +109,7 @@ namespace OpenSim.Tests.Common public bool IsLandPrimCountTainted() { return false; } public bool IsForcefulBansAllowed() { return false; } public void UpdateLandObject(int localID, LandData data) {} + public void SendParcelsOverlay(IClientAPI client) {} public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) {} public void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel) {} public void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel) {} @@ -111,5 +117,6 @@ namespace OpenSim.Tests.Common public void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id) {} public void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id) {} + public void sendClientInitialLandInfo(IClientAPI remoteClient) { } } } \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/TestScene.cs b/OpenSim/Tests/Common/Mock/TestScene.cs index 1a93c9f..0b3d446 100644 --- a/OpenSim/Tests/Common/Mock/TestScene.cs +++ b/OpenSim/Tests/Common/Mock/TestScene.cs @@ -41,7 +41,7 @@ namespace OpenSim.Tests.Common public class TestScene : Scene { public TestScene( - RegionInfo regInfo, AgentCircuitManager authen, + RegionInfo regInfo, AgentCircuitManager authen, ISimulationDataService simDataService, IEstateDataService estateDataService, IConfigSource config, string simulatorVersion) : base(regInfo, authen, simDataService, estateDataService, @@ -54,7 +54,7 @@ namespace OpenSim.Tests.Common //Console.WriteLine("TestScene destructor called for {0}", RegionInfo.RegionName); Console.WriteLine("TestScene destructor called"); } - + /// /// Temporarily override session authentication for tests (namely teleport). /// @@ -68,7 +68,7 @@ namespace OpenSim.Tests.Common reason = String.Empty; return true; } - + public AsyncSceneObjectGroupDeleter SceneObjectGroupDeleter { get { return m_asyncSceneObjectDeleter; } diff --git a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs index 2b272e6..77f1793 100644 --- a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs @@ -89,7 +89,7 @@ namespace OpenSim.Tests.Common m_allItems[item.inventoryID] = item.Clone(); // Console.WriteLine( -// "Added item {0} {1}, folder {2}, creator {3}, owner {4}", +// "Added item {0} {1}, folder {2}, creator {3}, owner {4}", // item.inventoryName, item.inventoryID, item.parentFolderID, item.creatorID, item.avatarID); return true; @@ -123,8 +123,8 @@ namespace OpenSim.Tests.Common public bool MoveItem(string id, string newParent) { throw new NotImplementedException(); } - public bool MoveFolder(string id, string newParent) - { + public bool MoveFolder(string id, string newParent) + { // Don't use GetFolders() here - it takes a clone! XInventoryFolder folder = m_allFolders[new UUID(id)]; @@ -133,11 +133,11 @@ namespace OpenSim.Tests.Common folder.parentFolderID = new UUID(newParent); -// XInventoryFolder[] newParentFolders +// XInventoryFolder[] newParentFolders // = GetFolders(new string[] { "folderID" }, new string[] { folder.parentFolderID.ToString() }); // Console.WriteLine( -// "Moved folder {0} {1}, to {2} {3}", +// "Moved folder {0} {1}, to {2} {3}", // folder.folderName, folder.folderID, newParentFolders[0].folderName, folder.parentFolderID); // TODO: Really need to implement folder version incrementing, though this should be common code anyway, diff --git a/OpenSim/Tests/Common/TestHelpers.cs b/OpenSim/Tests/Common/TestHelpers.cs index 6bf23f8..2b2af34 100644 --- a/OpenSim/Tests/Common/TestHelpers.cs +++ b/OpenSim/Tests/Common/TestHelpers.cs @@ -81,9 +81,9 @@ namespace OpenSim.Tests.Common return false; } - + /// - /// A debugging method that can be used to print out which test method you are in + /// A debugging method that can be used to print out which test method you are in /// public static void InMethod() { @@ -129,7 +129,7 @@ namespace OpenSim.Tests.Common { string rawUuid = stem.PadRight(32, '0'); - return UUID.Parse(rawUuid); + return UUID.Parse(rawUuid); } /// @@ -158,7 +158,7 @@ namespace OpenSim.Tests.Common { string rawUuid = stem.PadLeft(32, '0'); - return UUID.Parse(rawUuid); + return UUID.Parse(rawUuid); } } } diff --git a/OpenSim/Tests/Performance/NPCPerformanceTests.cs b/OpenSim/Tests/Performance/NPCPerformanceTests.cs index ca6ae42..e41f5d1 100644 --- a/OpenSim/Tests/Performance/NPCPerformanceTests.cs +++ b/OpenSim/Tests/Performance/NPCPerformanceTests.cs @@ -143,8 +143,7 @@ namespace OpenSim.Tests.Performance // ScenePresence.SendInitialData() to reset our entire appearance. scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId)); -/* - afm.SetAppearance(sp, originalTe, null); + afm.SetAppearance(sp, originalTe, null, new WearableCacheItem[0]); INPCModule npcModule = scene.RequestModuleInterface(); @@ -185,7 +184,6 @@ namespace OpenSim.Tests.Performance endGcMemory / 1024 / 1024, startGcMemory / 1024 / 1024, (endGcMemory - startGcMemory) / 1024 / 1024); -*/ } } } diff --git a/OpenSim/Tests/Permissions/Common.cs b/OpenSim/Tests/Permissions/Common.cs new file mode 100644 index 0000000..4ecce38 --- /dev/null +++ b/OpenSim/Tests/Permissions/Common.cs @@ -0,0 +1,374 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +using System; +using System.Collections.Generic; +using System.Threading; +using Nini.Config; +using NUnit.Framework; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.CoreModules.World.Permissions; +using OpenSim.Region.CoreModules.Avatar.Inventory.Transfer; +using OpenSim.Region.CoreModules.Framework.InventoryAccess; +using OpenSim.Services.Interfaces; +using OpenSim.Tests.Common; +using PermissionMask = OpenSim.Framework.PermissionMask; + +namespace OpenSim.Tests.Permissions +{ + [SetUpFixture] + public class Common : OpenSimTestCase + { + public static Common TheInstance; + + public static TestScene TheScene + { + get { return TheInstance.m_Scene; } + } + + public static ScenePresence[] TheAvatars + { + get { return TheInstance.m_Avatars; } + } + + private static string Perms = "Owner: {0}; Group: {1}; Everyone: {2}; Next: {3}"; + private TestScene m_Scene; + private ScenePresence[] m_Avatars = new ScenePresence[3]; + + [SetUp] + public override void SetUp() + { + if (TheInstance == null) + TheInstance = this; + + base.SetUp(); + TestHelpers.EnableLogging(); + + IConfigSource config = new IniConfigSource(); + config.AddConfig("Messaging"); + config.Configs["Messaging"].Set("InventoryTransferModule", "InventoryTransferModule"); + + config.AddConfig("Modules"); + config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); + + config.AddConfig("InventoryService"); + config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:XInventoryService"); + config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll:TestXInventoryDataPlugin"); + + config.AddConfig("Groups"); + config.Configs["Groups"].Set("Enabled", "true"); + config.Configs["Groups"].Set("Module", "Groups Module V2"); + config.Configs["Groups"].Set("StorageProvider", "OpenSim.Tests.Common.dll:TestGroupsDataPlugin"); + config.Configs["Groups"].Set("ServicesConnectorModule", "Groups Local Service Connector"); + config.Configs["Groups"].Set("LocalService", "local"); + + m_Scene = new SceneHelpers().SetupScene("Test", UUID.Random(), 1000, 1000, config); + // Add modules + SceneHelpers.SetupSceneModules(m_Scene, config, new DefaultPermissionsModule(), new InventoryTransferModule(), new BasicInventoryAccessModule()); + + SetUpBasicEnvironment(); + } + + /// + /// 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 + /// + 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 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); + } + + private ScenePresence AddScenePresence(string first, string last, UUID id) + { + UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_Scene, first, last, id, "pw"); + ScenePresence sp = SceneHelpers.AddScenePresence(m_Scene, id); + Assert.That(m_Scene.AuthenticateHandler.GetAgentCircuitData(id), Is.Not.Null); + + return sp; + } + + private void AddA1Object(string name, int suffix, PermissionMask nextOwnerPerms) + { + // Create a Box. Default permissions are just T + SceneObjectGroup box = AddSceneObject(name, suffix, 1, m_Avatars[0].UUID); + Assert.True((box.RootPart.NextOwnerMask & (int)PermissionMask.Copy) == 0); + Assert.True((box.RootPart.NextOwnerMask & (int)PermissionMask.Modify) == 0); + Assert.True((box.RootPart.NextOwnerMask & (int)PermissionMask.Transfer) != 0); + + // field = 16 is NextOwner + // set = 1 means add the permission; set = 0 means remove permission + + if ((nextOwnerPerms & PermissionMask.Copy) != 0) + m_Scene.HandleObjectPermissionsUpdate((IClientAPI)m_Avatars[0].ClientView, m_Avatars[0].UUID, + ((IClientAPI)(m_Avatars[0].ClientView)).SessionId, 16, box.LocalId, (uint)PermissionMask.Copy, 1); + + if ((nextOwnerPerms & PermissionMask.Modify) != 0) + m_Scene.HandleObjectPermissionsUpdate((IClientAPI)m_Avatars[0].ClientView, m_Avatars[0].UUID, + ((IClientAPI)(m_Avatars[0].ClientView)).SessionId, 16, box.LocalId, (uint)PermissionMask.Modify, 1); + + if ((nextOwnerPerms & PermissionMask.Transfer) == 0) + m_Scene.HandleObjectPermissionsUpdate((IClientAPI)m_Avatars[0].ClientView, m_Avatars[0].UUID, + ((IClientAPI)(m_Avatars[0].ClientView)).SessionId, 16, box.LocalId, (uint)PermissionMask.Transfer, 0); + + PrintPerms(box); + AssertPermissions(nextOwnerPerms, (PermissionMask)box.RootPart.NextOwnerMask, box.OwnerID.ToString().Substring(34) + " : " + box.Name); + + TakeCopyToInventory(0, box); + + } + + public void RevokePermission(int ownerIndex, string name, PermissionMask perm) + { + InventoryItemBase item = Common.TheInstance.GetItemFromInventory(m_Avatars[ownerIndex].UUID, "Objects", name); + Assert.That(item, Is.Not.Null); + + // Clone it, so to avoid aliasing -- just like the viewer does. + InventoryItemBase clone = Common.TheInstance.CloneInventoryItem(item); + // Revoke the permission in this copy + clone.NextPermissions &= ~(uint)perm; + Common.TheInstance.AssertPermissions((PermissionMask)clone.NextPermissions & ~perm, + (PermissionMask)clone.NextPermissions, Common.TheInstance.IdStr(clone)); + Assert.That(clone.ID == item.ID); + + // Update properties of the item in inventory. This should affect the original item above. + Common.TheScene.UpdateInventoryItemAsset(m_Avatars[ownerIndex].ControllingClient, UUID.Zero, clone.ID, clone); + + item = Common.TheInstance.GetItemFromInventory(m_Avatars[ownerIndex].UUID, "Objects", name); + Assert.That(item, Is.Not.Null); + Common.TheInstance.PrintPerms(item); + Common.TheInstance.AssertPermissions((PermissionMask)item.NextPermissions & ~perm, + (PermissionMask)item.NextPermissions, Common.TheInstance.IdStr(item)); + + } + + public void PrintPerms(SceneObjectGroup sog) + { + Console.WriteLine("SOG " + sog.Name + " (" + sog.OwnerID.ToString().Substring(34) + "): " + + String.Format(Perms, (PermissionMask)sog.EffectiveOwnerPerms, + (PermissionMask)sog.EffectiveGroupPerms, (PermissionMask)sog.EffectiveEveryOnePerms, (PermissionMask)sog.RootPart.NextOwnerMask)); + + } + + public void PrintPerms(InventoryItemBase item) + { + Console.WriteLine("Inv " + item.Name + " (" + item.Owner.ToString().Substring(34) + "): " + + String.Format(Perms, (PermissionMask)item.BasePermissions, + (PermissionMask)item.GroupPermissions, (PermissionMask)item.EveryOnePermissions, (PermissionMask)item.NextPermissions)); + + } + + public void AssertPermissions(PermissionMask desired, PermissionMask actual, string message) + { + if ((desired & PermissionMask.Copy) != 0) + Assert.True((actual & PermissionMask.Copy) != 0, message); + else + Assert.True((actual & PermissionMask.Copy) == 0, message); + + if ((desired & PermissionMask.Modify) != 0) + Assert.True((actual & PermissionMask.Modify) != 0, message); + else + Assert.True((actual & PermissionMask.Modify) == 0, message); + + if ((desired & PermissionMask.Transfer) != 0) + Assert.True((actual & PermissionMask.Transfer) != 0, message); + else + Assert.True((actual & PermissionMask.Transfer) == 0, message); + + } + + public SceneObjectGroup AddSceneObject(string name, int suffix, int partsToTestCount, UUID ownerID) + { + SceneObjectGroup so = SceneHelpers.CreateSceneObject(partsToTestCount, ownerID, name, suffix); + so.Name = name; + so.Description = name; + + Assert.That(m_Scene.AddNewSceneObject(so, false), Is.True); + SceneObjectGroup retrievedSo = m_Scene.GetSceneObjectGroup(so.UUID); + + // If the parts have the same UUID then we will consider them as one and the same + Assert.That(retrievedSo.PrimCount, Is.EqualTo(partsToTestCount)); + + return so; + } + + 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 localIds = new List(); localIds.Add(sog.LocalId); + // This is an async operation + m_Scene.DeRezObjects((IClientAPI)m_Avatars[userIndex].ClientView, localIds, m_Avatars[userIndex].UUID, DeRezAction.TakeCopy, objsFolder.ID); + } + + 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 items = m_Scene.InventoryService.GetFolderItems(userID, objsFolder.ID); + InventoryItemBase item = items.Find(i => i.Name == itemName); + Assert.That(item, Is.Not.Null); + + return item; + } + + public InventoryItemBase CloneInventoryItem(InventoryItemBase item) + { + InventoryItemBase clone = new InventoryItemBase(item.ID); + clone.Name = item.Name; + clone.Description = item.Description; + clone.AssetID = item.AssetID; + clone.AssetType = item.AssetType; + clone.BasePermissions = item.BasePermissions; + clone.CreatorId = item.CreatorId; + clone.CurrentPermissions = item.CurrentPermissions; + clone.EveryOnePermissions = item.EveryOnePermissions; + clone.Flags = item.Flags; + clone.Folder = item.Folder; + clone.GroupID = item.GroupID; + clone.GroupOwned = item.GroupOwned; + clone.GroupPermissions = item.GroupPermissions; + clone.InvType = item.InvType; + clone.NextPermissions = item.NextPermissions; + clone.Owner = item.Owner; + + return clone; + } + + 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 items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[i].UUID, objsFolder.ID); + List ids = new List(); + 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)); + } + + } + + public string IdStr(InventoryItemBase item) + { + return item.Owner.ToString().Substring(34) + " : " + item.Name; + } + + public string IdStr(SceneObjectGroup sog) + { + return sog.OwnerID.ToString().Substring(34) + " : " + sog.Name; + } + + public void GiveInventoryItem(UUID itemId, ScenePresence giverSp, ScenePresence receiverSp) + { + TestClient giverClient = (TestClient)giverSp.ControllingClient; + TestClient receiverClient = (TestClient)receiverSp.ControllingClient; + + UUID initialSessionId = TestHelpers.ParseTail(0x10); + 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); + } + } +} diff --git a/OpenSim/Tests/Permissions/DirectTransferTests.cs b/OpenSim/Tests/Permissions/DirectTransferTests.cs new file mode 100644 index 0000000..0f251db --- /dev/null +++ b/OpenSim/Tests/Permissions/DirectTransferTests.cs @@ -0,0 +1,153 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using NUnit.Framework; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Tests.Common; +using PermissionMask = OpenSim.Framework.PermissionMask; + +namespace OpenSim.Tests.Permissions +{ + /// + /// Basic scene object tests (create, read and delete but not update). + /// + [TestFixture] + public class DirectTransferTests + { + + [SetUp] + public void SetUp() + { + // In case we're dealing with some older version of nunit + if (Common.TheInstance == null) + { + Common.TheInstance = new Common(); + Common.TheInstance.SetUp(); + } + + Common.TheInstance.DeleteObjectsFolders(); + } + + /// + /// Test giving simple objecta with various combinations of next owner perms. + /// + [Test] + public void TestGiveBox() + { + TestHelpers.InMethod(); + + // 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 + }; + + for (int i = 0; i < 6; i++) + TestOneBox(names[i], perms[i]); + } + + private void TestOneBox(string name, PermissionMask mask) + { + InventoryItemBase item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[0].UUID, "Objects", name); + + Common.TheInstance.GiveInventoryItem(item.ID, Common.TheAvatars[0], Common.TheAvatars[1]); + + item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", name); + + // Check the receiver + Common.TheInstance.PrintPerms(item); + Common.TheInstance.AssertPermissions(mask, (PermissionMask)item.BasePermissions, item.Owner.ToString().Substring(34) + " : " + item.Name); + + int nObjects = Common.TheScene.GetSceneObjectGroups().Count; + // Rez it and check perms in scene too + Common.TheScene.RezObject(Common.TheAvatars[1].ControllingClient, item.ID, UUID.Zero, Vector3.One, Vector3.Zero, UUID.Zero, 0, false, false, false, UUID.Zero); + Assert.That(Common.TheScene.GetSceneObjectGroups().Count, Is.EqualTo(nObjects + 1)); + + SceneObjectGroup box = Common.TheScene.GetSceneObjectGroups().Find(sog => sog.OwnerID == Common.TheAvatars[1].UUID && sog.Name == name); + Common.TheInstance.PrintPerms(box); + Assert.That(box, Is.Not.Null); + + // Check Owner permissions + Common.TheInstance.AssertPermissions(mask, (PermissionMask)box.EffectiveOwnerPerms, box.OwnerID.ToString().Substring(34) + " : " + box.Name); + + // Check Next Owner permissions + Common.TheInstance.AssertPermissions(mask, (PermissionMask)box.RootPart.NextOwnerMask, box.OwnerID.ToString().Substring(34) + " : " + box.Name); + + } + + /// + /// Test giving simple objecta with variour combinations of next owner perms. + /// + [Test] + public void TestDoubleGiveWithChange() + { + TestHelpers.InMethod(); + + string name = "Box MCT-C"; + InventoryItemBase item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[0].UUID, "Objects", name); + + // Now give the item to A2. We give the original item, not a clone. + // The giving methods are supposed to duplicate it. + Common.TheInstance.GiveInventoryItem(item.ID, Common.TheAvatars[0], Common.TheAvatars[1]); + + item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", name); + + // Check the receiver + Common.TheInstance.PrintPerms(item); + Common.TheInstance.AssertPermissions(PermissionMask.Modify | PermissionMask.Transfer, + (PermissionMask)item.BasePermissions, Common.TheInstance.IdStr(item)); + + // --------------------------- + // Second transfer + //---------------------------- + + // A2 revokes M + Common.TheInstance.RevokePermission(1, name, PermissionMask.Modify); + + item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", name); + + // Now give the item to A3. We give the original item, not a clone. + // The giving methods are supposed to duplicate it. + Common.TheInstance.GiveInventoryItem(item.ID, Common.TheAvatars[1], Common.TheAvatars[2]); + + item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[2].UUID, "Objects", name); + + // Check the receiver + Common.TheInstance.PrintPerms(item); + Common.TheInstance.AssertPermissions(PermissionMask.Transfer, + (PermissionMask)item.BasePermissions, Common.TheInstance.IdStr(item)); + + } + } +} \ No newline at end of file diff --git a/OpenSim/Tests/Permissions/IndirectTransferTests.cs b/OpenSim/Tests/Permissions/IndirectTransferTests.cs new file mode 100644 index 0000000..fb96b8b --- /dev/null +++ b/OpenSim/Tests/Permissions/IndirectTransferTests.cs @@ -0,0 +1,132 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Collections.Generic; +using System.Threading; +using NUnit.Framework; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Tests.Common; +using PermissionMask = OpenSim.Framework.PermissionMask; + +namespace OpenSim.Tests.Permissions +{ + /// + /// Basic scene object tests (create, read and delete but not update). + /// + [TestFixture] + public class IndirectTransferTests + { + + [SetUp] + public void SetUp() + { + // In case we're dealing with some older version of nunit + if (Common.TheInstance == null) + { + Common.TheInstance = new Common(); + Common.TheInstance.SetUp(); + } + Common.TheInstance.DeleteObjectsFolders(); + } + + /// + /// Test giving simple objecta with various combinations of next owner perms. + /// + [Test] + 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 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)); + } + } + + private void TakeOneBox(List objs, string name, PermissionMask mask) + { + // Find the object inworld + SceneObjectGroup box = objs.Find(sog => sog.Name == name && sog.OwnerID == Common.TheAvatars[0].UUID); + Assert.That(box, Is.Not.Null, name); + + // A2's inventory (index 1) + Common.TheInstance.TakeCopyToInventory(1, box); + } + + private void MakeCopyable(List objs, string name) + { + SceneObjectGroup box = objs.Find(sog => sog.Name == name && sog.OwnerID == Common.TheAvatars[0].UUID); + Assert.That(box, Is.Not.Null, name); + + // field = 8 is Everyone + // set = 1 means add the permission; set = 0 means remove permission + Common.TheScene.HandleObjectPermissionsUpdate((IClientAPI)Common.TheAvatars[0].ClientView, Common.TheAvatars[0].UUID, + Common.TheAvatars[0].ControllingClient.SessionId, 8, box.LocalId, (uint)PermissionMask.Copy, 1); + Common.TheInstance.PrintPerms(box); + } + } +} \ No newline at end of file diff --git a/OpenSim/Tests/Robust/Clients/Grid/GridClient.cs b/OpenSim/Tests/Robust/Clients/Grid/GridClient.cs index 671aca7..1549851 100644 --- a/OpenSim/Tests/Robust/Clients/Grid/GridClient.cs +++ b/OpenSim/Tests/Robust/Clients/Grid/GridClient.cs @@ -95,7 +95,7 @@ namespace Robust.Tests Assert.AreNotEqual(regions, null, "GetRegionsByName failed"); Assert.AreEqual(regions.Count, 3, "GetRegionsByName should return 3"); - regions = m_Connector.GetRegionRange(UUID.Zero, + regions = m_Connector.GetRegionRange(UUID.Zero, (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002), (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002) ); Assert.AreNotEqual(regions, null, "GetRegionRange failed"); @@ -126,7 +126,7 @@ namespace Robust.Tests region.ExternalHostName = "127.0.0.1"; region.HttpPort = 9000; region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 9000); - + return region; } } diff --git a/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs index 0280b73..fe46a4f 100644 --- a/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs +++ b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs @@ -159,8 +159,7 @@ namespace Robust.Tests XInventoryServicesConnector m_Connector = new XInventoryServicesConnector(DemonServer.Address); // Prefetch Notecard 1, will be cached from here on - InventoryItemBase item = new InventoryItemBase(new UUID("10000000-0000-0000-0000-000000000001"), m_userID); - item = m_Connector.GetItem(item); + InventoryItemBase item = m_Connector.GetItem(m_userID, new UUID("10000000-0000-0000-0000-000000000001")); Assert.NotNull(item, "Failed to get Notecard 1"); Assert.AreEqual("Test Notecard 1", item.Name, "Wrong name for Notecard 1"); @@ -177,7 +176,7 @@ namespace Robust.Tests Assert.NotNull(items, "(Repeat) Failed to get multiple items"); Assert.IsTrue(items.Length == 2, "(Repeat) Requested 2 items, but didn't receive 2 items"); - // This item doesn't exist, but [0] does, and it's cached. + // This item doesn't exist, but [0] does, and it's cached. uuids[1] = new UUID("bb000000-0000-0000-0000-0000000000bb"); // Fetching should return 2 items, but [1] should be null items = m_Connector.GetMultipleItems(m_userID, uuids); @@ -186,7 +185,7 @@ namespace Robust.Tests Assert.AreEqual("Test Notecard 1", items[0].Name, "(Three times) Wrong name for Notecard 1"); Assert.IsNull(items[1], "(Three times) Expecting 2nd item to be null"); - // Now both don't exist + // Now both don't exist uuids[0] = new UUID("aa000000-0000-0000-0000-0000000000aa"); items = m_Connector.GetMultipleItems(m_userID, uuids); Assert.Null(items[0], "Request to multiple non-existent items is supposed to return null [0]"); diff --git a/OpenSim/Tests/Robust/Server/DemonServer.cs b/OpenSim/Tests/Robust/Server/DemonServer.cs index 205abfb..1e0797e 100644 --- a/OpenSim/Tests/Robust/Server/DemonServer.cs +++ b/OpenSim/Tests/Robust/Server/DemonServer.cs @@ -48,8 +48,8 @@ namespace Robust.Tests [SetUp] public void StartDemon() { - if (File.Exists("../logs/Robust.Tests.log")) - File.Delete("../logs/Robust.Tests.log"); + if (File.Exists("Robust.Tests.log")) + File.Delete("Robust.Tests.log"); Console.WriteLine("**** Starting demon Robust server ****"); m_demon = new Thread( () => Main(new string[] {"-inifile=Robust.Tests.ini"})); diff --git a/OpenSim/Tests/Stress/VectorRenderModuleStressTests.cs b/OpenSim/Tests/Stress/VectorRenderModuleStressTests.cs index 0ab407e..e9767f3 100644 --- a/OpenSim/Tests/Stress/VectorRenderModuleStressTests.cs +++ b/OpenSim/Tests/Stress/VectorRenderModuleStressTests.cs @@ -105,7 +105,7 @@ namespace OpenSim.Tests.Stress public void Draw() { SceneObjectGroup so = SceneHelpers.AddSceneObject(m_tests.Scene); - + while (Ready) { UUID originalTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; @@ -118,9 +118,8 @@ namespace OpenSim.Tests.Stress so.UUID, m_tests.Vrm.GetContentType(), string.Format("PenColour BLACK; MoveTo 40,220; FontSize 32; Text {0};", text), - "", - 0); - + ""); + Assert.That(originalTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); Pass++; -- cgit v1.1 From 295e91b8f44a356ab742dedd27c1b7edfe7b1157 Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 22:15:41 +1000 Subject: Move cache, config, logs out of tree, and various related clean ups. --- OpenSim/Tests/Robust/Server/DemonServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Tests') diff --git a/OpenSim/Tests/Robust/Server/DemonServer.cs b/OpenSim/Tests/Robust/Server/DemonServer.cs index 1e0797e..41c2185 100644 --- a/OpenSim/Tests/Robust/Server/DemonServer.cs +++ b/OpenSim/Tests/Robust/Server/DemonServer.cs @@ -48,8 +48,8 @@ namespace Robust.Tests [SetUp] public void StartDemon() { - if (File.Exists("Robust.Tests.log")) - File.Delete("Robust.Tests.log"); + if (File.Exists("../../logs/Robust.Tests.log")) + File.Delete("../../logs/Robust.Tests.log"); Console.WriteLine("**** Starting demon Robust server ****"); m_demon = new Thread( () => Main(new string[] {"-inifile=Robust.Tests.ini"})); -- cgit v1.1