Add more unit tests for user cases Persist more user fields into mysql that already had columns defined but weren't getting passed to the mysql manager.0.6.0-stable
parent
f79e7597b6
commit
46492f3c11
|
@ -751,6 +751,7 @@ namespace OpenSim.Data.MySQL
|
|||
/// <param name="passwordHash">A salted hash of the users password</param>
|
||||
/// <param name="passwordSalt">The salt used for the password hash</param>
|
||||
/// <param name="homeRegion">A regionHandle of the users home region</param>
|
||||
/// <param name="homeRegionID"> The UUID of the user's home region</param>
|
||||
/// <param name="homeLocX">Home region position vector</param>
|
||||
/// <param name="homeLocY">Home region position vector</param>
|
||||
/// <param name="homeLocZ">Home region position vector</param>
|
||||
|
@ -770,22 +771,22 @@ namespace OpenSim.Data.MySQL
|
|||
/// <param name="webLoginKey">Ignored</param>
|
||||
/// <returns>Success?</returns>
|
||||
public bool insertUserRow(UUID uuid, string username, string lastname, string email, string passwordHash,
|
||||
string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ,
|
||||
string passwordSalt, UInt64 homeRegion, UUID homeRegionID, float homeLocX, float homeLocY, float homeLocZ,
|
||||
float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin,
|
||||
string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask,
|
||||
string aboutText, string firstText,
|
||||
UUID profileImage, UUID firstImage, UUID webLoginKey)
|
||||
UUID profileImage, UUID firstImage, UUID webLoginKey, int userFlags, int godLevel, string customType, UUID partner)
|
||||
{
|
||||
m_log.Debug("[MySQLManager]: Fetching profile for " + uuid.ToString());
|
||||
string sql =
|
||||
"INSERT INTO users (`UUID`, `username`, `lastname`, `email`, `passwordHash`, `passwordSalt`, `homeRegion`, ";
|
||||
"INSERT INTO users (`UUID`, `username`, `lastname`, `email`, `passwordHash`, `passwordSalt`, `homeRegion`, `homeRegionID`, ";
|
||||
sql +=
|
||||
"`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, ";
|
||||
sql +=
|
||||
"`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, ";
|
||||
sql += "`profileFirstText`, `profileImage`, `profileFirstImage`, `webLoginKey`, `userFlags`, `godLevel`, `customType`, `partner`) VALUES ";
|
||||
|
||||
sql += "(?UUID, ?username, ?lastname, ?email, ?passwordHash, ?passwordSalt, ?homeRegion, ";
|
||||
sql += "(?UUID, ?username, ?lastname, ?email, ?passwordHash, ?passwordSalt, ?homeRegion, ?homeRegionID, ";
|
||||
sql +=
|
||||
"?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, ";
|
||||
sql +=
|
||||
|
@ -800,6 +801,7 @@ namespace OpenSim.Data.MySQL
|
|||
parameters["?passwordHash"] = passwordHash;
|
||||
parameters["?passwordSalt"] = passwordSalt;
|
||||
parameters["?homeRegion"] = homeRegion.ToString();
|
||||
parameters["?homeRegionID"] = homeRegionID.ToString();
|
||||
parameters["?homeLocationX"] = homeLocX.ToString();
|
||||
parameters["?homeLocationY"] = homeLocY.ToString();
|
||||
parameters["?homeLocationZ"] = homeLocZ.ToString();
|
||||
|
@ -808,21 +810,19 @@ namespace OpenSim.Data.MySQL
|
|||
parameters["?homeLookAtZ"] = homeLookAtZ.ToString();
|
||||
parameters["?created"] = created.ToString();
|
||||
parameters["?lastLogin"] = lastlogin.ToString();
|
||||
parameters["?userInventoryURI"] = String.Empty;
|
||||
parameters["?userAssetURI"] = String.Empty;
|
||||
parameters["?profileCanDoMask"] = "0";
|
||||
parameters["?profileWantDoMask"] = "0";
|
||||
parameters["?userInventoryURI"] = inventoryURI;
|
||||
parameters["?userAssetURI"] = assetURI;
|
||||
parameters["?profileCanDoMask"] = canDoMask.ToString();
|
||||
parameters["?profileWantDoMask"] = wantDoMask.ToString();
|
||||
parameters["?profileAboutText"] = aboutText;
|
||||
parameters["?profileFirstText"] = firstText;
|
||||
parameters["?profileImage"] = profileImage.ToString();
|
||||
parameters["?profileFirstImage"] = firstImage.ToString();
|
||||
parameters["?webLoginKey"] = string.Empty;
|
||||
parameters["?userFlags"] = "0";
|
||||
parameters["?godLevel"] = "0";
|
||||
parameters["?customType"] = "";
|
||||
parameters["?partner"] = "";
|
||||
|
||||
|
||||
parameters["?webLoginKey"] = webLoginKey.ToString();
|
||||
parameters["?userFlags"] = userFlags.ToString();
|
||||
parameters["?godLevel"] = godLevel.ToString();
|
||||
parameters["?customType"] = customType == null ? "" : customType;
|
||||
parameters["?partner"] = partner.ToString();
|
||||
bool returnval = false;
|
||||
|
||||
try
|
||||
|
@ -911,8 +911,8 @@ namespace OpenSim.Data.MySQL
|
|||
parameters["?lastLogin"] = lastlogin.ToString();
|
||||
parameters["?userInventoryURI"] = inventoryURI;
|
||||
parameters["?userAssetURI"] = assetURI;
|
||||
parameters["?profileCanDoMask"] = "0";
|
||||
parameters["?profileWantDoMask"] = "0";
|
||||
parameters["?profileCanDoMask"] = canDoMask.ToString();
|
||||
parameters["?profileWantDoMask"] = wantDoMask.ToString();
|
||||
parameters["?profileAboutText"] = aboutText;
|
||||
parameters["?profileFirstText"] = firstText;
|
||||
parameters["?profileImage"] = profileImage.ToString();
|
||||
|
|
|
@ -643,13 +643,13 @@ namespace OpenSim.Data.MySQL
|
|||
try
|
||||
{
|
||||
dbm.Manager.insertUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
|
||||
user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y,
|
||||
user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y,
|
||||
user.HomeLocation.Z,
|
||||
user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created,
|
||||
user.LastLogin, user.UserInventoryURI, user.UserAssetURI,
|
||||
user.CanDoMask, user.WantDoMask,
|
||||
user.AboutText, user.FirstLifeAboutText, user.Image,
|
||||
user.FirstLifeImage, user.WebLoginKey);
|
||||
user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
@ -46,6 +46,7 @@ namespace OpenSim.Data.Tests
|
|||
public UUID user2;
|
||||
public UUID user3;
|
||||
public UUID user4;
|
||||
public UUID user5;
|
||||
public UUID webkey;
|
||||
public UUID zero = UUID.Zero;
|
||||
public static Random random;
|
||||
|
@ -81,6 +82,7 @@ namespace OpenSim.Data.Tests
|
|||
user2 = UUID.Random();
|
||||
user3 = UUID.Random();
|
||||
user4 = UUID.Random();
|
||||
user5 = UUID.Random();
|
||||
agent1 = UUID.Random();
|
||||
agent2 = UUID.Random();
|
||||
agent3 = UUID.Random();
|
||||
|
@ -191,20 +193,20 @@ namespace OpenSim.Data.Tests
|
|||
public void T015_UserPersistency()
|
||||
{
|
||||
UserProfileData u = new UserProfileData();
|
||||
UUID id = UUID.Random();
|
||||
UUID id = user5;
|
||||
string fname = RandomName();
|
||||
string lname = RandomName();
|
||||
string email = RandomName();
|
||||
string passhash = RandomName();
|
||||
string passsalt = RandomName();
|
||||
UUID homeregion = UUID.Random();
|
||||
UUID webloginkey = UUID.Random();
|
||||
uint homeregx = (uint) random.Next();
|
||||
uint homeregy = (uint) random.Next();
|
||||
Vector3 homeloc = new Vector3((float) random.NextDouble(),(float) random.NextDouble(),(float) random.NextDouble());
|
||||
Vector3 homelookat = new Vector3((float)random.NextDouble(),(float)random.NextDouble(),(float)random.NextDouble());
|
||||
Vector3 homeloc = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5));
|
||||
Vector3 homelookat = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5));
|
||||
int created = random.Next();
|
||||
int lastlogin = random.Next();
|
||||
UUID rootinvfolder = UUID.Random();
|
||||
string userinvuri = RandomName();
|
||||
string userasseturi = RandomName();
|
||||
uint candomask = (uint) random.Next();
|
||||
|
@ -219,20 +221,25 @@ namespace OpenSim.Data.Tests
|
|||
string customtype = RandomName();
|
||||
UUID partner = UUID.Random();
|
||||
|
||||
//HomeRegionX and HomeRegionY must only use 24 bits
|
||||
homeregx = ((homeregx << 8) >> 8);
|
||||
homeregy = ((homeregy << 8) >> 8);
|
||||
|
||||
u.ID = id;
|
||||
u.WebLoginKey = webloginkey;
|
||||
u.HomeRegionID = homeregion;
|
||||
u.FirstName = fname;
|
||||
u.SurName = lname;
|
||||
u.Email = email;
|
||||
u.PasswordHash = passhash;
|
||||
u.PasswordSalt = passsalt;
|
||||
u.HomeRegionX = homeregx;
|
||||
u.HomeRegionY = homeregy;
|
||||
ulong homereg = u.HomeRegion;
|
||||
u.HomeLocation = homeloc;
|
||||
u.HomeLookAt = homelookat;
|
||||
u.Created = created;
|
||||
u.LastLogin = lastlogin;
|
||||
u.RootInventoryFolderID = rootinvfolder;
|
||||
u.UserInventoryURI = userinvuri;
|
||||
u.UserAssetURI = userasseturi;
|
||||
u.CanDoMask = candomask;
|
||||
|
@ -250,31 +257,135 @@ namespace OpenSim.Data.Tests
|
|||
db.AddNewUserProfile(u);
|
||||
UserProfileData u1a = db.GetUserByUUID(id);
|
||||
Assert.That(u1a,Is.Not.Null);
|
||||
Assert.That(homeregion,Is.EqualTo(u.HomeRegionID));
|
||||
Assert.That(webloginkey,Is.EqualTo(u.WebLoginKey));
|
||||
Assert.That(fname,Is.EqualTo(u.FirstName));
|
||||
Assert.That(lname,Is.EqualTo(u.SurName));
|
||||
Assert.That(passhash,Is.EqualTo(u.PasswordHash));
|
||||
Assert.That(passsalt,Is.EqualTo(u.PasswordSalt));
|
||||
Assert.That(homeregx,Is.EqualTo(u.HomeRegionX));
|
||||
Assert.That(homeregy,Is.EqualTo(u.HomeRegionY));
|
||||
Assert.That(homeloc,Is.EqualTo(u.HomeLocation));
|
||||
Assert.That(homelookat,Is.EqualTo(u.HomeLookAt));
|
||||
Assert.That(created,Is.EqualTo(u.Created));
|
||||
Assert.That(lastlogin,Is.EqualTo(u.LastLogin));
|
||||
Assert.That(rootinvfolder,Is.EqualTo(u.RootInventoryFolderID));
|
||||
Assert.That(userinvuri,Is.EqualTo(u.UserInventoryURI));
|
||||
Assert.That(userasseturi,Is.EqualTo(u.UserAssetURI));
|
||||
Assert.That(candomask,Is.EqualTo(u.CanDoMask));
|
||||
Assert.That(abouttext,Is.EqualTo(u.AboutText));
|
||||
Assert.That(flabouttext,Is.EqualTo(u.FirstLifeAboutText));
|
||||
Assert.That(image,Is.EqualTo(u.Image));
|
||||
Assert.That(firstimage,Is.EqualTo(u.FirstLifeImage));
|
||||
Assert.That(agent,Is.EqualTo(u.CurrentAgent));
|
||||
Assert.That(userflags,Is.EqualTo(u.UserFlags));
|
||||
Assert.That(godlevel,Is.EqualTo(u.GodLevel));
|
||||
Assert.That(customtype,Is.EqualTo(u.CustomType));
|
||||
Assert.That(partner,Is.EqualTo(u.Partner));
|
||||
Assert.That(id,Is.EqualTo(u1a.ID));
|
||||
Assert.That(homeregion,Is.EqualTo(u1a.HomeRegionID));
|
||||
Assert.That(webloginkey,Is.EqualTo(u1a.WebLoginKey));
|
||||
Assert.That(fname,Is.EqualTo(u1a.FirstName));
|
||||
Assert.That(lname,Is.EqualTo(u1a.SurName));
|
||||
Assert.That(email,Is.EqualTo(u1a.Email));
|
||||
Assert.That(passhash,Is.EqualTo(u1a.PasswordHash));
|
||||
Assert.That(passsalt,Is.EqualTo(u1a.PasswordSalt));
|
||||
Assert.That(homeregx,Is.EqualTo(u1a.HomeRegionX));
|
||||
Assert.That(homeregy,Is.EqualTo(u1a.HomeRegionY));
|
||||
Assert.That(homereg,Is.EqualTo(u1a.HomeRegion));
|
||||
Assert.That(homeloc,Is.EqualTo(u1a.HomeLocation));
|
||||
Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt));
|
||||
Assert.That(created,Is.EqualTo(u1a.Created));
|
||||
Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin));
|
||||
// RootInventoryFolderID is not tested because it is saved in SQLite,
|
||||
// but not in MySQL
|
||||
Assert.That(userinvuri,Is.EqualTo(u1a.UserInventoryURI));
|
||||
Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI));
|
||||
Assert.That(candomask,Is.EqualTo(u1a.CanDoMask));
|
||||
Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask));
|
||||
Assert.That(abouttext,Is.EqualTo(u1a.AboutText));
|
||||
Assert.That(flabouttext,Is.EqualTo(u1a.FirstLifeAboutText));
|
||||
Assert.That(image,Is.EqualTo(u1a.Image));
|
||||
Assert.That(firstimage,Is.EqualTo(u1a.FirstLifeImage));
|
||||
Assert.That(u1a.CurrentAgent,Is.Null);
|
||||
Assert.That(userflags,Is.EqualTo(u1a.UserFlags));
|
||||
Assert.That(godlevel,Is.EqualTo(u1a.GodLevel));
|
||||
Assert.That(customtype,Is.EqualTo(u1a.CustomType));
|
||||
Assert.That(partner,Is.EqualTo(u1a.Partner));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void T016_UserUpdatePersistency()
|
||||
{
|
||||
UUID id = user5;
|
||||
UserProfileData u = db.GetUserByUUID(id);
|
||||
string fname = RandomName();
|
||||
string lname = RandomName();
|
||||
string email = RandomName();
|
||||
string passhash = RandomName();
|
||||
string passsalt = RandomName();
|
||||
UUID homeregionid = UUID.Random();
|
||||
UUID webloginkey = UUID.Random();
|
||||
uint homeregx = (uint) random.Next();
|
||||
uint homeregy = (uint) random.Next();
|
||||
Vector3 homeloc = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5));
|
||||
Vector3 homelookat = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5));
|
||||
int created = random.Next();
|
||||
int lastlogin = random.Next();
|
||||
string userinvuri = RandomName();
|
||||
string userasseturi = RandomName();
|
||||
uint candomask = (uint) random.Next();
|
||||
uint wantdomask = (uint) random.Next();
|
||||
string abouttext = RandomName();
|
||||
string flabouttext = RandomName();
|
||||
UUID image = UUID.Random();
|
||||
UUID firstimage = UUID.Random();
|
||||
UserAgentData agent = NewAgent(id,UUID.Random());
|
||||
int userflags = random.Next();
|
||||
int godlevel = random.Next();
|
||||
string customtype = RandomName();
|
||||
UUID partner = UUID.Random();
|
||||
|
||||
//HomeRegionX and HomeRegionY must only use 24 bits
|
||||
homeregx = ((homeregx << 8) >> 8);
|
||||
homeregy = ((homeregy << 8) >> 8);
|
||||
|
||||
u.WebLoginKey = webloginkey;
|
||||
u.HomeRegionID = homeregionid;
|
||||
u.FirstName = fname;
|
||||
u.SurName = lname;
|
||||
u.Email = email;
|
||||
u.PasswordHash = passhash;
|
||||
u.PasswordSalt = passsalt;
|
||||
u.HomeRegionX = homeregx;
|
||||
u.HomeRegionY = homeregy;
|
||||
ulong homereg = u.HomeRegion;
|
||||
u.HomeLocation = homeloc;
|
||||
u.HomeLookAt = homelookat;
|
||||
u.Created = created;
|
||||
u.LastLogin = lastlogin;
|
||||
u.UserInventoryURI = userinvuri;
|
||||
u.UserAssetURI = userasseturi;
|
||||
u.CanDoMask = candomask;
|
||||
u.WantDoMask = wantdomask;
|
||||
u.AboutText = abouttext;
|
||||
u.FirstLifeAboutText = flabouttext;
|
||||
u.Image = image;
|
||||
u.FirstLifeImage = firstimage;
|
||||
u.CurrentAgent = agent;
|
||||
u.UserFlags = userflags;
|
||||
u.GodLevel = godlevel;
|
||||
u.CustomType = customtype;
|
||||
u.Partner = partner;
|
||||
|
||||
db.UpdateUserProfile(u);
|
||||
UserProfileData u1a = db.GetUserByUUID(id);
|
||||
Assert.That(u1a,Is.Not.Null);
|
||||
Assert.That(id,Is.EqualTo(u1a.ID));
|
||||
Assert.That(homeregionid,Is.EqualTo(u1a.HomeRegionID));
|
||||
Assert.That(webloginkey,Is.EqualTo(u1a.WebLoginKey));
|
||||
Assert.That(fname,Is.EqualTo(u1a.FirstName));
|
||||
Assert.That(lname,Is.EqualTo(u1a.SurName));
|
||||
Assert.That(email,Is.EqualTo(u1a.Email));
|
||||
Assert.That(passhash,Is.EqualTo(u1a.PasswordHash));
|
||||
Assert.That(passsalt,Is.EqualTo(u1a.PasswordSalt));
|
||||
Assert.That(homereg,Is.EqualTo(u1a.HomeRegion));
|
||||
Assert.That(homeregx,Is.EqualTo(u1a.HomeRegionX));
|
||||
Assert.That(homeregy,Is.EqualTo(u1a.HomeRegionY));
|
||||
Assert.That(homereg,Is.EqualTo(u1a.HomeRegion));
|
||||
Assert.That(homeloc,Is.EqualTo(u1a.HomeLocation));
|
||||
Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt));
|
||||
Assert.That(created,Is.EqualTo(u1a.Created));
|
||||
Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin));
|
||||
// RootInventoryFolderID is not tested because it is saved in SQLite,
|
||||
// but not in MySQL
|
||||
Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI));
|
||||
Assert.That(candomask,Is.EqualTo(u1a.CanDoMask));
|
||||
Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask));
|
||||
Assert.That(abouttext,Is.EqualTo(u1a.AboutText));
|
||||
Assert.That(flabouttext,Is.EqualTo(u1a.FirstLifeAboutText));
|
||||
Assert.That(image,Is.EqualTo(u1a.Image));
|
||||
Assert.That(firstimage,Is.EqualTo(u1a.FirstLifeImage));
|
||||
Assert.That(u1a.CurrentAgent,Is.Null);
|
||||
Assert.That(userflags,Is.EqualTo(u1a.UserFlags));
|
||||
Assert.That(godlevel,Is.EqualTo(u1a.GodLevel));
|
||||
Assert.That(customtype,Is.EqualTo(u1a.CustomType));
|
||||
Assert.That(partner,Is.EqualTo(u1a.Partner));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -394,7 +505,6 @@ namespace OpenSim.Data.Tests
|
|||
u.SurName = lname;
|
||||
u.PasswordHash = "NOTAHASH";
|
||||
u.PasswordSalt = "NOTSALT";
|
||||
u.Email = "nobody@nodomain.nocc";
|
||||
// MUST specify at least these 5 parameters or an exception is raised
|
||||
|
||||
return u;
|
||||
|
|
Loading…
Reference in New Issue