summaryrefslogtreecommitdiff
path: root/indra/test/llpermissions_tut.cpp
blob: 9dbb9642dd91771f9c1802149894e80c4e68efe5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
/**
 * @file llpermissions_tut.cpp
 * @author Adroit
 * @date March 2007
 * @brief llpermissions test cases.
 *
 * $LicenseInfo:firstyear=2007&license=viewergpl$
 * 
 * Copyright (c) 2007-2009, Linden Research, Inc.
 * 
 * Second Life Viewer Source Code
 * The source code in this file ("Source Code") is provided by Linden Lab
 * to you under the terms of the GNU General Public License, version 2.0
 * ("GPL"), unless you have obtained a separate licensing agreement
 * ("Other License"), formally executed by you and Linden Lab.  Terms of
 * the GPL can be found in doc/GPL-license.txt in this distribution, or
 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
 * 
 * There are special exceptions to the terms and conditions of the GPL as
 * it is applied to this Source Code. View the full text of the exception
 * in the file doc/FLOSS-exception.txt in this software distribution, or
 * online at
 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
 * 
 * By copying, modifying or distributing this software, you acknowledge
 * that you have read and understood your obligations described above,
 * and agree to abide by those obligations.
 * 
 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
 * COMPLETENESS OR PERFORMANCE.
 * $/LicenseInfo$
 */
 
#include <tut/tut.hpp>
#include "linden_common.h"
#include "lltut.h"
#include "message.h"
#include "llpermissions.h"


namespace tut
{
	struct permission
	{
	};
	typedef test_group<permission> permission_t;
	typedef permission_t::object permission_object_t;
	tut::permission_t tut_permission("permission");

	template<> template<>
	void permission_object_t::test<1>()
	{
		LLPermissions permissions;
		LLUUID	uuid = permissions.getCreator();
		LLUUID	uuid1 = permissions.getOwner(); 
		LLUUID	uuid2 = permissions.getGroup();
		LLUUID	uuid3 = permissions.getLastOwner(); 

		ensure("LLPermission Get Functions failed", (uuid == LLUUID::null && uuid1 == LLUUID::null && 
			uuid2 == LLUUID::null && uuid3 == LLUUID::null));
		ensure("LLPermission Get Functions failed", (permissions.getMaskBase() == PERM_ALL && permissions.getMaskOwner() == PERM_ALL && 
			permissions.getMaskGroup() == PERM_ALL && permissions.getMaskEveryone() == PERM_ALL && permissions.getMaskNextOwner() == PERM_ALL));
		ensure("Ownership functions failed", (permissions.isGroupOwned() == FALSE && permissions.isOwned() == FALSE));
	}

	template<> template<>
	void permission_object_t::test<2>()
	{
		LLPermissions permissions;
		LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
		LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		permissions.init(creator, owner, lastOwner, group);

		ensure_equals("init/getCreator():failed to return the creator ", creator, permissions.getCreator());	
		ensure_equals("init/getOwner():failed to return the owner ", owner, permissions.getOwner());
		ensure_equals("init/getLastOwner():failed to return the group ", lastOwner, permissions.getLastOwner());	
		ensure_equals("init/getGroup():failed to return the group ", group, permissions.getGroup());	
	}

	template<> template<>
	void permission_object_t::test<3>()
	{
		LLPermissions permissions;
		U32 base = PERM_ALL;
		U32 owner = PERM_ITEM_UNRESTRICTED; //PERM_ITEM_UNRESTRICTED = PERM_MODIFY | PERM_COPY | PERM_TRANSFER;
		U32 group = PERM_TRANSFER | PERM_MOVE | PERM_COPY|PERM_MODIFY;
		U32 everyone = PERM_TRANSFER | PERM_MOVE | PERM_MODIFY;
		U32 next = PERM_NONE;

		U32 fixedbase = base;
		U32 fixedowner = PERM_ITEM_UNRESTRICTED; //owner & fixedbase
		U32 fixedgroup = PERM_ITEM_UNRESTRICTED; // no PERM_MOVE as owner does not have that perm either
		U32 fixedeveryone = PERM_TRANSFER; // no PERM_MOVE. Everyone can never modify.
		U32 fixednext = PERM_NONE;

		permissions.initMasks(base, owner, everyone, group, next); // will fix perms if not allowed.
		ensure_equals("initMasks/getMaskBase():failed to return the MaskBase ", fixedbase, permissions.getMaskBase());	
		ensure_equals("initMasks/getMaskOwner():failed to return the MaskOwner ", fixedowner, permissions.getMaskOwner());	
		ensure_equals("initMasks/getMaskEveryone():failed to return the MaskGroup ", fixedgroup, permissions.getMaskGroup());	
		ensure_equals("initMasks/getMaskEveryone():failed to return the MaskEveryone ", fixedeveryone, permissions.getMaskEveryone());	
		ensure_equals("initMasks/getMaskNextOwner():failed to return the MaskNext ", fixednext, permissions.getMaskNextOwner());	

		// explictly set should maintain the values
		permissions.setMaskBase(base); //no fixing
		ensure_equals("setMaskBase/getMaskBase():failed to return the MaskBase ", base, permissions.getMaskBase());	

		permissions.setMaskOwner(owner);
		ensure_equals("setMaskOwner/getMaskOwner():failed to return the MaskOwner ", owner, permissions.getMaskOwner());	
		
		permissions.setMaskEveryone(everyone);
		ensure_equals("setMaskEveryone/getMaskEveryone():failed to return the MaskEveryone ", everyone, permissions.getMaskEveryone());	

		permissions.setMaskGroup(group);
		ensure_equals("setMaskGroup/getMaskEveryone():failed to return the MaskGroup ", group, permissions.getMaskGroup());	

		permissions.setMaskNext(next);
		ensure_equals("setMaskNext/getMaskNextOwner():failed to return the MaskNext ", next, permissions.getMaskNextOwner());	

		// further tests can be added to ensure perms for owner/group/everyone etc. get properly fixed. 
		// code however suggests that there is no explict check if the perms are correct and the user of this 
		// class is expected to know how to use them correctly. skipping further test cases for now for various
		// perm combinations.
	}

	template<> template<>
	void permission_object_t::test<4>()
	{
		LLPermissions perm,perm1;
		LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
		LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		perm1.init(creator,owner,lastOwner,group);
		perm.set(perm1);
		ensure("set():failed to set ", (creator == perm.getCreator()) && (owner == perm.getOwner())&&
									(lastOwner == perm.getLastOwner())&& (group == perm.getGroup()));	
		}

	template<> template<>
	void permission_object_t::test<5>()
	{
		LLPermissions perm,perm1;
		LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
		LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		perm1.init(creator,owner,lastOwner,group);

		U32 base = PERM_TRANSFER;
		U32 ownerp = PERM_TRANSFER;
		U32 groupp = PERM_TRANSFER;
		U32 everyone = PERM_TRANSFER;
		U32 next = PERM_NONE;

		perm1.initMasks(base, ownerp, everyone, groupp, next);

		base = PERM_ALL;
		ownerp = PERM_ITEM_UNRESTRICTED; //PERM_ITEM_UNRESTRICTED = PERM_MODIFY | PERM_COPY | PERM_TRANSFER;
		groupp = PERM_TRANSFER | PERM_COPY|PERM_MODIFY;
		everyone = PERM_TRANSFER;
		next = PERM_NONE;
		
		perm.init(creator,owner,lastOwner,group);
		perm.initMasks(base, ownerp, everyone, groupp, next); 

		// restrict permissions by accumulation
		perm.accumulate(perm1);

		U32 fixedbase = PERM_TRANSFER | PERM_MOVE;
		U32 fixedowner = PERM_TRANSFER;
		U32 fixedgroup = PERM_TRANSFER;
		U32 fixedeveryone = PERM_TRANSFER;
		U32 fixednext = PERM_NONE;

		ensure_equals("accumulate failed ", fixedbase, perm.getMaskBase());	
		ensure_equals("accumulate failed ", fixedowner, perm.getMaskOwner());	
		ensure_equals("accumulate failed ", fixedgroup, perm.getMaskGroup());	
		ensure_equals("accumulate failed ", fixedeveryone, perm.getMaskEveryone());	
		ensure_equals("accumulate failed ", fixednext, perm.getMaskNextOwner());	
	}

	template<> template<>
	void permission_object_t::test<6>()
	{
		LLPermissions perm;
		LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
		LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		perm.init(creator,owner,lastOwner,group);
		ensure_equals("getSafeOwner:failed ", owner,perm.getSafeOwner());
		
		///NULL Owner
		perm.init(creator,LLUUID::null,lastOwner,group);
		ensure_equals("getSafeOwner:failed ", group, perm.getSafeOwner());
	}
	
		template<> template<>
	void permission_object_t::test<7>()
	{
		LLPermissions perm1;
		LLUUID uuid;
		BOOL is_group_owned = FALSE;
		ensure("1:getOwnership:failed ", (FALSE == perm1.getOwnership(uuid,is_group_owned)));
		
		LLPermissions perm;
		LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
		LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		perm.init(creator,owner,lastOwner,group);
		perm.getOwnership(uuid,is_group_owned);
		ensure("2:getOwnership:failed ", ((uuid == owner) && (FALSE == is_group_owned))); 

		perm.init(creator,LLUUID::null,lastOwner,group);
		perm.getOwnership(uuid,is_group_owned);
		ensure("3:getOwnership:failed ", ((uuid == group) && (TRUE == is_group_owned))); 
	}

	template<> template<>
	void permission_object_t::test<8>()
	{
		LLPermissions perm,perm1;
		LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
		LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		perm.init(creator,owner,lastOwner,group);
		perm1.init(creator,owner,lastOwner,group);
		ensure_equals("getCRC32:failed ", perm.getCRC32(),perm1.getCRC32());
	}

	template<> template<>
	void permission_object_t::test<9>()
	{
		LLPermissions perm;
		LLUUID agent("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
		bool is_atomic = TRUE;
		ensure("setOwnerAndGroup():failed ", (TRUE == perm.setOwnerAndGroup(agent,owner,group,is_atomic)));
		
		LLUUID owner2("68edcf47-ccd7-45b8-9f90-1649d7f12807"); 
		LLUUID group2("9c8eca51-53d5-42a7-bb58-cef070395db9");
		
		// cant change - agent need to be current owner
		ensure("setOwnerAndGroup():failed ", (FALSE == perm.setOwnerAndGroup(agent,owner2,group2,is_atomic)));
		
		// should be able to change - agent and owner same as current owner
		ensure("setOwnerAndGroup():failed ", (TRUE == perm.setOwnerAndGroup(owner,owner,group2,is_atomic)));
	}

	template<> template<>
	void permission_object_t::test<10>()
	{
		LLPermissions perm;
		LLUUID agent;
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
		ensure("deedToGroup():failed ", (TRUE == perm.deedToGroup(agent,group)));
	}
	template<> template<>
	void permission_object_t::test<11>()
	{
		LLPermissions perm;
		LLUUID agent;
		BOOL set = 1;
		U32 bits = PERM_TRANSFER | PERM_MODIFY;
		ensure("setBaseBits():failed ", (TRUE == perm.setBaseBits(agent, set, bits)));
		ensure("setOwnerBits():failed ", (TRUE == perm.setOwnerBits(agent, set, bits)));

		LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8");
		ensure("setBaseBits():failed ", (FALSE == perm.setBaseBits(agent1, set, bits)));
		ensure("setOwnerBits():failed ", (FALSE == perm.setOwnerBits(agent1, set, bits)));
	}

	template<> template<>
	void permission_object_t::test<12>()
	{
		LLPermissions perm;
		LLUUID agent;
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		BOOL set = 1;
		U32 bits = 10;
		ensure("setGroupBits():failed ", (TRUE == perm.setGroupBits(agent,group, set, bits)));
		ensure("setEveryoneBits():failed ", (TRUE == perm.setEveryoneBits(agent,group, set, bits)));
		ensure("setNextOwnerBits():failed ", (TRUE == perm.setNextOwnerBits(agent,group, set, bits)));

		LLUUID agent1("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		ensure("setGroupBits():failed ", (FALSE == perm.setGroupBits(agent1,group, set, bits)));
		ensure("setEveryoneBits():failed ", (FALSE == perm.setEveryoneBits(agent1,group, set, bits)));
		ensure("setNextOwnerBits():failed ", (FALSE == perm.setNextOwnerBits(agent1,group, set, bits)));
	}

	template<> template<>
	void permission_object_t::test<13>()
	{
		LLPermissions perm;
		LLUUID agent;
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		U32 bits = 10;
		ensure("allowOperationBy():failed ", (TRUE == perm.allowOperationBy(bits,agent,group)));

		LLUUID agent1("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
		LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
		LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
		perm.init(creator,owner,lastOwner,group);
		ensure("allowOperationBy():failed ", (TRUE == perm.allowOperationBy(bits,agent1,group)));
	}

	template<> template<>
	void permission_object_t::test<14>()
	{
		LLPermissions perm;
		LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner;
		LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		perm.init(creator,owner,lastOwner,group);
		LLUUID agent;
		ensure("1:allowModifyBy():failed ", (TRUE == perm.allowModifyBy(agent)));
		ensure("2:allowModifyBy():failed ", (TRUE == perm.allowModifyBy(agent,group)));
				
		U32 val1 = 0x7FFFFFFF;
		S32 sVal = 1 << 14;
		sVal = val1 & sVal;
		LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8"); 
		ensure("3:allowModifyBy():failed ", (sVal == perm.allowModifyBy(agent1)));
		ensure("4:allowModifyBy():failed ", (sVal == perm.allowModifyBy(agent1,group)));
	}
	
	template<> template<>
	void permission_object_t::test<15>()
	{
		LLPermissions perm;
		LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner;
		LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		perm.init(creator,owner,lastOwner,group);
		LLUUID agent;
		ensure("1:allowCopyBy():failed ", (TRUE == perm.allowModifyBy(agent)));
		ensure("2:allowCopyBy():failed ", (TRUE == perm.allowModifyBy(agent,group)));
				
		U32 val1 = 0x7FFFFFFF;
		S32 sVal = 1 << 15;
		sVal = val1 & sVal;
		LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8"); 
		ensure("3:allowCopyBy():failed ", (sVal == perm.allowCopyBy(agent1)));
		ensure("4:allowCopyBy():failed ", (sVal == perm.allowCopyBy(agent1,group)));
	}

	template<> template<>
	void permission_object_t::test<16>()
	{
		LLPermissions perm;
		LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner;
		LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		perm.init(creator,owner,lastOwner,group);
		LLUUID agent;
		ensure("1:allowMoveBy():failed ", (TRUE == perm.allowMoveBy(agent)));
		ensure("2:allowMoveBy():failed ", (TRUE == perm.allowMoveBy(agent,group)));

		U32 val1 = 0x7FFFFFFF;
		S32 sVal = 1 << 19;
		sVal = val1 & sVal;
		LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8"); 
		ensure("3:allowMoveBy():failed ", (sVal == perm.allowMoveBy(agent1)));
		ensure("4:allowMoveBy():failed ", (sVal == perm.allowMoveBy(agent1,group)));
	}

	template<> template<>
	void permission_object_t::test<17>()
	{
		LLPermissions perm;
		LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner;
		LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		LLUUID agent;
		ensure("1:allowMoveBy():failed ", (TRUE == perm.allowTransferTo(agent)));
		
		perm.init(creator,owner,lastOwner,group);
		U32 val1 = 0x7FFFFFFF;
		S32 sVal = 1 << 13;
		sVal = val1 & sVal;
		ensure("2:allowMoveBy():failed ", (sVal == perm.allowTransferTo(agent)));
	}

	template<> template<>
	void permission_object_t::test<18>()
	{
		LLPermissions perm,perm1;
		ensure("1:Operator==:failed ", perm == perm1);
		
		LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
		LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		perm.init(creator,owner,lastOwner,group);
		perm = perm1;
		ensure("2:Operator==:failed ", perm == perm1);
	}

	template<> template<>
	void permission_object_t::test<19>()
	{
		LLPermissions perm,perm1;
		LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
		LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		perm.init(creator,owner,lastOwner,group);
		ensure("2:Operator==:failed ", perm != perm1);
	}

	template<> template<>
	void permission_object_t::test<20>()
	{
		LLFILE* fp = LLFile::fopen("linden_file.dat","w+");
		if(!fp)
		{
			llerrs << "file coudnt be opened\n" << llendl;
			return;
		}
		LLPermissions perm,perm1;
		LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
		LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		perm.init(creator,owner,lastOwner,group);
		
		U32 base = PERM_TRANSFER | PERM_COPY;
		U32 ownerp = PERM_TRANSFER;
		U32 groupp = PERM_TRANSFER;
		U32 everyone = PERM_TRANSFER;
		U32 next = PERM_NONE;

		perm.initMasks(base, ownerp, everyone, groupp, next);

		perm.exportFile(fp);
		fclose(fp);	
		fp = LLFile::fopen("linden_file.dat","r+");
		if(!fp)
		{
			llerrs << "file coudnt be opened\n" << llendl;
			return;
		}
		perm1.importFile(fp);
		fclose(fp);
		ensure("exportFile()/importFile():failed to export and import the data ", perm1 == perm);	
}

	template<> template<>
	void permission_object_t::test<21>()
	{
		LLPermissions perm,perm1;
		LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
		LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		perm.init(creator,owner,lastOwner,group);

		U32 base = PERM_TRANSFER | PERM_COPY;
		U32 ownerp = PERM_TRANSFER;
		U32 groupp = PERM_TRANSFER;
		U32 everyone = PERM_TRANSFER;
		U32 next = PERM_NONE;

		perm.initMasks(base, ownerp, everyone, groupp, next);

		std::ostringstream ostream;
		perm.exportLegacyStream(ostream);
		std::istringstream istream(ostream.str());
		perm1.importLegacyStream(istream);

		ensure("exportLegacyStream()/importLegacyStream():failed to export and import the data ", perm1 == perm);	
	}

	template<> template<>
	void permission_object_t::test<22>()
	{
		LLPermissions perm,perm1;
		LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
		LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		perm.init(creator,owner,lastOwner,group);
		LLXMLNode* xml_node = perm.exportFileXML();
		perm1.importXML(xml_node);
		ensure("exportFileXML()/importXML():failed to export and import the data ", perm1 == perm);	
	}

	template<> template<>
	void permission_object_t::test<23>()
	{
		LLPermissions perm,perm1;
		LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
		LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		perm.init(creator,owner,lastOwner,group);
		std::ostringstream stream1, stream2;
		stream1 << perm;
		perm1.init(creator,owner,lastOwner,group);
		stream2 << perm1;
		ensure("1:operator << failed",(stream1.str() == stream2.str()));	
	}

	template<> template<>
	void permission_object_t::test<24>()
	{
		LLPermissions perm,perm1;
		LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");	
		LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
		LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
		LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");		
		perm.init(creator,owner,lastOwner,group);
		
		U32 base = PERM_TRANSFER | PERM_COPY;
		U32 ownerp = PERM_TRANSFER;
		U32 groupp = PERM_TRANSFER;
		U32 everyone = PERM_TRANSFER;
		U32 next = PERM_NONE;

		perm.initMasks(base, ownerp, everyone, groupp, next);

		LLSD sd = ll_create_sd_from_permissions(perm);
		perm1 = ll_permissions_from_sd(sd);
		ensure_equals("ll_permissions_from_sd() and ll_create_sd_from_permissions()functions failed", perm, perm1);
	}

	template<> template<>
	void permission_object_t::test<25>()
	{
		LLAggregatePermissions AggrPermission;	
		LLAggregatePermissions AggrPermission1;	
		ensure("getU8() function failed", (AggrPermission.getU8() == 0));
		ensure("isEmpty() function failed", (AggrPermission.isEmpty() == TRUE));
		AggrPermission.getValue(PERM_TRANSFER);
		ensure_equals("getValue() function failed", AggrPermission.getValue(PERM_TRANSFER), 0x00);

		AggrPermission.aggregate(PERM_ITEM_UNRESTRICTED);
		ensure("aggregate() function failed", (AggrPermission.isEmpty() == FALSE));

		AggrPermission1.aggregate(AggrPermission);
		ensure("aggregate() function failed", (AggrPermission1.isEmpty() == FALSE));

		std::ostringstream stream1;
		stream1 << AggrPermission;
		ensure("operator<< failed", (stream1.str() == "{PI_COPY=All, PI_MODIFY=All, PI_TRANSFER=All}"));
	}
}