globalgroup_part2_test.py 20 KB

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