aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/test/llpermissions_tut.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:02 -0500
committerJacek Antonelli2008-08-15 23:45:02 -0500
commitd644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd (patch)
tree7ed0c2c27d717801238a2e6b5749cd5bf88c3059 /linden/indra/test/llpermissions_tut.cpp
parentSecond Life viewer sources 1.17.3.0 (diff)
downloadmeta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.zip
meta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.tar.gz
meta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.tar.bz2
meta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.tar.xz
Second Life viewer sources 1.18.0.6
Diffstat (limited to 'linden/indra/test/llpermissions_tut.cpp')
-rw-r--r--linden/indra/test/llpermissions_tut.cpp553
1 files changed, 553 insertions, 0 deletions
diff --git a/linden/indra/test/llpermissions_tut.cpp b/linden/indra/test/llpermissions_tut.cpp
new file mode 100644
index 0000000..0c9082b
--- /dev/null
+++ b/linden/indra/test/llpermissions_tut.cpp
@@ -0,0 +1,553 @@
1/**
2 * @file llpermissions_tut.cpp
3 * @author Adroit
4 * @date March 2007
5 * @brief llpermissions test cases.
6 *
7 * Copyright (c) 2007-2007, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlife.com/developers/opensource/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlife.com/developers/opensource/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 */
30
31#include <tut/tut.h>
32#include "lltut.h"
33#include "message.h"
34#include "llpermissions.h"
35
36
37namespace tut
38{
39 struct permission
40 {
41 };
42 typedef test_group<permission> permission_t;
43 typedef permission_t::object permission_object_t;
44 tut::permission_t tut_permission("permission");
45
46 template<> template<>
47 void permission_object_t::test<1>()
48 {
49 LLPermissions permissions;
50 LLUUID uuid = permissions.getCreator();
51 LLUUID uuid1 = permissions.getOwner();
52 LLUUID uuid2 = permissions.getGroup();
53 LLUUID uuid3 = permissions.getLastOwner();
54
55 ensure("LLPermission Get Functions failed", (uuid == LLUUID::null && uuid1 == LLUUID::null &&
56 uuid2 == LLUUID::null && uuid3 == LLUUID::null));
57 ensure("LLPermission Get Functions failed", (permissions.getMaskBase() == PERM_ALL && permissions.getMaskOwner() == PERM_ALL &&
58 permissions.getMaskGroup() == PERM_ALL && permissions.getMaskEveryone() == PERM_ALL && permissions.getMaskNextOwner() == PERM_ALL));
59 ensure("Ownership functions failed", (permissions.isGroupOwned() == FALSE && permissions.isOwned() == FALSE));
60 }
61
62 template<> template<>
63 void permission_object_t::test<2>()
64 {
65 LLPermissions permissions;
66 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
67 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
68 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
69 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
70 permissions.init(creator, owner, lastOwner, group);
71
72 ensure_equals("init/getCreator():failed to return the creator ", creator, permissions.getCreator());
73 ensure_equals("init/getOwner():failed to return the owner ", owner, permissions.getOwner());
74 ensure_equals("init/getLastOwner():failed to return the group ", lastOwner, permissions.getLastOwner());
75 ensure_equals("init/getGroup():failed to return the group ", group, permissions.getGroup());
76 }
77
78 template<> template<>
79 void permission_object_t::test<3>()
80 {
81 LLPermissions permissions;
82 U32 base = PERM_ALL;
83 U32 owner = PERM_ITEM_UNRESTRICTED; //PERM_ITEM_UNRESTRICTED = PERM_MODIFY | PERM_COPY | PERM_TRANSFER;
84 U32 group = PERM_TRANSFER | PERM_MOVE | PERM_COPY|PERM_MODIFY;
85 U32 everyone = PERM_TRANSFER | PERM_MOVE | PERM_MODIFY;
86 U32 next = PERM_NONE;
87
88 U32 fixedbase = base;
89 U32 fixedowner = PERM_ITEM_UNRESTRICTED; //owner & fixedbase
90 U32 fixedgroup = PERM_ITEM_UNRESTRICTED; // no PERM_MOVE as owner does not have that perm either
91 U32 fixedeveryone = PERM_TRANSFER; // no PERM_MOVE. Everyone can never modify.
92 U32 fixednext = PERM_NONE;
93
94 permissions.initMasks(base, owner, everyone, group, next); // will fix perms if not allowed.
95 ensure_equals("initMasks/getMaskBase():failed to return the MaskBase ", fixedbase, permissions.getMaskBase());
96 ensure_equals("initMasks/getMaskOwner():failed to return the MaskOwner ", fixedowner, permissions.getMaskOwner());
97 ensure_equals("initMasks/getMaskEveryone():failed to return the MaskGroup ", fixedgroup, permissions.getMaskGroup());
98 ensure_equals("initMasks/getMaskEveryone():failed to return the MaskEveryone ", fixedeveryone, permissions.getMaskEveryone());
99 ensure_equals("initMasks/getMaskNextOwner():failed to return the MaskNext ", fixednext, permissions.getMaskNextOwner());
100
101 // explictly set should maintain the values
102 permissions.setMaskBase(base); //no fixing
103 ensure_equals("setMaskBase/getMaskBase():failed to return the MaskBase ", base, permissions.getMaskBase());
104
105 permissions.setMaskOwner(owner);
106 ensure_equals("setMaskOwner/getMaskOwner():failed to return the MaskOwner ", owner, permissions.getMaskOwner());
107
108 permissions.setMaskEveryone(everyone);
109 ensure_equals("setMaskEveryone/getMaskEveryone():failed to return the MaskEveryone ", everyone, permissions.getMaskEveryone());
110
111 permissions.setMaskGroup(group);
112 ensure_equals("setMaskGroup/getMaskEveryone():failed to return the MaskGroup ", group, permissions.getMaskGroup());
113
114 permissions.setMaskNext(next);
115 ensure_equals("setMaskNext/getMaskNextOwner():failed to return the MaskNext ", next, permissions.getMaskNextOwner());
116
117 // further tests can be added to ensure perms for owner/group/everyone etc. get properly fixed.
118 // code however suggests that there is no explict check if the perms are correct and the user of this
119 // class is expected to know how to use them correctly. skipping further test cases for now for various
120 // perm combinations.
121 }
122
123 template<> template<>
124 void permission_object_t::test<4>()
125 {
126 LLPermissions perm,perm1;
127 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
128 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
129 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
130 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
131 perm1.init(creator,owner,lastOwner,group);
132 perm.set(perm1);
133 ensure("set():failed to set ", (creator == perm.getCreator()) && (owner == perm.getOwner())&&
134 (lastOwner == perm.getLastOwner())&& (group == perm.getGroup()));
135 }
136
137 template<> template<>
138 void permission_object_t::test<5>()
139 {
140 LLPermissions perm,perm1;
141 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
142 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
143 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
144 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
145 perm1.init(creator,owner,lastOwner,group);
146
147 U32 base = PERM_TRANSFER;
148 U32 ownerp = PERM_TRANSFER;
149 U32 groupp = PERM_TRANSFER;
150 U32 everyone = PERM_TRANSFER;
151 U32 next = PERM_NONE;
152
153 perm1.initMasks(base, ownerp, everyone, groupp, next);
154
155 base = PERM_ALL;
156 ownerp = PERM_ITEM_UNRESTRICTED; //PERM_ITEM_UNRESTRICTED = PERM_MODIFY | PERM_COPY | PERM_TRANSFER;
157 groupp = PERM_TRANSFER | PERM_COPY|PERM_MODIFY;
158 everyone = PERM_TRANSFER;
159 next = PERM_NONE;
160
161 perm.init(creator,owner,lastOwner,group);
162 perm.initMasks(base, ownerp, everyone, groupp, next);
163
164 // restrict permissions by accumulation
165 perm.accumulate(perm1);
166
167 U32 fixedbase = PERM_TRANSFER | PERM_MOVE;
168 U32 fixedowner = PERM_TRANSFER;
169 U32 fixedgroup = PERM_TRANSFER;
170 U32 fixedeveryone = PERM_TRANSFER;
171 U32 fixednext = PERM_NONE;
172
173 ensure_equals("accumulate failed ", fixedbase, perm.getMaskBase());
174 ensure_equals("accumulate failed ", fixedowner, perm.getMaskOwner());
175 ensure_equals("accumulate failed ", fixedgroup, perm.getMaskGroup());
176 ensure_equals("accumulate failed ", fixedeveryone, perm.getMaskEveryone());
177 ensure_equals("accumulate failed ", fixednext, perm.getMaskNextOwner());
178 }
179
180 template<> template<>
181 void permission_object_t::test<6>()
182 {
183 LLPermissions perm;
184 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
185 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
186 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
187 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
188 perm.init(creator,owner,lastOwner,group);
189 ensure_equals("getSafeOwner:failed ", owner,perm.getSafeOwner());
190
191 ///NULL Owner
192 perm.init(creator,LLUUID::null,lastOwner,group);
193 ensure_equals("getSafeOwner:failed ", group, perm.getSafeOwner());
194 }
195
196 template<> template<>
197 void permission_object_t::test<7>()
198 {
199 LLPermissions perm1;
200 LLUUID uuid;
201 BOOL is_group_owned = FALSE;
202 ensure("1:getOwnership:failed ", (FALSE == perm1.getOwnership(uuid,is_group_owned)));
203
204 LLPermissions perm;
205 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
206 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
207 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
208 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
209 perm.init(creator,owner,lastOwner,group);
210 perm.getOwnership(uuid,is_group_owned);
211 ensure("2:getOwnership:failed ", ((uuid == owner) && (FALSE == is_group_owned)));
212
213 perm.init(creator,LLUUID::null,lastOwner,group);
214 perm.getOwnership(uuid,is_group_owned);
215 ensure("3:getOwnership:failed ", ((uuid == group) && (TRUE == is_group_owned)));
216 }
217
218 template<> template<>
219 void permission_object_t::test<8>()
220 {
221 LLPermissions perm,perm1;
222 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
223 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
224 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
225 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
226 perm.init(creator,owner,lastOwner,group);
227 perm1.init(creator,owner,lastOwner,group);
228 ensure_equals("getCRC32:failed ", perm.getCRC32(),perm1.getCRC32());
229 }
230
231 template<> template<>
232 void permission_object_t::test<9>()
233 {
234 LLPermissions perm;
235 LLUUID agent("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
236 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
237 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
238 bool is_atomic = TRUE;
239 ensure("setOwnerAndGroup():failed ", (TRUE == perm.setOwnerAndGroup(agent,owner,group,is_atomic)));
240
241 LLUUID owner2("68edcf47-ccd7-45b8-9f90-1649d7f12807");
242 LLUUID group2("9c8eca51-53d5-42a7-bb58-cef070395db9");
243
244 // cant change - agent need to be current owner
245 ensure("setOwnerAndGroup():failed ", (FALSE == perm.setOwnerAndGroup(agent,owner2,group2,is_atomic)));
246
247 // should be able to change - agent and owner same as current owner
248 ensure("setOwnerAndGroup():failed ", (TRUE == perm.setOwnerAndGroup(owner,owner,group2,is_atomic)));
249 }
250
251 template<> template<>
252 void permission_object_t::test<10>()
253 {
254 LLPermissions perm;
255 LLUUID agent;
256 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
257 ensure("deedToGroup():failed ", (TRUE == perm.deedToGroup(agent,group)));
258 }
259 template<> template<>
260 void permission_object_t::test<11>()
261 {
262 LLPermissions perm;
263 LLUUID agent;
264 BOOL set = 1;
265 U32 bits = PERM_TRANSFER | PERM_MODIFY;
266 ensure("setBaseBits():failed ", (TRUE == perm.setBaseBits(agent, set, bits)));
267 ensure("setOwnerBits():failed ", (TRUE == perm.setOwnerBits(agent, set, bits)));
268
269 LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8");
270 ensure("setBaseBits():failed ", (FALSE == perm.setBaseBits(agent1, set, bits)));
271 ensure("setOwnerBits():failed ", (FALSE == perm.setOwnerBits(agent1, set, bits)));
272 }
273
274 template<> template<>
275 void permission_object_t::test<12>()
276 {
277 LLPermissions perm;
278 LLUUID agent;
279 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
280 BOOL set = 1;
281 U32 bits = 10;
282 ensure("setGroupBits():failed ", (TRUE == perm.setGroupBits(agent,group, set, bits)));
283 ensure("setEveryoneBits():failed ", (TRUE == perm.setEveryoneBits(agent,group, set, bits)));
284 ensure("setNextOwnerBits():failed ", (TRUE == perm.setNextOwnerBits(agent,group, set, bits)));
285
286 LLUUID agent1("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
287 ensure("setGroupBits():failed ", (FALSE == perm.setGroupBits(agent1,group, set, bits)));
288 ensure("setEveryoneBits():failed ", (FALSE == perm.setEveryoneBits(agent1,group, set, bits)));
289 ensure("setNextOwnerBits():failed ", (FALSE == perm.setNextOwnerBits(agent1,group, set, bits)));
290 }
291
292 template<> template<>
293 void permission_object_t::test<13>()
294 {
295 LLPermissions perm;
296 LLUUID agent;
297 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
298 U32 bits = 10;
299 ensure("allowOperationBy():failed ", (TRUE == perm.allowOperationBy(bits,agent,group)));
300
301 LLUUID agent1("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
302 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
303 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
304 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
305 perm.init(creator,owner,lastOwner,group);
306 ensure("allowOperationBy():failed ", (TRUE == perm.allowOperationBy(bits,agent1,group)));
307 }
308
309 template<> template<>
310 void permission_object_t::test<14>()
311 {
312 LLPermissions perm;
313 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
314 LLUUID owner;
315 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
316 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
317 perm.init(creator,owner,lastOwner,group);
318 LLUUID agent;
319 ensure("1:allowModifyBy():failed ", (TRUE == perm.allowModifyBy(agent)));
320 ensure("2:allowModifyBy():failed ", (TRUE == perm.allowModifyBy(agent,group)));
321
322 U32 val1 = 0x7FFFFFFF;
323 S32 sVal = 1 << 14;
324 sVal = val1 & sVal;
325 LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8");
326 ensure("3:allowModifyBy():failed ", (sVal == perm.allowModifyBy(agent1)));
327 ensure("4:allowModifyBy():failed ", (sVal == perm.allowModifyBy(agent1,group)));
328 }
329
330 template<> template<>
331 void permission_object_t::test<15>()
332 {
333 LLPermissions perm;
334 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
335 LLUUID owner;
336 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
337 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
338 perm.init(creator,owner,lastOwner,group);
339 LLUUID agent;
340 ensure("1:allowCopyBy():failed ", (TRUE == perm.allowModifyBy(agent)));
341 ensure("2:allowCopyBy():failed ", (TRUE == perm.allowModifyBy(agent,group)));
342
343 U32 val1 = 0x7FFFFFFF;
344 S32 sVal = 1 << 15;
345 sVal = val1 & sVal;
346 LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8");
347 ensure("3:allowCopyBy():failed ", (sVal == perm.allowCopyBy(agent1)));
348 ensure("4:allowCopyBy():failed ", (sVal == perm.allowCopyBy(agent1,group)));
349 }
350
351 template<> template<>
352 void permission_object_t::test<16>()
353 {
354 LLPermissions perm;
355 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
356 LLUUID owner;
357 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
358 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
359 perm.init(creator,owner,lastOwner,group);
360 LLUUID agent;
361 ensure("1:allowMoveBy():failed ", (TRUE == perm.allowMoveBy(agent)));
362 ensure("2:allowMoveBy():failed ", (TRUE == perm.allowMoveBy(agent,group)));
363
364 U32 val1 = 0x7FFFFFFF;
365 S32 sVal = 1 << 19;
366 sVal = val1 & sVal;
367 LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8");
368 ensure("3:allowMoveBy():failed ", (sVal == perm.allowMoveBy(agent1)));
369 ensure("4:allowMoveBy():failed ", (sVal == perm.allowMoveBy(agent1,group)));
370 }
371
372 template<> template<>
373 void permission_object_t::test<17>()
374 {
375 LLPermissions perm;
376 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
377 LLUUID owner;
378 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
379 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
380 LLUUID agent;
381 ensure("1:allowMoveBy():failed ", (TRUE == perm.allowTransferTo(agent)));
382
383 perm.init(creator,owner,lastOwner,group);
384 U32 val1 = 0x7FFFFFFF;
385 S32 sVal = 1 << 13;
386 sVal = val1 & sVal;
387 ensure("2:allowMoveBy():failed ", (sVal == perm.allowTransferTo(agent)));
388 }
389
390 template<> template<>
391 void permission_object_t::test<18>()
392 {
393 LLPermissions perm,perm1;
394 ensure("1:Operator==:failed ", perm == perm1);
395
396 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
397 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
398 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
399 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
400 perm.init(creator,owner,lastOwner,group);
401 perm = perm1;
402 ensure("2:Operator==:failed ", perm == perm1);
403 }
404
405 template<> template<>
406 void permission_object_t::test<19>()
407 {
408 LLPermissions perm,perm1;
409 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
410 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
411 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
412 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
413 perm.init(creator,owner,lastOwner,group);
414 ensure("2:Operator==:failed ", perm != perm1);
415 }
416
417 template<> template<>
418 void permission_object_t::test<20>()
419 {
420 FILE* fp = fopen("linden_file.dat","w+");
421 if(!fp)
422 {
423 llerrs << "file coudnt be opened\n" << llendl;
424 return;
425 }
426 LLPermissions perm,perm1;
427 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
428 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
429 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
430 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
431 perm.init(creator,owner,lastOwner,group);
432
433 U32 base = PERM_TRANSFER | PERM_COPY;
434 U32 ownerp = PERM_TRANSFER;
435 U32 groupp = PERM_TRANSFER;
436 U32 everyone = PERM_TRANSFER;
437 U32 next = PERM_NONE;
438
439 perm.initMasks(base, ownerp, everyone, groupp, next);
440
441 perm.exportFile(fp);
442 fclose(fp);
443 fp = fopen("linden_file.dat","r+");
444 if(!fp)
445 {
446 llerrs << "file coudnt be opened\n" << llendl;
447 return;
448 }
449 perm1.importFile(fp);
450 fclose(fp);
451 ensure("exportFile()/importFile():failed to export and import the data ", perm1 == perm);
452}
453
454 template<> template<>
455 void permission_object_t::test<21>()
456 {
457 LLPermissions perm,perm1;
458 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
459 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
460 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
461 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
462 perm.init(creator,owner,lastOwner,group);
463
464 U32 base = PERM_TRANSFER | PERM_COPY;
465 U32 ownerp = PERM_TRANSFER;
466 U32 groupp = PERM_TRANSFER;
467 U32 everyone = PERM_TRANSFER;
468 U32 next = PERM_NONE;
469
470 perm.initMasks(base, ownerp, everyone, groupp, next);
471
472 std::ostringstream ostream;
473 perm.exportLegacyStream(ostream);
474 std::istringstream istream(ostream.str());
475 perm1.importLegacyStream(istream);
476
477 ensure("exportLegacyStream()/importLegacyStream():failed to export and import the data ", perm1 == perm);
478 }
479
480 template<> template<>
481 void permission_object_t::test<22>()
482 {
483 LLPermissions perm,perm1;
484 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
485 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
486 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
487 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
488 perm.init(creator,owner,lastOwner,group);
489 LLXMLNode* xml_node = perm.exportFileXML();
490 perm1.importXML(xml_node);
491 ensure("exportFileXML()/importXML():failed to export and import the data ", perm1 == perm);
492 }
493
494 template<> template<>
495 void permission_object_t::test<23>()
496 {
497 LLPermissions perm,perm1;
498 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
499 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
500 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
501 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
502 perm.init(creator,owner,lastOwner,group);
503 std::ostringstream stream1, stream2;
504 stream1 << perm;
505 perm1.init(creator,owner,lastOwner,group);
506 stream2 << perm1;
507 ensure("1:operator << failed",(stream1.str() == stream2.str()));
508 }
509
510 template<> template<>
511 void permission_object_t::test<24>()
512 {
513 LLPermissions perm,perm1;
514 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
515 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
516 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
517 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
518 perm.init(creator,owner,lastOwner,group);
519
520 U32 base = PERM_TRANSFER | PERM_COPY;
521 U32 ownerp = PERM_TRANSFER;
522 U32 groupp = PERM_TRANSFER;
523 U32 everyone = PERM_TRANSFER;
524 U32 next = PERM_NONE;
525
526 perm.initMasks(base, ownerp, everyone, groupp, next);
527
528 LLSD sd = ll_create_sd_from_permissions(perm);
529 perm1 = ll_permissions_from_sd(sd);
530 ensure_equals("ll_permissions_from_sd() and ll_create_sd_from_permissions()functions failed", perm, perm1);
531 }
532
533 template<> template<>
534 void permission_object_t::test<25>()
535 {
536 LLAggregatePermissions AggrPermission;
537 LLAggregatePermissions AggrPermission1;
538 ensure("getU8() function failed", (AggrPermission.getU8() == 0));
539 ensure("isEmpty() function failed", (AggrPermission.isEmpty() == TRUE));
540 AggrPermission.getValue(PERM_TRANSFER);
541 ensure_equals("getValue() function failed", AggrPermission.getValue(PERM_TRANSFER), 0x00);
542
543 AggrPermission.aggregate(PERM_ITEM_UNRESTRICTED);
544 ensure("aggregate() function failed", (AggrPermission.isEmpty() == FALSE));
545
546 AggrPermission1.aggregate(AggrPermission);
547 ensure("aggregate() function failed", (AggrPermission1.isEmpty() == FALSE));
548
549 std::ostringstream stream1;
550 stream1 << AggrPermission;
551 ensure("operator<< failed", (stream1.str() == "{PI_COPY=All, PI_MODIFY=All, PI_TRANSFER=All}"));
552 }
553}