llpermissions_tut.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:21k
源码类别:

游戏引擎

开发平台:

C++ Builder

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