PageRenderTime 40ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/test/llpermissions_tut.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 533 lines | 424 code | 71 blank | 38 comment | 28 complexity | 6707a7edb43514f249ec694c48992113 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llpermissions_tut.cpp
  3. * @author Adroit
  4. * @date March 2007
  5. * @brief llpermissions test cases.
  6. *
  7. * $LicenseInfo:firstyear=2007&license=viewerlgpl$
  8. * Second Life Viewer Source Code
  9. * Copyright (C) 2010, Linden Research, Inc.
  10. *
  11. * This library is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation;
  14. * version 2.1 of the License only.
  15. *
  16. * This library is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public
  22. * License along with this library; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. *
  25. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  26. * $/LicenseInfo$
  27. */
  28. #include <tut/tut.hpp>
  29. #include "linden_common.h"
  30. #include "lltut.h"
  31. #include "message.h"
  32. #include "llpermissions.h"
  33. namespace tut
  34. {
  35. struct permission
  36. {
  37. };
  38. typedef test_group<permission> permission_t;
  39. typedef permission_t::object permission_object_t;
  40. tut::permission_t tut_permission("permission");
  41. template<> template<>
  42. void permission_object_t::test<1>()
  43. {
  44. LLPermissions permissions;
  45. LLUUID uuid = permissions.getCreator();
  46. LLUUID uuid1 = permissions.getOwner();
  47. LLUUID uuid2 = permissions.getGroup();
  48. LLUUID uuid3 = permissions.getLastOwner();
  49. ensure("LLPermission Get Functions failed", (uuid == LLUUID::null && uuid1 == LLUUID::null &&
  50. uuid2 == LLUUID::null && uuid3 == LLUUID::null));
  51. ensure("LLPermission Get Functions failed", (permissions.getMaskBase() == PERM_ALL && permissions.getMaskOwner() == PERM_ALL &&
  52. permissions.getMaskGroup() == PERM_ALL && permissions.getMaskEveryone() == PERM_ALL && permissions.getMaskNextOwner() == PERM_ALL));
  53. ensure("Ownership functions failed", ((! permissions.isGroupOwned()) && (! permissions.isOwned())));
  54. }
  55. template<> template<>
  56. void permission_object_t::test<2>()
  57. {
  58. LLPermissions permissions;
  59. LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  60. LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
  61. LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
  62. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  63. permissions.init(creator, owner, lastOwner, group);
  64. ensure_equals("init/getCreator():failed to return the creator ", creator, permissions.getCreator());
  65. ensure_equals("init/getOwner():failed to return the owner ", owner, permissions.getOwner());
  66. ensure_equals("init/getLastOwner():failed to return the group ", lastOwner, permissions.getLastOwner());
  67. ensure_equals("init/getGroup():failed to return the group ", group, permissions.getGroup());
  68. }
  69. template<> template<>
  70. void permission_object_t::test<3>()
  71. {
  72. LLPermissions permissions;
  73. U32 base = PERM_ALL;
  74. U32 owner = PERM_ITEM_UNRESTRICTED; //PERM_ITEM_UNRESTRICTED = PERM_MODIFY | PERM_COPY | PERM_TRANSFER;
  75. U32 group = PERM_TRANSFER | PERM_MOVE | PERM_COPY|PERM_MODIFY;
  76. U32 everyone = PERM_TRANSFER | PERM_MOVE | PERM_MODIFY;
  77. U32 next = PERM_NONE;
  78. U32 fixedbase = base;
  79. U32 fixedowner = PERM_ITEM_UNRESTRICTED; //owner & fixedbase
  80. U32 fixedgroup = PERM_ITEM_UNRESTRICTED; // no PERM_MOVE as owner does not have that perm either
  81. U32 fixedeveryone = PERM_TRANSFER; // no PERM_MOVE. Everyone can never modify.
  82. U32 fixednext = PERM_NONE;
  83. permissions.initMasks(base, owner, everyone, group, next); // will fix perms if not allowed.
  84. ensure_equals("initMasks/getMaskBase():failed to return the MaskBase ", fixedbase, permissions.getMaskBase());
  85. ensure_equals("initMasks/getMaskOwner():failed to return the MaskOwner ", fixedowner, permissions.getMaskOwner());
  86. ensure_equals("initMasks/getMaskEveryone():failed to return the MaskGroup ", fixedgroup, permissions.getMaskGroup());
  87. ensure_equals("initMasks/getMaskEveryone():failed to return the MaskEveryone ", fixedeveryone, permissions.getMaskEveryone());
  88. ensure_equals("initMasks/getMaskNextOwner():failed to return the MaskNext ", fixednext, permissions.getMaskNextOwner());
  89. // explictly set should maintain the values
  90. permissions.setMaskBase(base); //no fixing
  91. ensure_equals("setMaskBase/getMaskBase():failed to return the MaskBase ", base, permissions.getMaskBase());
  92. permissions.setMaskOwner(owner);
  93. ensure_equals("setMaskOwner/getMaskOwner():failed to return the MaskOwner ", owner, permissions.getMaskOwner());
  94. permissions.setMaskEveryone(everyone);
  95. ensure_equals("setMaskEveryone/getMaskEveryone():failed to return the MaskEveryone ", everyone, permissions.getMaskEveryone());
  96. permissions.setMaskGroup(group);
  97. ensure_equals("setMaskGroup/getMaskEveryone():failed to return the MaskGroup ", group, permissions.getMaskGroup());
  98. permissions.setMaskNext(next);
  99. ensure_equals("setMaskNext/getMaskNextOwner():failed to return the MaskNext ", next, permissions.getMaskNextOwner());
  100. // further tests can be added to ensure perms for owner/group/everyone etc. get properly fixed.
  101. // code however suggests that there is no explict check if the perms are correct and the user of this
  102. // class is expected to know how to use them correctly. skipping further test cases for now for various
  103. // perm combinations.
  104. }
  105. template<> template<>
  106. void permission_object_t::test<4>()
  107. {
  108. LLPermissions perm,perm1;
  109. LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  110. LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
  111. LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
  112. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  113. perm1.init(creator,owner,lastOwner,group);
  114. perm.set(perm1);
  115. ensure("set():failed to set ", (creator == perm.getCreator()) && (owner == perm.getOwner())&&
  116. (lastOwner == perm.getLastOwner())&& (group == perm.getGroup()));
  117. }
  118. template<> template<>
  119. void permission_object_t::test<5>()
  120. {
  121. LLPermissions perm,perm1;
  122. LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  123. LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
  124. LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
  125. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  126. perm1.init(creator,owner,lastOwner,group);
  127. U32 base = PERM_TRANSFER;
  128. U32 ownerp = PERM_TRANSFER;
  129. U32 groupp = PERM_TRANSFER;
  130. U32 everyone = PERM_TRANSFER;
  131. U32 next = PERM_NONE;
  132. perm1.initMasks(base, ownerp, everyone, groupp, next);
  133. base = PERM_ALL;
  134. ownerp = PERM_ITEM_UNRESTRICTED; //PERM_ITEM_UNRESTRICTED = PERM_MODIFY | PERM_COPY | PERM_TRANSFER;
  135. groupp = PERM_TRANSFER | PERM_COPY|PERM_MODIFY;
  136. everyone = PERM_TRANSFER;
  137. next = PERM_NONE;
  138. perm.init(creator,owner,lastOwner,group);
  139. perm.initMasks(base, ownerp, everyone, groupp, next);
  140. // restrict permissions by accumulation
  141. perm.accumulate(perm1);
  142. U32 fixedbase = PERM_TRANSFER | PERM_MOVE;
  143. U32 fixedowner = PERM_TRANSFER;
  144. U32 fixedgroup = PERM_TRANSFER;
  145. U32 fixedeveryone = PERM_TRANSFER;
  146. U32 fixednext = PERM_NONE;
  147. ensure_equals("accumulate failed ", fixedbase, perm.getMaskBase());
  148. ensure_equals("accumulate failed ", fixedowner, perm.getMaskOwner());
  149. ensure_equals("accumulate failed ", fixedgroup, perm.getMaskGroup());
  150. ensure_equals("accumulate failed ", fixedeveryone, perm.getMaskEveryone());
  151. ensure_equals("accumulate failed ", fixednext, perm.getMaskNextOwner());
  152. }
  153. template<> template<>
  154. void permission_object_t::test<6>()
  155. {
  156. LLPermissions perm;
  157. LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  158. LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
  159. LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
  160. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  161. perm.init(creator,owner,lastOwner,group);
  162. ensure_equals("getSafeOwner:failed ", owner,perm.getSafeOwner());
  163. ///NULL Owner
  164. perm.init(creator,LLUUID::null,lastOwner,group);
  165. ensure_equals("getSafeOwner:failed ", group, perm.getSafeOwner());
  166. }
  167. template<> template<>
  168. void permission_object_t::test<7>()
  169. {
  170. LLPermissions perm1;
  171. LLUUID uuid;
  172. BOOL is_group_owned = FALSE;
  173. ensure("1:getOwnership:failed ", ! perm1.getOwnership(uuid,is_group_owned));
  174. LLPermissions perm;
  175. LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  176. LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
  177. LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
  178. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  179. perm.init(creator,owner,lastOwner,group);
  180. perm.getOwnership(uuid,is_group_owned);
  181. ensure("2:getOwnership:failed ", ((uuid == owner) && (! is_group_owned)));
  182. perm.init(creator,LLUUID::null,lastOwner,group);
  183. perm.getOwnership(uuid,is_group_owned);
  184. ensure("3:getOwnership:failed ", ((uuid == group) && is_group_owned));
  185. }
  186. template<> template<>
  187. void permission_object_t::test<8>()
  188. {
  189. LLPermissions perm,perm1;
  190. LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  191. LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
  192. LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
  193. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  194. perm.init(creator,owner,lastOwner,group);
  195. perm1.init(creator,owner,lastOwner,group);
  196. ensure_equals("getCRC32:failed ", perm.getCRC32(),perm1.getCRC32());
  197. }
  198. template<> template<>
  199. void permission_object_t::test<9>()
  200. {
  201. LLPermissions perm;
  202. LLUUID agent("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  203. LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
  204. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  205. bool is_atomic = true;
  206. ensure("setOwnerAndGroup():failed ", perm.setOwnerAndGroup(agent,owner,group,is_atomic));
  207. LLUUID owner2("68edcf47-ccd7-45b8-9f90-1649d7f12807");
  208. LLUUID group2("9c8eca51-53d5-42a7-bb58-cef070395db9");
  209. // cant change - agent need to be current owner
  210. ensure("setOwnerAndGroup():failed ", ! perm.setOwnerAndGroup(agent,owner2,group2,is_atomic));
  211. // should be able to change - agent and owner same as current owner
  212. ensure("setOwnerAndGroup():failed ", perm.setOwnerAndGroup(owner,owner,group2,is_atomic));
  213. }
  214. template<> template<>
  215. void permission_object_t::test<10>()
  216. {
  217. LLPermissions perm;
  218. LLUUID agent;
  219. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  220. ensure("deedToGroup():failed ", perm.deedToGroup(agent,group));
  221. }
  222. template<> template<>
  223. void permission_object_t::test<11>()
  224. {
  225. LLPermissions perm;
  226. LLUUID agent;
  227. BOOL set = 1;
  228. U32 bits = PERM_TRANSFER | PERM_MODIFY;
  229. ensure("setBaseBits():failed ", perm.setBaseBits(agent, set, bits));
  230. ensure("setOwnerBits():failed ", perm.setOwnerBits(agent, set, bits));
  231. LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8");
  232. ensure("setBaseBits():failed ", ! perm.setBaseBits(agent1, set, bits));
  233. ensure("setOwnerBits():failed ", ! perm.setOwnerBits(agent1, set, bits));
  234. }
  235. template<> template<>
  236. void permission_object_t::test<12>()
  237. {
  238. LLPermissions perm;
  239. LLUUID agent;
  240. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  241. BOOL set = 1;
  242. U32 bits = 10;
  243. ensure("setGroupBits():failed ", perm.setGroupBits(agent,group, set, bits));
  244. ensure("setEveryoneBits():failed ", perm.setEveryoneBits(agent,group, set, bits));
  245. ensure("setNextOwnerBits():failed ", perm.setNextOwnerBits(agent,group, set, bits));
  246. LLUUID agent1("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  247. ensure("setGroupBits():failed ", ! perm.setGroupBits(agent1,group, set, bits));
  248. ensure("setEveryoneBits():failed ", ! perm.setEveryoneBits(agent1,group, set, bits));
  249. ensure("setNextOwnerBits():failed ", ! perm.setNextOwnerBits(agent1,group, set, bits));
  250. }
  251. template<> template<>
  252. void permission_object_t::test<13>()
  253. {
  254. LLPermissions perm;
  255. LLUUID agent;
  256. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  257. U32 bits = 10;
  258. ensure("allowOperationBy():failed ", perm.allowOperationBy(bits,agent,group));
  259. LLUUID agent1("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  260. LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  261. LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
  262. LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
  263. perm.init(creator,owner,lastOwner,group);
  264. ensure("allowOperationBy():failed ", perm.allowOperationBy(bits,agent1,group));
  265. }
  266. template<> template<>
  267. void permission_object_t::test<14>()
  268. {
  269. LLPermissions perm;
  270. LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  271. LLUUID owner;
  272. LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
  273. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  274. perm.init(creator,owner,lastOwner,group);
  275. LLUUID agent;
  276. ensure("1:allowModifyBy():failed ", perm.allowModifyBy(agent));
  277. ensure("2:allowModifyBy():failed ", perm.allowModifyBy(agent,group));
  278. LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8");
  279. ensure("3:allowModifyBy():failed ", perm.allowModifyBy(agent1));
  280. ensure("4:allowModifyBy():failed ", perm.allowModifyBy(agent1,group));
  281. }
  282. template<> template<>
  283. void permission_object_t::test<15>()
  284. {
  285. LLPermissions perm;
  286. LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  287. LLUUID owner;
  288. LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
  289. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  290. perm.init(creator,owner,lastOwner,group);
  291. LLUUID agent;
  292. ensure("1:allowCopyBy():failed ", perm.allowModifyBy(agent));
  293. ensure("2:allowCopyBy():failed ", perm.allowModifyBy(agent,group));
  294. LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8");
  295. ensure("3:allowCopyBy():failed ", perm.allowCopyBy(agent1));
  296. ensure("4:allowCopyBy():failed ", perm.allowCopyBy(agent1,group));
  297. }
  298. template<> template<>
  299. void permission_object_t::test<16>()
  300. {
  301. LLPermissions perm;
  302. LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  303. LLUUID owner;
  304. LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
  305. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  306. perm.init(creator,owner,lastOwner,group);
  307. LLUUID agent;
  308. ensure("1:allowMoveBy():failed ", perm.allowMoveBy(agent));
  309. ensure("2:allowMoveBy():failed ", perm.allowMoveBy(agent,group));
  310. LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8");
  311. ensure("3:allowMoveBy():failed ", perm.allowMoveBy(agent1));
  312. ensure("4:allowMoveBy():failed ", perm.allowMoveBy(agent1,group));
  313. }
  314. template<> template<>
  315. void permission_object_t::test<17>()
  316. {
  317. LLPermissions perm;
  318. LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  319. LLUUID owner;
  320. LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
  321. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  322. LLUUID agent;
  323. ensure("1:allowMoveBy():failed ", perm.allowTransferTo(agent));
  324. perm.init(creator,owner,lastOwner,group);
  325. ensure("2:allowMoveBy():failed ", perm.allowTransferTo(agent));
  326. }
  327. template<> template<>
  328. void permission_object_t::test<18>()
  329. {
  330. LLPermissions perm,perm1;
  331. ensure_equals("1:Operator==:failed ", perm, perm1);
  332. LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  333. LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
  334. LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
  335. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  336. perm.init(creator,owner,lastOwner,group);
  337. perm = perm1;
  338. ensure_equals("2:Operator==:failed ", perm, perm1);
  339. }
  340. template<> template<>
  341. void permission_object_t::test<19>()
  342. {
  343. LLPermissions perm,perm1;
  344. LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  345. LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
  346. LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
  347. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  348. perm.init(creator,owner,lastOwner,group);
  349. ensure_not_equals("2:Operator==:failed ", perm, perm1);
  350. }
  351. template<> template<>
  352. void permission_object_t::test<20>()
  353. {
  354. LLFILE* fp = LLFile::fopen("linden_file.dat","w+");
  355. if(!fp)
  356. {
  357. llerrs << "file coudnt be opened\n" << llendl;
  358. return;
  359. }
  360. LLPermissions perm,perm1;
  361. LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  362. LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
  363. LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
  364. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  365. perm.init(creator,owner,lastOwner,group);
  366. U32 base = PERM_TRANSFER | PERM_COPY;
  367. U32 ownerp = PERM_TRANSFER;
  368. U32 groupp = PERM_TRANSFER;
  369. U32 everyone = PERM_TRANSFER;
  370. U32 next = PERM_NONE;
  371. perm.initMasks(base, ownerp, everyone, groupp, next);
  372. perm.exportFile(fp);
  373. fclose(fp);
  374. fp = LLFile::fopen("linden_file.dat","r+");
  375. if(!fp)
  376. {
  377. llerrs << "file coudnt be opened\n" << llendl;
  378. return;
  379. }
  380. perm1.importFile(fp);
  381. fclose(fp);
  382. ensure_equals("exportFile()/importFile():failed to export and import the data ", perm1, perm);
  383. }
  384. template<> template<>
  385. void permission_object_t::test<21>()
  386. {
  387. LLPermissions perm,perm1;
  388. LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  389. LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
  390. LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
  391. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  392. perm.init(creator,owner,lastOwner,group);
  393. U32 base = PERM_TRANSFER | PERM_COPY;
  394. U32 ownerp = PERM_TRANSFER;
  395. U32 groupp = PERM_TRANSFER;
  396. U32 everyone = PERM_TRANSFER;
  397. U32 next = PERM_NONE;
  398. perm.initMasks(base, ownerp, everyone, groupp, next);
  399. std::ostringstream ostream;
  400. perm.exportLegacyStream(ostream);
  401. std::istringstream istream(ostream.str());
  402. perm1.importLegacyStream(istream);
  403. ensure_equals("exportLegacyStream()/importLegacyStream():failed to export and import the data ", perm1, perm);
  404. }
  405. template<> template<>
  406. void permission_object_t::test<22>()
  407. {
  408. // Deleted LLPermissions::exportFileXML() and LLPermissions::importXML()
  409. // because I can't find any non-test code references to it. 2009-05-04 JC
  410. }
  411. template<> template<>
  412. void permission_object_t::test<23>()
  413. {
  414. LLPermissions perm,perm1;
  415. LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  416. LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
  417. LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
  418. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  419. perm.init(creator,owner,lastOwner,group);
  420. std::ostringstream stream1, stream2;
  421. stream1 << perm;
  422. perm1.init(creator,owner,lastOwner,group);
  423. stream2 << perm1;
  424. ensure_equals("1:operator << failed", stream1.str(), stream2.str());
  425. }
  426. template<> template<>
  427. void permission_object_t::test<24>()
  428. {
  429. LLPermissions perm,perm1;
  430. LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
  431. LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
  432. LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
  433. LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
  434. perm.init(creator,owner,lastOwner,group);
  435. U32 base = PERM_TRANSFER | PERM_COPY;
  436. U32 ownerp = PERM_TRANSFER;
  437. U32 groupp = PERM_TRANSFER;
  438. U32 everyone = PERM_TRANSFER;
  439. U32 next = PERM_NONE;
  440. perm.initMasks(base, ownerp, everyone, groupp, next);
  441. LLSD sd = ll_create_sd_from_permissions(perm);
  442. perm1 = ll_permissions_from_sd(sd);
  443. ensure_equals("ll_permissions_from_sd() and ll_create_sd_from_permissions()functions failed", perm, perm1);
  444. }
  445. template<> template<>
  446. void permission_object_t::test<25>()
  447. {
  448. LLAggregatePermissions AggrPermission;
  449. LLAggregatePermissions AggrPermission1;
  450. ensure_equals("getU8() function failed", AggrPermission.getU8(), 0);
  451. ensure("isEmpty() function failed", AggrPermission.isEmpty());
  452. AggrPermission.getValue(PERM_TRANSFER);
  453. ensure_equals("getValue() function failed", AggrPermission.getValue(PERM_TRANSFER), 0x00);
  454. AggrPermission.aggregate(PERM_ITEM_UNRESTRICTED);
  455. ensure("aggregate() function failed", ! AggrPermission.isEmpty());
  456. AggrPermission1.aggregate(AggrPermission);
  457. ensure("aggregate() function failed", ! AggrPermission1.isEmpty());
  458. std::ostringstream stream1;
  459. stream1 << AggrPermission;
  460. ensure_equals("operator<< failed", stream1.str(), "{PI_COPY=All, PI_MODIFY=All, PI_TRANSFER=All}");
  461. }
  462. }