From 191db0e6a4327e8bf84350a541a9edc579ae1c54 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 28 May 2010 23:14:24 +0100 Subject: get TestSaveIarV0_1() uncommented but not running as a test yet since I didn't get the authentication server to work and my brain is about to fizzle out my ears --- .../Archiver/Tests/InventoryArchiverTests.cs | 205 ++++++++++----------- OpenSim/Region/Framework/Scenes/SceneBase.cs | 2 + OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 28 ++- OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs | 13 +- 4 files changed, 138 insertions(+), 110 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index d339543..c81f295 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -76,125 +76,118 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // Commenting for now! The mock inventory service needs more beef, at least for // GetFolderForType // REFACTORING PROBLEM. This needs to be rewritten. + //[Test] + public void TestSaveIarV0_1() + { + TestHelper.InMethod(); + log4net.Config.XmlConfigurator.Configure(); -// [Test] -// public void TestSaveIarV0_1() -// { -// TestHelper.InMethod(); -// //log4net.Config.XmlConfigurator.Configure(); + InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); -// InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); + Scene scene = SceneSetupHelpers.SetupScene("Inventory"); + SceneSetupHelpers.SetupSceneModules(scene, archiverModule); -// Scene scene = SceneSetupHelpers.SetupScene("Inventory"); -// SceneSetupHelpers.SetupSceneModules(scene, archiverModule); -// CommunicationsManager cm = scene.CommsManager; - -// // Create user -// string userFirstName = "Jock"; -// string userLastName = "Stirrup"; -// UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); - -// lock (this) -// { -// UserProfileTestUtils.CreateUserWithInventory( -// cm, userFirstName, userLastName, userId, InventoryReceived); -// Monitor.Wait(this, 60000); -// } + // Create user + string userFirstName = "Jock"; + string userLastName = "Stirrup"; + string userPassword = "troll"; + UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); + UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); -// // Create asset -// SceneObjectGroup object1; -// SceneObjectPart part1; -// { -// string partName = "My Little Dog Object"; -// UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); -// PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); -// Vector3 groupPosition = new Vector3(10, 20, 30); -// Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); -// Vector3 offsetPosition = new Vector3(5, 10, 15); - -// part1 -// = new SceneObjectPart( -// ownerId, shape, groupPosition, rotationOffset, offsetPosition); -// part1.Name = partName; - -// object1 = new SceneObjectGroup(part1); -// scene.AddNewSceneObject(object1, false); -// } - -// UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); -// AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); -// scene.AssetService.Store(asset1); - -// // Create item -// UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); -// InventoryItemBase item1 = new InventoryItemBase(); -// item1.Name = "My Little Dog"; -// item1.AssetID = asset1.FullID; -// item1.ID = item1Id; -// InventoryFolderBase objsFolder -// = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); -// item1.Folder = objsFolder.ID; -// scene.AddInventoryItem(userId, item1); - -// MemoryStream archiveWriteStream = new MemoryStream(); -// archiverModule.OnInventoryArchiveSaved += SaveCompleted; - -// mre.Reset(); -// archiverModule.ArchiveInventory( -// Guid.NewGuid(), userFirstName, userLastName, "Objects", "troll", archiveWriteStream); -// mre.WaitOne(60000, false); - -// byte[] archive = archiveWriteStream.ToArray(); -// MemoryStream archiveReadStream = new MemoryStream(archive); -// TarArchiveReader tar = new TarArchiveReader(archiveReadStream); - -// //bool gotControlFile = false; -// bool gotObject1File = false; -// //bool gotObject2File = false; -// string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1); -// string expectedObject1FilePath = string.Format( -// "{0}{1}{2}", -// ArchiveConstants.INVENTORY_PATH, -// InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder), -// expectedObject1FileName); + // Create asset + SceneObjectGroup object1; + SceneObjectPart part1; + { + string partName = "My Little Dog Object"; + UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); + PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); + Vector3 groupPosition = new Vector3(10, 20, 30); + Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); + Vector3 offsetPosition = new Vector3(5, 10, 15); + + part1 + = new SceneObjectPart( + ownerId, shape, groupPosition, rotationOffset, offsetPosition); + part1.Name = partName; + + object1 = new SceneObjectGroup(part1); + scene.AddNewSceneObject(object1, false); + } -// string filePath; -// TarArchiveReader.TarEntryType tarEntryType; + UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); + AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); + scene.AssetService.Store(asset1); + + // Create item + UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); + InventoryItemBase item1 = new InventoryItemBase(); + item1.Name = "My Little Dog"; + item1.AssetID = asset1.FullID; + item1.ID = item1Id; + InventoryFolderBase objsFolder + = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); + item1.Folder = objsFolder.ID; + scene.AddInventoryItem(userId, item1); + + MemoryStream archiveWriteStream = new MemoryStream(); + archiverModule.OnInventoryArchiveSaved += SaveCompleted; + + mre.Reset(); + archiverModule.ArchiveInventory( + Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); + mre.WaitOne(60000, false); + + byte[] archive = archiveWriteStream.ToArray(); + MemoryStream archiveReadStream = new MemoryStream(archive); + TarArchiveReader tar = new TarArchiveReader(archiveReadStream); + + //bool gotControlFile = false; + bool gotObject1File = false; + //bool gotObject2File = false; + string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1); + string expectedObject1FilePath = string.Format( + "{0}{1}{2}", + ArchiveConstants.INVENTORY_PATH, + InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder), + expectedObject1FileName); + + string filePath; + TarArchiveReader.TarEntryType tarEntryType; // Console.WriteLine("Reading archive"); -// while (tar.ReadEntry(out filePath, out tarEntryType) != null) -// { -// Console.WriteLine("Got {0}", filePath); + while (tar.ReadEntry(out filePath, out tarEntryType) != null) + { + Console.WriteLine("Got {0}", filePath); -//// if (ArchiveConstants.CONTROL_FILE_PATH == filePath) -//// { -//// gotControlFile = true; -//// } - -// if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml")) +// if (ArchiveConstants.CONTROL_FILE_PATH == filePath) // { -//// string fileName = filePath.Remove(0, "Objects/".Length); -//// -//// if (fileName.StartsWith(part1.Name)) -//// { -// Assert.That(expectedObject1FilePath, Is.EqualTo(filePath)); -// gotObject1File = true; -//// } -//// else if (fileName.StartsWith(part2.Name)) -//// { -//// Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); -//// gotObject2File = true; -//// } +// gotControlFile = true; // } -// } + + if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml")) + { +// string fileName = filePath.Remove(0, "Objects/".Length); +// +// if (fileName.StartsWith(part1.Name)) +// { + Assert.That(expectedObject1FilePath, Is.EqualTo(filePath)); + gotObject1File = true; +// } +// else if (fileName.StartsWith(part2.Name)) +// { +// Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); +// gotObject2File = true; +// } + } + } -//// Assert.That(gotControlFile, Is.True, "No control file in archive"); -// Assert.That(gotObject1File, Is.True, "No item1 file in archive"); -//// Assert.That(gotObject2File, Is.True, "No object2 file in archive"); +// Assert.That(gotControlFile, Is.True, "No control file in archive"); + Assert.That(gotObject1File, Is.True, "No item1 file in archive"); +// Assert.That(gotObject2File, Is.True, "No object2 file in archive"); -// // TODO: Test presence of more files and contents of files. -// } + // TODO: Test presence of more files and contents of files. + } /// /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index c363a91..ee17fbf 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -376,6 +376,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void RegisterModuleInterface(M mod) { + m_log.DebugFormat("[SCENE BASE]: Registering interface {0}", typeof(M)); + List l = null; if (!ModuleInterfaces.TryGetValue(typeof(M), out l)) { diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index 91cf323..2756324 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs @@ -42,6 +42,7 @@ using OpenSim.Region.Framework.Scenes; using OpenSim.Region.CoreModules.Agent.Capabilities; using OpenSim.Region.CoreModules.Avatar.Gods; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset; +using OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; @@ -58,6 +59,7 @@ namespace OpenSim.Tests.Common.Setup // These static variables in order to allow regions to be linked by shared modules and same // CommunicationsManager. private static ISharedRegionModule m_assetService = null; +// private static ISharedRegionModule m_authenticationService = null; private static ISharedRegionModule m_inventoryService = null; private static ISharedRegionModule m_gridService = null; private static ISharedRegionModule m_userAccountService = null; @@ -177,6 +179,9 @@ namespace OpenSim.Tests.Common.Setup StartAssetService(testScene, true); else StartAssetService(testScene, false); + + // For now, always started a 'real' authenication service + StartAuthenticationService(testScene, true); if (realServices.Contains("inventory")) StartInventoryService(testScene, true); @@ -236,13 +241,34 @@ namespace OpenSim.Tests.Common.Setup else config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:MockAssetService"); config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); - assetService.Initialise(config); + assetService.Initialise(config); assetService.AddRegion(testScene); assetService.RegionLoaded(testScene); testScene.AddRegionModule(assetService.Name, assetService); m_assetService = assetService; } + private static void StartAuthenticationService(Scene testScene, bool real) + { + ISharedRegionModule service = new LocalAuthenticationServicesConnector(); + IConfigSource config = new IniConfigSource(); + config.AddConfig("Modules"); + config.AddConfig("AuthenticationService"); + config.Configs["Modules"].Set("AuthenticationServices", "LocalAuthenticationServicesConnector"); + if (real) + config.Configs["AuthenticationService"].Set( + "LocalServiceModule", "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"); + else + config.Configs["AuthenticationService"].Set( + "LocalServiceModule", "OpenSim.Tests.Common.dll:MockuthenticationService"); + config.Configs["AuthenticationService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); + service.Initialise(config); + service.AddRegion(testScene); + service.RegionLoaded(testScene); + testScene.AddRegionModule(service.Name, service); + //m_authenticationService = service; + } + private static void StartInventoryService(Scene testScene, bool real) { ISharedRegionModule inventoryService = new LocalInventoryServicesConnector(); diff --git a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs index a6b9520..e6a7818 100644 --- a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs +++ b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs @@ -117,12 +117,19 @@ namespace OpenSim.Tests.Common.Setup public static UserAccount CreateUserWithInventory(Scene scene) { - UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099"); - UserAccount ua = new UserAccount(userId) { FirstName = "Bill", LastName = "Bailey" }; + return CreateUserWithInventory( + scene, "Bill", "Bailey", UUID.Parse("00000000-0000-0000-0000-000000000099"), "troll"); + } + + public static UserAccount CreateUserWithInventory( + Scene scene, string firstName, string lastName, UUID userId, string pw) + { + UserAccount ua = new UserAccount(userId) { FirstName = firstName, LastName = lastName }; scene.UserAccountService.StoreUserAccount(ua); scene.InventoryService.CreateUserInventory(ua.PrincipalID); + scene.AuthenticationService.SetPassword(ua.PrincipalID, pw); return ua; - } + } } } \ No newline at end of file -- cgit v1.1