Add test to check behaviour if an iar is loaded where no user profile exists for the creators

Disable generation of temporary profiles for now, instead record loading user as creator
remotes/origin/0.6.7-post-fixes
Justin Clark-Casey (justincc) 2009-09-09 18:03:49 +01:00
parent 2bb2a0ec44
commit 0683cf6e0d
4 changed files with 90 additions and 20 deletions

View File

@ -154,6 +154,8 @@ namespace OpenSim.Framework.Communications.Osp
if (userInfo != null) if (userInfo != null)
return userInfo.UserProfile.ID; return userInfo.UserProfile.ID;
// XXX: Disable temporary user profile creation for now as implementation is incomplete - justincc
/*
UserProfileData tempUserProfile = new UserProfileData(); UserProfileData tempUserProfile = new UserProfileData();
tempUserProfile.FirstName = firstName; tempUserProfile.FirstName = firstName;
tempUserProfile.SurName = lastName; tempUserProfile.SurName = lastName;
@ -164,6 +166,9 @@ namespace OpenSim.Framework.Communications.Osp
commsManager.UserService.AddTemporaryUserProfile(tempUserProfile); commsManager.UserService.AddTemporaryUserProfile(tempUserProfile);
return tempUserProfile.ID; return tempUserProfile.ID;
*/
return UUID.Zero;
} }
} }
} }

View File

@ -177,6 +177,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager); UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager);
if (UUID.Zero != ospResolvedId) if (UUID.Zero != ospResolvedId)
item.CreatorIdAsUuid = ospResolvedId; item.CreatorIdAsUuid = ospResolvedId;
else
item.CreatorIdAsUuid = m_userInfo.UserProfile.ID;
item.Owner = m_userInfo.UserProfile.ID; item.Owner = m_userInfo.UserProfile.ID;

View File

@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
public void TestSaveIarV0_1() public void TestSaveIarV0_1()
{ {
TestHelper.InMethod(); TestHelper.InMethod();
log4net.Config.XmlConfigurator.Configure(); //log4net.Config.XmlConfigurator.Configure();
InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
@ -202,12 +202,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
/// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
/// an account exists with the creator name. /// an account exists with the creator name.
/// </summary> /// </summary>
///
/// This test also does some deeper probing of loading into nested inventory structures
[Test] [Test]
public void TestLoadIarV0_1ExistingUsers() public void TestLoadIarV0_1ExistingUsers()
{ {
TestHelper.InMethod(); TestHelper.InMethod();
log4net.Config.XmlConfigurator.Configure(); //log4net.Config.XmlConfigurator.Configure();
string userFirstName = "Mr"; string userFirstName = "Mr";
string userLastName = "Tiddles"; string userLastName = "Tiddles";
@ -289,6 +291,77 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
} }
/// <summary>
/// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
/// embedded creators do not exist in the system
/// </summary>
///
/// This may possibly one day get overtaken by the as yet incomplete temporary profiles feature
/// (as tested in the a later commented out test)
[Test]
public void TestLoadIarV0_1AbsentUsers()
{
TestHelper.InMethod();
log4net.Config.XmlConfigurator.Configure();
string userFirstName = "Charlie";
string userLastName = "Chan";
UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000999");
string userItemCreatorFirstName = "Bat";
string userItemCreatorLastName = "Man";
//UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000008888");
string itemName = "b.lsl";
string archiveItemName
= string.Format("{0}{1}{2}", itemName, "_", UUID.Random());
MemoryStream archiveWriteStream = new MemoryStream();
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
InventoryItemBase item1 = new InventoryItemBase();
item1.Name = itemName;
item1.AssetID = UUID.Random();
item1.GroupID = UUID.Random();
item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName);
//item1.CreatorId = userUuid.ToString();
//item1.CreatorId = "00000000-0000-0000-0000-000000000444";
item1.Owner = UUID.Zero;
string item1FileName
= string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
tar.Close();
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
SerialiserModule serialiserModule = new SerialiserModule();
InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
// Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
Scene scene = SceneSetupHelpers.SetupScene("inventory");
IUserAdminService userAdminService = scene.CommsManager.UserAdminService;
SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
userAdminService.AddUser(
userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid);
archiverModule.DearchiveInventory(userFirstName, userLastName, "/", archiveReadStream);
CachedUserInfo userInfo
= scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
InventoryItemBase foundItem1
= InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, itemName);
Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
// Assert.That(
// foundItem1.CreatorId, Is.EqualTo(userUuid),
// "Loaded item non-uuid creator doesn't match that of the loading user");
Assert.That(
foundItem1.CreatorIdAsUuid, Is.EqualTo(userUuid),
"Loaded item uuid creator doesn't match that of the loading user");
}
/// <summary> /// <summary>
/// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
/// no account exists with the creator name /// no account exists with the creator name
@ -376,7 +449,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
{ {
TestHelper.InMethod(); TestHelper.InMethod();
log4net.Config.XmlConfigurator.Configure(); //log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene("inventory"); Scene scene = SceneSetupHelpers.SetupScene("inventory");
CommunicationsManager commsManager = scene.CommsManager; CommunicationsManager commsManager = scene.CommsManager;

View File

@ -3488,7 +3488,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (geom == localGround) if (geom == localGround)
{ {
localHeightfield = TerrainHeightFieldHeights[geom]; //localHeightfield = TerrainHeightFieldHeights[geom];
proceed = true; proceed = true;
} }
else else
@ -3510,7 +3510,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// memory corruption // memory corruption
if (TerrainHeightFieldHeights.ContainsKey(g)) if (TerrainHeightFieldHeights.ContainsKey(g))
{ {
float[] removingHeightField = TerrainHeightFieldHeights[g]; //float[] removingHeightField = TerrainHeightFieldHeights[g];
TerrainHeightFieldHeights.Remove(g); TerrainHeightFieldHeights.Remove(g);
if (RegionTerrain.ContainsKey(g)) if (RegionTerrain.ContainsKey(g))
@ -3519,27 +3519,17 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
d.GeomDestroy(g); d.GeomDestroy(g);
removingHeightField = new float[0]; //removingHeightField = new float[0];
} }
} }
} }
else else
{ {
m_log.Warn("[PHYSICS]: Couldn't proceed with UnCombine. Region has inconsistant data."); m_log.Warn("[PHYSICS]: Couldn't proceed with UnCombine. Region has inconsistant data.");
}
}
} }
} }
}
}
public override void SetWaterLevel(float baseheight) public override void SetWaterLevel(float baseheight)
{ {