globalgroup_part2_test.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. # --- BEGIN COPYRIGHT BLOCK ---
  2. # Copyright (C) 2019 Red Hat, Inc.
  3. # All rights reserved.
  4. #
  5. # License: GPL (version 3 or any later version).
  6. # See LICENSE for details.
  7. # --- END COPYRIGHT BLOCK ----
  8. import pytest, os, ldap
  9. from lib389._constants import DEFAULT_SUFFIX, PW_DM
  10. from lib389.idm.user import UserAccount, UserAccounts
  11. from lib389.idm.group import UniqueGroup, UniqueGroups
  12. from lib389.idm.organizationalunit import OrganizationalUnit
  13. from lib389.topologies import topology_st as topo
  14. from lib389.idm.domain import Domain
  15. pytestmark = pytest.mark.tier1
  16. NESTEDGROUP_OU_GLOBAL = "ou=nestedgroup, {}".format(DEFAULT_SUFFIX)
  17. DEEPUSER_GLOBAL = "uid=DEEPUSER_GLOBAL, {}".format(NESTEDGROUP_OU_GLOBAL)
  18. DEEPUSER2_GLOBAL = "uid=DEEPUSER2_GLOBAL, {}".format(NESTEDGROUP_OU_GLOBAL)
  19. DEEPUSER3_GLOBAL = "uid=DEEPUSER3_GLOBAL, {}".format(NESTEDGROUP_OU_GLOBAL)
  20. DEEPGROUPSCRATCHENTRY_GLOBAL = "uid=scratchEntry,{}".format(NESTEDGROUP_OU_GLOBAL)
  21. GROUPDNATTRSCRATCHENTRY_GLOBAL = "uid=GROUPDNATTRSCRATCHENTRY_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL)
  22. GROUPDNATTRCHILDSCRATCHENTRY_GLOBAL = "uid=c1,{}".format(GROUPDNATTRSCRATCHENTRY_GLOBAL)
  23. NEWCHILDSCRATCHENTRY_GLOBAL = "uid=newChild,{}".format(NESTEDGROUP_OU_GLOBAL)
  24. ALLGROUPS_GLOBAL = "cn=ALLGROUPS_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL)
  25. GROUPA_GLOBAL = "cn=GROUPA_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL)
  26. GROUPB_GLOBAL = "cn=GROUPB_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL)
  27. GROUPC_GLOBAL = "cn=GROUPC_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL)
  28. GROUPD_GLOBAL = "cn=GROUPD_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL)
  29. GROUPE_GLOBAL = "cn=GROUPE_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL)
  30. GROUPF_GLOBAL = "cn=GROUPF_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL)
  31. GROUPG_GLOBAL = "cn=GROUPG_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL)
  32. GROUPH_GLOBAL = "cn=GROUPH_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL)
  33. CHILD1_GLOBAL = "uid=CHILD1_GLOBAL,{}".format(GROUPDNATTRSCRATCHENTRY_GLOBAL)
  34. CONTAINER_1_DELADD = "ou=Product Development,{}".format(DEFAULT_SUFFIX)
  35. CONTAINER_2_DELADD = "ou=Accounting,{}".format(DEFAULT_SUFFIX)
  36. @pytest.fixture(scope="function")
  37. def aci_of_user(request, topo):
  38. aci_list = Domain(topo.standalone, DEFAULT_SUFFIX).get_attr_vals('aci')
  39. def finofaci():
  40. domain = Domain(topo.standalone, DEFAULT_SUFFIX)
  41. domain.set('aci', None)
  42. for i in aci_list:
  43. domain.add("aci", i)
  44. request.addfinalizer(finofaci)
  45. @pytest.fixture(scope="module")
  46. def test_user(request, topo):
  47. for demo in ['Product Development', 'Accounting', 'nestedgroup']:
  48. OrganizationalUnit(topo.standalone, "ou={},{}".format(demo, DEFAULT_SUFFIX)).create(properties={'ou': demo})
  49. uas = UserAccounts(topo.standalone, DEFAULT_SUFFIX, 'ou=nestedgroup')
  50. for demo1 in ['DEEPUSER_GLOBAL', 'scratchEntry', 'DEEPUSER2_GLOBAL',
  51. 'DEEPUSER3_GLOBAL', 'GROUPDNATTRSCRATCHENTRY_GLOBAL', 'newChild']:
  52. uas.create(properties={
  53. 'uid': demo1,
  54. 'cn': demo1,
  55. 'sn': 'user',
  56. 'uidNumber': '1000',
  57. 'gidNumber': '2000',
  58. 'homeDirectory': '/home/' + demo1,
  59. 'userPassword': PW_DM
  60. })
  61. uas = UserAccounts(topo.standalone, DEFAULT_SUFFIX, 'uid=GROUPDNATTRSCRATCHENTRY_GLOBAL,ou=nestedgroup')
  62. for demo1 in ['c1', 'CHILD1_GLOBAL']:
  63. uas.create(properties={
  64. 'uid': demo1,
  65. 'cn': demo1,
  66. 'sn': 'user',
  67. 'uidNumber': '1000',
  68. 'gidNumber': '2000',
  69. 'homeDirectory': '/home/' + demo1,
  70. 'userPassword': PW_DM
  71. })
  72. grp = UniqueGroups(topo.standalone, DEFAULT_SUFFIX, rdn='ou=nestedgroup')
  73. for i in [('ALLGROUPS_GLOBAL', GROUPA_GLOBAL), ('GROUPA_GLOBAL', GROUPB_GLOBAL), ('GROUPB_GLOBAL', GROUPC_GLOBAL),
  74. ('GROUPC_GLOBAL', GROUPD_GLOBAL), ('GROUPD_GLOBAL', GROUPE_GLOBAL), ('GROUPE_GLOBAL', GROUPF_GLOBAL),
  75. ('GROUPF_GLOBAL', GROUPG_GLOBAL), ('GROUPG_GLOBAL', GROUPH_GLOBAL), ('GROUPH_GLOBAL', DEEPUSER_GLOBAL)]:
  76. grp.create(properties={'cn': i[0],
  77. 'ou': 'groups',
  78. 'uniquemember': i[1]
  79. })
  80. def test_undefined_in_group_eval_five(topo, test_user, aci_of_user):
  81. """
  82. Aci will not allow access as Group dn is not allowed so members will not allowed access.
  83. :id: 11451a96-7841-11e8-9f79-8c16451d917b
  84. :setup: server
  85. :steps:
  86. 1. Add test entry
  87. 2. Take a count of users using DN_DM
  88. 3. Add test user
  89. 4. add aci
  90. 5. test should fulfil the aci rules
  91. :expectedresults:
  92. 1. Entry should be added
  93. 2. Operation should succeed
  94. 3. Operation should succeed
  95. 4. Operation should succeed
  96. 5. Operation should succeed
  97. """
  98. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr=*)(version 3.0; aci "tester"; allow(all) groupdn != "ldap:///{}\ || ldap:///{}";)'.format(ALLGROUPS_GLOBAL, GROUPF_GLOBAL))
  99. conn = UserAccount(topo.standalone, DEEPUSER2_GLOBAL).bind(PW_DM)
  100. # This aci should NOT allow access
  101. user = UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL)
  102. with pytest.raises(ldap.INSUFFICIENT_ACCESS):
  103. user.replace("description", "Fred")
  104. assert user.get_attr_val_utf8('uid') == 'scratchEntry'
  105. def test_undefined_in_group_eval_six(topo, test_user, aci_of_user):
  106. """
  107. Aci will not allow access as tested user is not a member of allowed Group dn
  108. :id: 1904572e-7841-11e8-a9d8-8c16451d917b
  109. :setup: server
  110. :steps:
  111. 1. Add test entry
  112. 2. Take a count of users using DN_DM
  113. 3. Add test user
  114. 4. add aci
  115. 5. test should fullfil the aci rules
  116. :expectedresults:
  117. 1. Entry should be added
  118. 2. Operation should succeed
  119. 3. Operation should succeed
  120. 4. Operation should succeed
  121. 5. Operation should succeed
  122. """
  123. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr=*)(version 3.0; aci "tester"; allow(all) groupdn = "ldap:///{} || ldap:///{}" ;)'.format(GROUPH_GLOBAL, ALLGROUPS_GLOBAL))
  124. conn = UserAccount(topo.standalone, DEEPUSER3_GLOBAL).bind(PW_DM)
  125. # test UNDEFINED in group
  126. user = UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL)
  127. with pytest.raises(ldap.INSUFFICIENT_ACCESS):
  128. user.replace("description", "Fred")
  129. assert user.get_attr_val_utf8('uid') == 'scratchEntry'
  130. def test_undefined_in_group_eval_seven(topo, test_user, aci_of_user):
  131. """
  132. Aci will not allow access as tested user is not a member of allowed Group dn
  133. :id: 206b43c4-7841-11e8-b3ed-8c16451d917b
  134. :setup: server
  135. :steps:
  136. 1. Add test entry
  137. 2. Take a count of users using DN_DM
  138. 3. Add test user
  139. 4. add aci
  140. 5. test should fullfil the aci rules
  141. :expectedresults:
  142. 1. Entry should be added
  143. 2. Operation should succeed
  144. 3. Operation should succeed
  145. 4. Operation should succeed
  146. 5. Operation should succeed
  147. """
  148. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr=*)(version 3.0; aci "tester"; allow(all) groupdn = "ldap:///{}\ || ldap:///{}";)'.format(ALLGROUPS_GLOBAL, GROUPH_GLOBAL))
  149. conn = UserAccount(topo.standalone, DEEPUSER3_GLOBAL).bind(PW_DM)
  150. # test UNDEFINED in group
  151. user = UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL)
  152. with pytest.raises(ldap.INSUFFICIENT_ACCESS):
  153. user.replace("description", "Fred")
  154. assert user.get_attr_val_utf8('uid') == 'scratchEntry'
  155. def test_undefined_in_group_eval_eight(topo, test_user, aci_of_user):
  156. """
  157. Aci will not allow access as Group dn is not allowed so members will not allowed access.
  158. :id: 26ca7456-7841-11e8-801e-8c16451d917b
  159. :setup: server
  160. :steps:
  161. 1. Add test entry
  162. 2. Take a count of users using DN_DM
  163. 3. Add test user
  164. 4. add aci
  165. 5. test should fullfil the aci rules
  166. :expectedresults:
  167. 1. Entry should be added
  168. 2. Operation should succeed
  169. 3. Operation should succeed
  170. 4. Operation should succeed
  171. 5. Operation should succeed
  172. """
  173. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr=*)(version 3.0; aci "tester"; allow(all) groupdn != "ldap:///{} || ldap:///{} || ldap:///{}" ;)'.format(GROUPH_GLOBAL, GROUPA_GLOBAL, ALLGROUPS_GLOBAL))
  174. conn = UserAccount(topo.standalone, DEEPUSER3_GLOBAL).bind(PW_DM)
  175. # test UNDEFINED in group
  176. user = UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL)
  177. with pytest.raises(ldap.INSUFFICIENT_ACCESS):
  178. user.replace("description", "Fred")
  179. assert user.get_attr_val_utf8('uid') == 'scratchEntry'
  180. def test_undefined_in_group_eval_nine(topo, test_user, aci_of_user):
  181. """
  182. Aci will not allow access as Group dn is not allowed so members will not allowed access.
  183. :id: 38c7fbb0-7841-11e8-90aa-8c16451d917b
  184. :setup: server
  185. :steps:
  186. 1. Add test entry
  187. 2. Take a count of users using DN_DM
  188. 3. Add test user
  189. 4. add aci
  190. 5. test should fullfil the aci rules
  191. :expectedresults:
  192. 1. Entry should be added
  193. 2. Operation should succeed
  194. 3. Operation should succeed
  195. 4. Operation should succeed
  196. 5. Operation should succeed
  197. """
  198. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr=*)(version 3.0; aci "tester"; allow(all) groupdn != "ldap:///{}\ || ldap:///{} || ldap:///{}";)'.format(ALLGROUPS_GLOBAL, GROUPA_GLOBAL, GROUPH_GLOBAL))
  199. conn = UserAccount(topo.standalone, DEEPUSER3_GLOBAL).bind(PW_DM)
  200. # test UNDEFINED in group
  201. user = UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL)
  202. with pytest.raises(ldap.INSUFFICIENT_ACCESS):
  203. user.replace("sn", "Fred")
  204. assert user.get_attr_val_utf8('uid') == 'scratchEntry'
  205. def test_undefined_in_group_eval_ten(topo, test_user, aci_of_user):
  206. """
  207. Test the userattr keyword to ensure that it evaluates correctly.
  208. :id: 46c0fb72-7841-11e8-af1d-8c16451d917b
  209. :setup: server
  210. :steps:
  211. 1. Add test entry
  212. 2. Take a count of users using DN_DM
  213. 3. Add test user
  214. 4. add aci
  215. 5. test should fullfil the aci rules
  216. :expectedresults:
  217. 1. Entry should be added
  218. 2. Operation should succeed
  219. 3. Operation should succeed
  220. 4. Operation should succeed
  221. 5. Operation should succeed
  222. """
  223. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr=*)(version 3.0; aci "tester"; allow(all) userattr = "description#GROUPDN";)')
  224. user = UserAccount(topo.standalone, DEEPGROUPSCRATCHENTRY_GLOBAL)
  225. user.add("description", [ALLGROUPS_GLOBAL, GROUPG_GLOBAL])
  226. conn = UserAccount(topo.standalone, DEEPUSER_GLOBAL).bind(PW_DM)
  227. # Test the userattr keyword
  228. user.add("sn", "Fred")
  229. assert UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL).get_attr_val_utf8('uid') == 'scratchEntry'
  230. user.remove("description", [ALLGROUPS_GLOBAL, GROUPG_GLOBAL])
  231. def test_undefined_in_group_eval_eleven(topo, test_user, aci_of_user):
  232. """
  233. Aci will not allow access as description is there with the user entry which is not allowed in ACI
  234. :id: 4cfa28e2-7841-11e8-8117-8c16451d917b
  235. :setup: server
  236. :steps:
  237. 1. Add test entry
  238. 2. Take a count of users using DN_DM
  239. 3. Add test user
  240. 4. add aci
  241. 5. test should fullfil the aci rules
  242. :expectedresults:
  243. 1. Entry should be added
  244. 2. Operation should succeed
  245. 3. Operation should succeed
  246. 4. Operation should succeed
  247. 5. Operation should succeed
  248. """
  249. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr=*)(version 3.0; aci "tester"; allow(all) not( userattr = "description#GROUPDN");)')
  250. user = UserAccount(topo.standalone, DEEPGROUPSCRATCHENTRY_GLOBAL)
  251. user.add("description", [ALLGROUPS_GLOBAL, GROUPH_GLOBAL])
  252. conn = UserAccount(topo.standalone, DEEPUSER_GLOBAL).bind(PW_DM)
  253. # Test that not(UNDEFINED(attrval1))
  254. user1 = UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL)
  255. with pytest.raises(ldap.INSUFFICIENT_ACCESS):
  256. user1.add("sn", "Fred1")
  257. assert user.get_attr_val_utf8('cn')
  258. user.remove("description", [ALLGROUPS_GLOBAL, GROUPH_GLOBAL])
  259. def test_undefined_in_group_eval_twelve(topo, test_user, aci_of_user):
  260. """
  261. Test with the parent keyord that Yields TRUE as description is present in tested entry
  262. :id: 54f471ec-7841-11e8-8910-8c16451d917b
  263. :setup: server
  264. :steps:
  265. 1. Add test entry
  266. 2. Take a count of users using DN_DM
  267. 3. Add test user
  268. 4. add aci
  269. 5. test should fullfil the aci rules
  270. :expectedresults:
  271. 1. Entry should be added
  272. 2. Operation should succeed
  273. 3. Operation should succeed
  274. 4. Operation should succeed
  275. 5. Operation should succeed
  276. """
  277. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr=*)(version 3.0; aci "tester"; allow(all) userattr = "parent[0,1].description#GROUPDN";)')
  278. user = UserAccount(topo.standalone, GROUPDNATTRSCRATCHENTRY_GLOBAL)
  279. user.add("description", [ALLGROUPS_GLOBAL, GROUPD_GLOBAL])
  280. conn = UserAccount(topo.standalone, DEEPUSER_GLOBAL).bind(PW_DM)
  281. # Test with the parent keyord
  282. UserAccount(conn, GROUPDNATTRCHILDSCRATCHENTRY_GLOBAL).add("sn", "Fred")
  283. assert UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL).get_attr_val_utf8('cn')
  284. user.remove("description", [ALLGROUPS_GLOBAL, GROUPD_GLOBAL])
  285. def test_undefined_in_group_eval_fourteen(topo, test_user, aci_of_user):
  286. """
  287. Test with parent keyword that Yields FALSE as description is not present in tested entry
  288. :id: 5c527218-7841-11e8-8909-8c16451d917b
  289. :setup: server
  290. :steps:
  291. 1. Add test entry
  292. 2. Take a count of users using DN_DM
  293. 3. Add test user
  294. 4. add aci
  295. 5. test should fullfil the aci rules
  296. :expectedresults:
  297. 1. Entry should be added
  298. 2. Operation should succeed
  299. 3. Operation should succeed
  300. 4. Operation should succeed
  301. 5. Operation should succeed
  302. """
  303. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr=*)(version 3.0; aci "tester"; allow(all) userattr = "parent[0,1].description#GROUPDN";)')
  304. user = UserAccount(topo.standalone, GROUPDNATTRSCRATCHENTRY_GLOBAL)
  305. user.add("description", [ALLGROUPS_GLOBAL, GROUPG_GLOBAL])
  306. conn = UserAccount(topo.standalone, DEEPUSER2_GLOBAL).bind(PW_DM)
  307. # Test with parent keyword
  308. user1 = UserAccount(conn, GROUPDNATTRCHILDSCRATCHENTRY_GLOBAL)
  309. with pytest.raises(ldap.INSUFFICIENT_ACCESS):
  310. user1.add("sn", "Fred")
  311. assert UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL).get_attr_val_utf8('cn')
  312. user.remove("description", [ALLGROUPS_GLOBAL, GROUPG_GLOBAL])
  313. def test_undefined_in_group_eval_fifteen(topo, test_user, aci_of_user):
  314. """
  315. Here do the same tests for userattr with the parent keyword.
  316. :id: 6381c070-7841-11e8-a6b6-8c16451d917b
  317. :setup: server
  318. :steps:
  319. 1. Add test entry
  320. 2. Take a count of users using DN_DM
  321. 3. Add test user
  322. 4. add aci
  323. 5. test should fullfil the aci rules
  324. :expectedresults:
  325. 1. Entry should be added
  326. 2. Operation should succeed
  327. 3. Operation should succeed
  328. 4. Operation should succeed
  329. 5. Operation should succeed
  330. """
  331. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr=*)(version 3.0; aci "tester"; allow(all) userattr = "parent[0,1].description#USERDN";)')
  332. UserAccount(topo.standalone, NESTEDGROUP_OU_GLOBAL).add("description", DEEPUSER_GLOBAL)
  333. # Here do the same tests for userattr with the parent keyword.
  334. conn = UserAccount(topo.standalone, DEEPUSER_GLOBAL).bind(PW_DM)
  335. UserAccount(conn, NEWCHILDSCRATCHENTRY_GLOBAL).add("description", DEEPUSER_GLOBAL)
  336. def test_undefined_in_group_eval_sixteen(topo, test_user, aci_of_user):
  337. """
  338. Test with parent keyword with not key
  339. :id: 69852688-7841-11e8-8db1-8c16451d917b
  340. :setup: server
  341. :steps:
  342. 1. Add test entry
  343. 2. Take a count of users using DN_DM
  344. 3. Add test user
  345. 4. add aci
  346. 5. test should fullfil the aci rules
  347. :expectedresults:
  348. 1. Entry should be added
  349. 2. Operation should succeed
  350. 3. Operation should succeed
  351. 4. Operation should succeed
  352. 5. Operation should succeed
  353. """
  354. domain = Domain(topo.standalone, DEFAULT_SUFFIX)
  355. domain.add("aci",'(targetattr=*)(version 3.0; aci "tester"; allow(all) not ( userattr = "parent[0,1].description#USERDN");)')
  356. domain.add("description", DEEPUSER_GLOBAL)
  357. conn = UserAccount(topo.standalone, DEEPUSER_GLOBAL).bind(PW_DM)
  358. # Test with parent keyword with not key
  359. user = UserAccount(conn, NEWCHILDSCRATCHENTRY_GLOBAL)
  360. with pytest.raises(ldap.INSUFFICIENT_ACCESS):
  361. user.add("description",DEEPUSER_GLOBAL)
  362. def test_undefined_in_group_eval_seventeen(topo, test_user, aci_of_user):
  363. """
  364. Test with the parent keyord that Yields TRUE as description is present in tested entry
  365. :id: 7054d1c0-7841-11e8-8177-8c16451d917b
  366. :setup: server
  367. :steps:
  368. 1. Add test entry
  369. 2. Take a count of users using DN_DM
  370. 3. Add test user
  371. 4. add aci
  372. 5. test should fullfil the aci rules
  373. :expectedresults:
  374. 1. Entry should be added
  375. 2. Operation should succeed
  376. 3. Operation should succeed
  377. 4. Operation should succeed
  378. 5. Operation should succeed
  379. """
  380. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr=*)(version 3.0; aci "tester"; allow(all) userattr = "parent[0,1].description#GROUPDN";)')
  381. user = UserAccount(topo.standalone, GROUPDNATTRSCRATCHENTRY_GLOBAL)
  382. # Test with the parent keyord
  383. user.add("description", [ALLGROUPS_GLOBAL, GROUPD_GLOBAL])
  384. conn = UserAccount(topo.standalone, DEEPUSER_GLOBAL).bind(PW_DM)
  385. UserAccount(conn, CHILD1_GLOBAL).add("description", DEEPUSER_GLOBAL)
  386. user.remove("description", [ALLGROUPS_GLOBAL, GROUPD_GLOBAL])
  387. def test_undefined_in_group_eval_eighteen(topo, test_user, aci_of_user):
  388. """
  389. Test with parent keyword with not key
  390. :id: 768b9ab0-7841-11e8-87c3-8c16451d917b
  391. :setup: server
  392. :steps:
  393. 1. Add test entry
  394. 2. Take a count of users using DN_DM
  395. 3. Add test user
  396. 4. add aci
  397. 5. test should fullfil the aci rules
  398. :expectedresults:
  399. 1. Entry should be added
  400. 2. Operation should succeed
  401. 3. Operation should succeed
  402. 4. Operation should succeed
  403. 5. Operation should succeed
  404. """
  405. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr=*)(version 3.0; aci "tester"; allow(all) not (userattr = "parent[0,1].description#GROUPDN" );)')
  406. user = UserAccount(topo.standalone, GROUPDNATTRSCRATCHENTRY_GLOBAL)
  407. # Test with parent keyword with not key
  408. user.add("description", [ALLGROUPS_GLOBAL, GROUPH_GLOBAL])
  409. conn = UserAccount(topo.standalone, DEEPUSER_GLOBAL).bind(PW_DM)
  410. user = UserAccount(conn, CHILD1_GLOBAL)
  411. with pytest.raises(ldap.INSUFFICIENT_ACCESS):
  412. user.add("description", DEEPUSER_GLOBAL)
  413. if __name__ == "__main__":
  414. CURRENT_FILE = os.path.realpath(__file__)
  415. pytest.main("-s -v %s" % CURRENT_FILE)