aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/Tests/BasicUserTest.cs
diff options
context:
space:
mode:
authorSean Dague2008-11-06 17:07:08 +0000
committerSean Dague2008-11-06 17:07:08 +0000
commit46492f3c1182d68139f914bfe89c81ca8dae1733 (patch)
treefde57370dd37966aa0c034faaeb24570fb71cd14 /OpenSim/Data/Tests/BasicUserTest.cs
parentDisable distance sorting for child agents. It makes no sense there, as the (diff)
downloadopensim-SC_OLD-46492f3c1182d68139f914bfe89c81ca8dae1733.zip
opensim-SC_OLD-46492f3c1182d68139f914bfe89c81ca8dae1733.tar.gz
opensim-SC_OLD-46492f3c1182d68139f914bfe89c81ca8dae1733.tar.bz2
opensim-SC_OLD-46492f3c1182d68139f914bfe89c81ca8dae1733.tar.xz
From: arthursv@linux.vnet.ibm.com
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.
Diffstat (limited to 'OpenSim/Data/Tests/BasicUserTest.cs')
-rw-r--r--OpenSim/Data/Tests/BasicUserTest.cs172
1 files changed, 141 insertions, 31 deletions
diff --git a/OpenSim/Data/Tests/BasicUserTest.cs b/OpenSim/Data/Tests/BasicUserTest.cs
index ba6da68..e9e61d0 100644
--- a/OpenSim/Data/Tests/BasicUserTest.cs
+++ b/OpenSim/Data/Tests/BasicUserTest.cs
@@ -46,6 +46,7 @@ namespace OpenSim.Data.Tests
46 public UUID user2; 46 public UUID user2;
47 public UUID user3; 47 public UUID user3;
48 public UUID user4; 48 public UUID user4;
49 public UUID user5;
49 public UUID webkey; 50 public UUID webkey;
50 public UUID zero = UUID.Zero; 51 public UUID zero = UUID.Zero;
51 public static Random random; 52 public static Random random;
@@ -81,6 +82,7 @@ namespace OpenSim.Data.Tests
81 user2 = UUID.Random(); 82 user2 = UUID.Random();
82 user3 = UUID.Random(); 83 user3 = UUID.Random();
83 user4 = UUID.Random(); 84 user4 = UUID.Random();
85 user5 = UUID.Random();
84 agent1 = UUID.Random(); 86 agent1 = UUID.Random();
85 agent2 = UUID.Random(); 87 agent2 = UUID.Random();
86 agent3 = UUID.Random(); 88 agent3 = UUID.Random();
@@ -191,20 +193,20 @@ namespace OpenSim.Data.Tests
191 public void T015_UserPersistency() 193 public void T015_UserPersistency()
192 { 194 {
193 UserProfileData u = new UserProfileData(); 195 UserProfileData u = new UserProfileData();
194 UUID id = UUID.Random(); 196 UUID id = user5;
195 string fname = RandomName(); 197 string fname = RandomName();
196 string lname = RandomName(); 198 string lname = RandomName();
199 string email = RandomName();
197 string passhash = RandomName(); 200 string passhash = RandomName();
198 string passsalt = RandomName(); 201 string passsalt = RandomName();
199 UUID homeregion = UUID.Random(); 202 UUID homeregion = UUID.Random();
200 UUID webloginkey = UUID.Random(); 203 UUID webloginkey = UUID.Random();
201 uint homeregx = (uint) random.Next(); 204 uint homeregx = (uint) random.Next();
202 uint homeregy = (uint) random.Next(); 205 uint homeregy = (uint) random.Next();
203 Vector3 homeloc = new Vector3((float) random.NextDouble(),(float) random.NextDouble(),(float) random.NextDouble()); 206 Vector3 homeloc = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5));
204 Vector3 homelookat = new Vector3((float)random.NextDouble(),(float)random.NextDouble(),(float)random.NextDouble()); 207 Vector3 homelookat = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5));
205 int created = random.Next(); 208 int created = random.Next();
206 int lastlogin = random.Next(); 209 int lastlogin = random.Next();
207 UUID rootinvfolder = UUID.Random();
208 string userinvuri = RandomName(); 210 string userinvuri = RandomName();
209 string userasseturi = RandomName(); 211 string userasseturi = RandomName();
210 uint candomask = (uint) random.Next(); 212 uint candomask = (uint) random.Next();
@@ -219,20 +221,25 @@ namespace OpenSim.Data.Tests
219 string customtype = RandomName(); 221 string customtype = RandomName();
220 UUID partner = UUID.Random(); 222 UUID partner = UUID.Random();
221 223
224 //HomeRegionX and HomeRegionY must only use 24 bits
225 homeregx = ((homeregx << 8) >> 8);
226 homeregy = ((homeregy << 8) >> 8);
227
222 u.ID = id; 228 u.ID = id;
223 u.WebLoginKey = webloginkey; 229 u.WebLoginKey = webloginkey;
224 u.HomeRegionID = homeregion; 230 u.HomeRegionID = homeregion;
225 u.FirstName = fname; 231 u.FirstName = fname;
226 u.SurName = lname; 232 u.SurName = lname;
233 u.Email = email;
227 u.PasswordHash = passhash; 234 u.PasswordHash = passhash;
228 u.PasswordSalt = passsalt; 235 u.PasswordSalt = passsalt;
229 u.HomeRegionX = homeregx; 236 u.HomeRegionX = homeregx;
230 u.HomeRegionY = homeregy; 237 u.HomeRegionY = homeregy;
238 ulong homereg = u.HomeRegion;
231 u.HomeLocation = homeloc; 239 u.HomeLocation = homeloc;
232 u.HomeLookAt = homelookat; 240 u.HomeLookAt = homelookat;
233 u.Created = created; 241 u.Created = created;
234 u.LastLogin = lastlogin; 242 u.LastLogin = lastlogin;
235 u.RootInventoryFolderID = rootinvfolder;
236 u.UserInventoryURI = userinvuri; 243 u.UserInventoryURI = userinvuri;
237 u.UserAssetURI = userasseturi; 244 u.UserAssetURI = userasseturi;
238 u.CanDoMask = candomask; 245 u.CanDoMask = candomask;
@@ -250,34 +257,138 @@ namespace OpenSim.Data.Tests
250 db.AddNewUserProfile(u); 257 db.AddNewUserProfile(u);
251 UserProfileData u1a = db.GetUserByUUID(id); 258 UserProfileData u1a = db.GetUserByUUID(id);
252 Assert.That(u1a,Is.Not.Null); 259 Assert.That(u1a,Is.Not.Null);
253 Assert.That(homeregion,Is.EqualTo(u.HomeRegionID)); 260 Assert.That(id,Is.EqualTo(u1a.ID));
254 Assert.That(webloginkey,Is.EqualTo(u.WebLoginKey)); 261 Assert.That(homeregion,Is.EqualTo(u1a.HomeRegionID));
255 Assert.That(fname,Is.EqualTo(u.FirstName)); 262 Assert.That(webloginkey,Is.EqualTo(u1a.WebLoginKey));
256 Assert.That(lname,Is.EqualTo(u.SurName)); 263 Assert.That(fname,Is.EqualTo(u1a.FirstName));
257 Assert.That(passhash,Is.EqualTo(u.PasswordHash)); 264 Assert.That(lname,Is.EqualTo(u1a.SurName));
258 Assert.That(passsalt,Is.EqualTo(u.PasswordSalt)); 265 Assert.That(email,Is.EqualTo(u1a.Email));
259 Assert.That(homeregx,Is.EqualTo(u.HomeRegionX)); 266 Assert.That(passhash,Is.EqualTo(u1a.PasswordHash));
260 Assert.That(homeregy,Is.EqualTo(u.HomeRegionY)); 267 Assert.That(passsalt,Is.EqualTo(u1a.PasswordSalt));
261 Assert.That(homeloc,Is.EqualTo(u.HomeLocation)); 268 Assert.That(homeregx,Is.EqualTo(u1a.HomeRegionX));
262 Assert.That(homelookat,Is.EqualTo(u.HomeLookAt)); 269 Assert.That(homeregy,Is.EqualTo(u1a.HomeRegionY));
263 Assert.That(created,Is.EqualTo(u.Created)); 270 Assert.That(homereg,Is.EqualTo(u1a.HomeRegion));
264 Assert.That(lastlogin,Is.EqualTo(u.LastLogin)); 271 Assert.That(homeloc,Is.EqualTo(u1a.HomeLocation));
265 Assert.That(rootinvfolder,Is.EqualTo(u.RootInventoryFolderID)); 272 Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt));
266 Assert.That(userinvuri,Is.EqualTo(u.UserInventoryURI)); 273 Assert.That(created,Is.EqualTo(u1a.Created));
267 Assert.That(userasseturi,Is.EqualTo(u.UserAssetURI)); 274 Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin));
268 Assert.That(candomask,Is.EqualTo(u.CanDoMask)); 275 // RootInventoryFolderID is not tested because it is saved in SQLite,
269 Assert.That(abouttext,Is.EqualTo(u.AboutText)); 276 // but not in MySQL
270 Assert.That(flabouttext,Is.EqualTo(u.FirstLifeAboutText)); 277 Assert.That(userinvuri,Is.EqualTo(u1a.UserInventoryURI));
271 Assert.That(image,Is.EqualTo(u.Image)); 278 Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI));
272 Assert.That(firstimage,Is.EqualTo(u.FirstLifeImage)); 279 Assert.That(candomask,Is.EqualTo(u1a.CanDoMask));
273 Assert.That(agent,Is.EqualTo(u.CurrentAgent)); 280 Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask));
274 Assert.That(userflags,Is.EqualTo(u.UserFlags)); 281 Assert.That(abouttext,Is.EqualTo(u1a.AboutText));
275 Assert.That(godlevel,Is.EqualTo(u.GodLevel)); 282 Assert.That(flabouttext,Is.EqualTo(u1a.FirstLifeAboutText));
276 Assert.That(customtype,Is.EqualTo(u.CustomType)); 283 Assert.That(image,Is.EqualTo(u1a.Image));
277 Assert.That(partner,Is.EqualTo(u.Partner)); 284 Assert.That(firstimage,Is.EqualTo(u1a.FirstLifeImage));
285 Assert.That(u1a.CurrentAgent,Is.Null);
286 Assert.That(userflags,Is.EqualTo(u1a.UserFlags));
287 Assert.That(godlevel,Is.EqualTo(u1a.GodLevel));
288 Assert.That(customtype,Is.EqualTo(u1a.CustomType));
289 Assert.That(partner,Is.EqualTo(u1a.Partner));
278 } 290 }
279 291
280 [Test] 292 [Test]
293 public void T016_UserUpdatePersistency()
294 {
295 UUID id = user5;
296 UserProfileData u = db.GetUserByUUID(id);
297 string fname = RandomName();
298 string lname = RandomName();
299 string email = RandomName();
300 string passhash = RandomName();
301 string passsalt = RandomName();
302 UUID homeregionid = UUID.Random();
303 UUID webloginkey = UUID.Random();
304 uint homeregx = (uint) random.Next();
305 uint homeregy = (uint) random.Next();
306 Vector3 homeloc = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5));
307 Vector3 homelookat = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5));
308 int created = random.Next();
309 int lastlogin = random.Next();
310 string userinvuri = RandomName();
311 string userasseturi = RandomName();
312 uint candomask = (uint) random.Next();
313 uint wantdomask = (uint) random.Next();
314 string abouttext = RandomName();
315 string flabouttext = RandomName();
316 UUID image = UUID.Random();
317 UUID firstimage = UUID.Random();
318 UserAgentData agent = NewAgent(id,UUID.Random());
319 int userflags = random.Next();
320 int godlevel = random.Next();
321 string customtype = RandomName();
322 UUID partner = UUID.Random();
323
324 //HomeRegionX and HomeRegionY must only use 24 bits
325 homeregx = ((homeregx << 8) >> 8);
326 homeregy = ((homeregy << 8) >> 8);
327
328 u.WebLoginKey = webloginkey;
329 u.HomeRegionID = homeregionid;
330 u.FirstName = fname;
331 u.SurName = lname;
332 u.Email = email;
333 u.PasswordHash = passhash;
334 u.PasswordSalt = passsalt;
335 u.HomeRegionX = homeregx;
336 u.HomeRegionY = homeregy;
337 ulong homereg = u.HomeRegion;
338 u.HomeLocation = homeloc;
339 u.HomeLookAt = homelookat;
340 u.Created = created;
341 u.LastLogin = lastlogin;
342 u.UserInventoryURI = userinvuri;
343 u.UserAssetURI = userasseturi;
344 u.CanDoMask = candomask;
345 u.WantDoMask = wantdomask;
346 u.AboutText = abouttext;
347 u.FirstLifeAboutText = flabouttext;
348 u.Image = image;
349 u.FirstLifeImage = firstimage;
350 u.CurrentAgent = agent;
351 u.UserFlags = userflags;
352 u.GodLevel = godlevel;
353 u.CustomType = customtype;
354 u.Partner = partner;
355
356 db.UpdateUserProfile(u);
357 UserProfileData u1a = db.GetUserByUUID(id);
358 Assert.That(u1a,Is.Not.Null);
359 Assert.That(id,Is.EqualTo(u1a.ID));
360 Assert.That(homeregionid,Is.EqualTo(u1a.HomeRegionID));
361 Assert.That(webloginkey,Is.EqualTo(u1a.WebLoginKey));
362 Assert.That(fname,Is.EqualTo(u1a.FirstName));
363 Assert.That(lname,Is.EqualTo(u1a.SurName));
364 Assert.That(email,Is.EqualTo(u1a.Email));
365 Assert.That(passhash,Is.EqualTo(u1a.PasswordHash));
366 Assert.That(passsalt,Is.EqualTo(u1a.PasswordSalt));
367 Assert.That(homereg,Is.EqualTo(u1a.HomeRegion));
368 Assert.That(homeregx,Is.EqualTo(u1a.HomeRegionX));
369 Assert.That(homeregy,Is.EqualTo(u1a.HomeRegionY));
370 Assert.That(homereg,Is.EqualTo(u1a.HomeRegion));
371 Assert.That(homeloc,Is.EqualTo(u1a.HomeLocation));
372 Assert.That(homelookat,Is.EqualTo(u1a.HomeLookAt));
373 Assert.That(created,Is.EqualTo(u1a.Created));
374 Assert.That(lastlogin,Is.EqualTo(u1a.LastLogin));
375 // RootInventoryFolderID is not tested because it is saved in SQLite,
376 // but not in MySQL
377 Assert.That(userasseturi,Is.EqualTo(u1a.UserAssetURI));
378 Assert.That(candomask,Is.EqualTo(u1a.CanDoMask));
379 Assert.That(wantdomask,Is.EqualTo(u1a.WantDoMask));
380 Assert.That(abouttext,Is.EqualTo(u1a.AboutText));
381 Assert.That(flabouttext,Is.EqualTo(u1a.FirstLifeAboutText));
382 Assert.That(image,Is.EqualTo(u1a.Image));
383 Assert.That(firstimage,Is.EqualTo(u1a.FirstLifeImage));
384 Assert.That(u1a.CurrentAgent,Is.Null);
385 Assert.That(userflags,Is.EqualTo(u1a.UserFlags));
386 Assert.That(godlevel,Is.EqualTo(u1a.GodLevel));
387 Assert.That(customtype,Is.EqualTo(u1a.CustomType));
388 Assert.That(partner,Is.EqualTo(u1a.Partner));
389 }
390
391 [Test]
281 public void T020_CreateAgent() 392 public void T020_CreateAgent()
282 { 393 {
283 UserAgentData a1 = NewAgent(user1,agent1); 394 UserAgentData a1 = NewAgent(user1,agent1);
@@ -394,7 +505,6 @@ namespace OpenSim.Data.Tests
394 u.SurName = lname; 505 u.SurName = lname;
395 u.PasswordHash = "NOTAHASH"; 506 u.PasswordHash = "NOTAHASH";
396 u.PasswordSalt = "NOTSALT"; 507 u.PasswordSalt = "NOTSALT";
397 u.Email = "nobody@nodomain.nocc";
398 // MUST specify at least these 5 parameters or an exception is raised 508 // MUST specify at least these 5 parameters or an exception is raised
399 509
400 return u; 510 return u;