search_real_part2_test.py 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  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, ErrorLog
  10. from lib389.idm.user import UserAccount, UserAccounts
  11. from lib389.idm.account import Accounts
  12. from lib389.idm.organizationalunit import OrganizationalUnits
  13. from lib389.topologies import topology_st as topo
  14. from lib389.idm.domain import Domain
  15. pytestmark = pytest.mark.tier1
  16. CONTAINER_1_DELADD = "ou=Product Development,{}".format(DEFAULT_SUFFIX)
  17. CONTAINER_2_DELADD = "ou=Accounting,{}".format(DEFAULT_SUFFIX)
  18. USER_ANUJ = "uid=Anuj Borah,{}".format(CONTAINER_1_DELADD)
  19. USER_ANANDA = "uid=Ananda Borah,{}".format(CONTAINER_2_DELADD)
  20. @pytest.fixture(scope="function")
  21. def aci_of_user(request, topo):
  22. # Add anonymous access aci
  23. ACI_TARGET = "(targetattr != \"userpassword\")(target = \"ldap:///%s\")" % (DEFAULT_SUFFIX)
  24. ACI_ALLOW = "(version 3.0; acl \"Anonymous Read access\"; allow (read,search,compare)"
  25. ACI_SUBJECT = "(userdn=\"ldap:///anyone\");)"
  26. ANON_ACI = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
  27. suffix = Domain(topo.standalone, DEFAULT_SUFFIX)
  28. try:
  29. suffix.add('aci', ANON_ACI)
  30. except ldap.TYPE_OR_VALUE_EXISTS:
  31. pass
  32. aci_list = Domain(topo.standalone, DEFAULT_SUFFIX).get_attr_vals('aci')
  33. def finofaci():
  34. domain = Domain(topo.standalone, DEFAULT_SUFFIX)
  35. domain.set('aci', None)
  36. for i in aci_list:
  37. domain.add("aci", i)
  38. pass
  39. request.addfinalizer(finofaci)
  40. @pytest.fixture(scope="module")
  41. def test_uer(request, topo):
  42. topo.standalone.config.loglevel((ErrorLog.ACL_SUMMARY,))
  43. ous = OrganizationalUnits(topo.standalone, DEFAULT_SUFFIX)
  44. for i in ['Product Development', 'Accounting']:
  45. ous.create(properties={'ou': i})
  46. users = UserAccounts(topo.standalone, DEFAULT_SUFFIX, rdn='ou=Product Development')
  47. users.create(properties={
  48. 'uid': 'Anuj Borah',
  49. 'cn': 'Anuj Borah',
  50. 'sn': 'user',
  51. 'uidNumber': '1000',
  52. 'gidNumber': '2000',
  53. 'homeDirectory': '/home/' + 'AnujBorah',
  54. 'userPassword': PW_DM
  55. })
  56. users = UserAccounts(topo.standalone, DEFAULT_SUFFIX, rdn='ou=Accounting')
  57. users.create(properties={
  58. 'uid': 'Ananda Borah',
  59. 'cn': 'Ananda Borah',
  60. 'sn': 'user',
  61. 'uidNumber': '1000',
  62. 'gidNumber': '2000',
  63. 'homeDirectory': '/home/' + 'AnandaBorah',
  64. 'userPassword': PW_DM
  65. })
  66. def test_deny_all_access_with__target_set_on_non_leaf(topo, test_uer, aci_of_user):
  67. """Search Test 11 Deny all access with != target set on non-leaf
  68. :id: f1c5d72a-6e11-11e8-aa9d-8c16451d917b
  69. :setup: Standalone Instance
  70. :steps:
  71. 1. Add Entry
  72. 2. Add ACI
  73. 3. Bind with test USER_ANUJ
  74. 4. Try search
  75. 5. Delete Entry,test USER_ANUJ, ACI
  76. :expectedresults:
  77. 1. Operation should success
  78. 2. Operation should success
  79. 3. Operation should success
  80. 4. Operation should Fail
  81. 5. Operation should success
  82. """
  83. ACI_TARGET = "(target != ldap:///{})(targetattr=\"*\")".format(CONTAINER_2_DELADD)
  84. ACI_ALLOW = '(version 3.0; acl "Name of the ACI"; deny absolute (all)'
  85. ACI_SUBJECT = 'userdn="ldap:///anyone";)'
  86. ACI_BODY = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
  87. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ACI_BODY)
  88. conn = UserAccount(topo.standalone, USER_ANANDA).bind(PW_DM)
  89. # After binding with USER_ANANDA , aci will limit the search to itself
  90. assert 1 == len(Accounts(conn, DEFAULT_SUFFIX).filter('(cn=*)'))
  91. conn = UserAccount(topo.standalone, USER_ANUJ).bind(PW_DM)
  92. # After binding with USER_ANUJ , aci will limit the search to itself
  93. assert 1 == len(Accounts(conn, DEFAULT_SUFFIX).filter('(cn=*)'))
  94. # After binding with root , the actual number of users will be given
  95. assert 4 == len(Accounts(topo.standalone, DEFAULT_SUFFIX).filter('(cn=*)'))
  96. def test_deny_all_access_with__target_set_on_wildcard_non_leaf(
  97. topo, test_uer, aci_of_user
  98. ):
  99. """Search Test 12 Deny all access with != target set on wildcard non-leaf
  100. :id: 02f34640-6e12-11e8-a382-8c16451d917b
  101. :setup: Standalone Instance
  102. :steps:
  103. 1. Add Entry
  104. 2. Add ACI
  105. 3. Bind with test USER_ANUJ
  106. 4. Try search
  107. 5. Delete Entry,test USER_ANUJ, ACI
  108. :expectedresults:
  109. 1. Operation should success
  110. 2. Operation should success
  111. 3. Operation should success
  112. 4. Operation should Fail
  113. 5. Operation should success
  114. """
  115. ACI_TARGET = "(target != ldap:///ou=Product*,{})(targetattr=\"*\")".format(
  116. DEFAULT_SUFFIX)
  117. ACI_ALLOW = '(version 3.0; acl "Name of the ACI"; deny absolute (all)'
  118. ACI_SUBJECT = 'userdn="ldap:///anyone";)'
  119. ACI_BODY = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
  120. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ACI_BODY)
  121. conn = UserAccount(topo.standalone, USER_ANANDA).bind(PW_DM)
  122. # aci will limit the search to ou=Product it will block others
  123. assert 1 == len(Accounts(conn, DEFAULT_SUFFIX).filter('(cn=*)'))
  124. conn = UserAccount(topo.standalone, USER_ANUJ).bind(PW_DM)
  125. # aci will limit the search to ou=Product it will block others
  126. assert 1 == len(Accounts(conn, DEFAULT_SUFFIX).filter('(cn=*)'))
  127. # with root , aci will give actual no of users , without any limit.
  128. assert 4 == len(Accounts(topo.standalone, DEFAULT_SUFFIX).filter('(cn=*)'))
  129. def test_deny_all_access_with__target_set_on_wildcard_leaf(
  130. topo, test_uer, aci_of_user
  131. ):
  132. """Search Test 13 Deny all access with != target set on wildcard leaf
  133. :id: 16c54d76-6e12-11e8-b5ba-8c16451d917b
  134. :setup: Standalone Instance
  135. :steps:
  136. 1. Add Entry
  137. 2. Add ACI
  138. 3. Bind with test USER_ANUJ
  139. 4. Try search
  140. 5. Delete Entry,test USER_ANUJ, ACI
  141. :expectedresults:
  142. 1. Operation should success
  143. 2. Operation should success
  144. 3. Operation should success
  145. 4. Operation should Fail
  146. 5. Operation should success
  147. """
  148. ACI_TARGET = "(target != ldap:///uid=Anuj*, ou=*,{})(targetattr=\"*\")".format(
  149. DEFAULT_SUFFIX)
  150. ACI_ALLOW = '(version 3.0; acl "Name of the ACI"; deny absolute (all)'
  151. ACI_SUBJECT = 'userdn="ldap:///anyone";)'
  152. ACI_BODY = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
  153. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ACI_BODY)
  154. conn = UserAccount(topo.standalone, USER_ANANDA).bind(PW_DM)
  155. # aci will limit the search to cn=Jeff it will block others
  156. assert 1 == len(Accounts(conn, DEFAULT_SUFFIX).filter('(cn=*)'))
  157. conn = UserAccount(topo.standalone, USER_ANUJ).bind(PW_DM)
  158. # aci will limit the search to cn=Jeff it will block others
  159. assert 1 == len(Accounts(conn, DEFAULT_SUFFIX).filter('(cn=*)'))
  160. # with root there is no aci blockage
  161. assert 4 == len(Accounts(topo.standalone, DEFAULT_SUFFIX).filter('(cn=*)'))
  162. def test_deny_all_access_with_targetfilter_using_equality_search(
  163. topo, test_uer, aci_of_user
  164. ):
  165. """Search Test 14 Deny all access with targetfilter using equality search
  166. :id: 27255e04-6e12-11e8-8e35-8c16451d917b
  167. :setup: Standalone Instance
  168. :steps:
  169. 1. Add Entry
  170. 2. Add ACI
  171. 3. Bind with test USER_ANUJ
  172. 4. Try search
  173. 5. Delete Entry,test USER_ANUJ, ACI
  174. :expectedresults:
  175. 1. Operation should success
  176. 2. Operation should success
  177. 3. Operation should success
  178. 4. Operation should Fail
  179. 5. Operation should success
  180. """
  181. ACI_TARGET = '(targetfilter ="(uid=Anuj Borah)")(target = ldap:///{})(targetattr="*")'.format(
  182. DEFAULT_SUFFIX)
  183. ACI_ALLOW = '(version 3.0; acl "Name of the ACI"; deny absolute (all)'
  184. ACI_SUBJECT = 'userdn="ldap:///anyone";)'
  185. ACI_BODY = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
  186. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ACI_BODY)
  187. conn = UserAccount(topo.standalone, USER_ANANDA).bind(PW_DM)
  188. # aci will block the search to cn=Jeff
  189. assert 0 == len(Accounts(conn, DEFAULT_SUFFIX).filter('(uid=Anuj Borah)'))
  190. conn = UserAccount(topo.standalone, USER_ANUJ).bind(PW_DM)
  191. # aci will block the search to cn=Jeff
  192. assert 0 == len(Accounts(conn, DEFAULT_SUFFIX).filter('(uid=Anuj Borah)'))
  193. # with root there is no blockage
  194. assert 1 == len(Accounts(topo.standalone, DEFAULT_SUFFIX).filter('(uid=Anuj Borah)'))
  195. def test_deny_all_access_with_targetfilter_using_equality_search_two(
  196. topo, test_uer, aci_of_user
  197. ):
  198. """Test that Search Test 15 Deny all access with targetfilter using != equality search
  199. :id: 3966bcd4-6e12-11e8-83ce-8c16451d917b
  200. :setup: Standalone Instance
  201. :steps:
  202. 1. Add Entry
  203. 2. Add ACI
  204. 3. Bind with test USER_ANUJ
  205. 4. Try search
  206. 5. Delete Entry,test USER_ANUJ, ACI
  207. :expectedresults:
  208. 1. Operation should success
  209. 2. Operation should success
  210. 3. Operation should success
  211. 4. Operation should Fail
  212. 5. Operation should success
  213. """
  214. ACI_TARGET = '(targetfilter !="(uid=Anuj Borah)")(target = ldap:///{})(targetattr="*")'.format(
  215. DEFAULT_SUFFIX)
  216. ACI_ALLOW = '(version 3.0; acl "Name of the ACI"; deny absolute (all)'
  217. ACI_SUBJECT = 'userdn="ldap:///anyone";)'
  218. ACI_BODY = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
  219. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ACI_BODY)
  220. conn = UserAccount(topo.standalone, USER_ANANDA).bind(PW_DM)
  221. # aci will limit the search to cn=Jeff it will block others
  222. assert 1 == len(Accounts(conn, DEFAULT_SUFFIX).filter('(cn=*)'))
  223. conn = UserAccount(topo.standalone, USER_ANUJ).bind(PW_DM)
  224. # aci will limit the search to cn=Jeff it will block others
  225. assert 1 == len(Accounts(conn, DEFAULT_SUFFIX).filter('(cn=*)'))
  226. # with root there is no blockage
  227. assert 4 == len(Accounts(topo.standalone, DEFAULT_SUFFIX).filter('(cn=*)'))
  228. def test_deny_all_access_with_targetfilter_using_substring_search(
  229. topo, test_uer, aci_of_user
  230. ):
  231. """Test that Search Test 16 Deny all access with targetfilter using substring search
  232. :id: 44d7b4ba-6e12-11e8-b420-8c16451d917b
  233. :setup: Standalone Instance
  234. :steps:
  235. 1. Add Entry
  236. 2. Add ACI
  237. 3. Bind with test USER_ANUJ
  238. 4. Try search
  239. 5. Delete Entry,test USER_ANUJ, ACI
  240. :expectedresults:
  241. 1. Operation should success
  242. 2. Operation should success
  243. 3. Operation should success
  244. 4. Operation should Fail
  245. 5. Operation should success
  246. """
  247. ACI_TARGET = '(targetfilter ="(uid=Anu*)")(target = ldap:///{})(targetattr="*")'.format(
  248. DEFAULT_SUFFIX)
  249. ACI_ALLOW = '(version 3.0; acl "Name of the ACI"; deny absolute (all)'
  250. ACI_SUBJECT = 'userdn="ldap:///anyone";)'
  251. ACI_BODY = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
  252. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ACI_BODY)
  253. conn = UserAccount(topo.standalone, USER_ANANDA).bind(PW_DM)
  254. # aci block anything cn=j*
  255. assert 0 == len(Accounts(conn, DEFAULT_SUFFIX).filter('(cn=Anu*)'))
  256. conn = UserAccount(topo.standalone, USER_ANUJ).bind(PW_DM)
  257. # aci block anything cn=j*
  258. assert 0 == len(Accounts(conn, DEFAULT_SUFFIX).filter('(cn=Anu*)'))
  259. # with root there is no blockage
  260. assert 1 == len(Accounts(topo.standalone, DEFAULT_SUFFIX).filter('(cn=Anu*)'))
  261. def test_deny_all_access_with_targetfilter_using_substring_search_two(
  262. topo, test_uer, aci_of_user
  263. ):
  264. """Test that Search Test 17 Deny all access with targetfilter using != substring search
  265. :id: 55b12d98-6e12-11e8-8cf4-8c16451d917b
  266. :setup: Standalone Instance
  267. :steps:
  268. 1. Add Entry
  269. 2. Add ACI
  270. 3. Bind with test USER_ANUJ
  271. 4. Try search
  272. 5. Delete Entry,test USER_ANUJ, ACI
  273. :expectedresults:
  274. 1. Operation should success
  275. 2. Operation should success
  276. 3. Operation should success
  277. 4. Operation should Fail
  278. 5. Operation should success
  279. """
  280. ACI_TARGET = '(targetfilter !="(uid=Anu*)")(target = ldap:///{})(targetattr="*")'.format(
  281. DEFAULT_SUFFIX
  282. )
  283. ACI_ALLOW = '(version 3.0; acl "Name of the ACI"; deny (all)'
  284. ACI_SUBJECT = 'userdn="ldap:///anyone";)'
  285. ACI_BODY = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
  286. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ACI_BODY)
  287. conn = UserAccount(topo.standalone, USER_ANANDA).bind(PW_DM)
  288. # aci allow anything cn=j*, it will block others
  289. assert 1 == len(Accounts(conn, DEFAULT_SUFFIX).filter('(uid=*)'))
  290. conn = UserAccount(topo.standalone, USER_ANUJ).bind(PW_DM)
  291. # aci allow anything cn=j*, it will block others
  292. assert 1 == len(Accounts(conn, DEFAULT_SUFFIX).filter('(uid=*)'))
  293. # with root there is no blockage
  294. assert 3 == len(Accounts(topo.standalone, DEFAULT_SUFFIX).filter('(uid=*)'))
  295. def test_deny_all_access_with_targetfilter_using_boolean_or_of_two_equality_search(
  296. topo, test_uer, aci_of_user, request
  297. ):
  298. """Search Test 18 Deny all access with targetfilter using boolean OR of two equality search
  299. :id: 29cc35fa-793f-11e8-988f-8c16451d917b
  300. :setup: Standalone Instance
  301. :steps:
  302. 1. Add Entry
  303. 2. Add ACI
  304. 3. Bind with test USER_ANUJ
  305. 4. Try search
  306. 5. Delete Entry,test USER_ANUJ, ACI
  307. :expectedresults:
  308. 1. Operation should success
  309. 2. Operation should success
  310. 3. Operation should success
  311. 4. Operation should Fail
  312. 5. Operation should success
  313. """
  314. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(target = ldap:///{})(targetattr = "*")'
  315. '(targetfilter = (|(cn=scarter)(cn=jvaughan)))(version 3.0; acl "{}"; '
  316. 'deny absolute (all) (userdn = "ldap:///anyone") ;)'.format(DEFAULT_SUFFIX, request.node.name))
  317. UserAccount(topo.standalone, USER_ANANDA).set("cn", "scarter")
  318. UserAccount(topo.standalone, USER_ANUJ).set("cn", "jvaughan")
  319. conn = UserAccount(topo.standalone, USER_ANANDA).bind(PW_DM)
  320. # aci will deny_all_access_with_targetfilter_using_boolean_or_of_two_equality_search
  321. user = UserAccount(conn, USER_ANANDA)
  322. with pytest.raises(IndexError):
  323. user.get_attr_val_utf8('uid')
  324. # aci will deny_all_access_with_targetfilter_using_boolean_or_of_two_equality_search
  325. user = UserAccount(conn, USER_ANUJ)
  326. with pytest.raises(IndexError):
  327. user.get_attr_val_utf8('uid')
  328. # with root no blockage
  329. assert UserAccount(topo.standalone, USER_ANANDA).get_attr_val_utf8('uid') == 'Ananda Borah'
  330. # with root no blockage
  331. assert UserAccount(topo.standalone, USER_ANUJ).get_attr_val_utf8('uid') == 'Anuj Borah'
  332. def test_deny_all_access_to__userdn_two(topo, test_uer, aci_of_user):
  333. """Search Test 19 Deny all access to != userdn
  334. :id: 693496c0-6e12-11e8-80dc-8c16451d917b
  335. :setup: Standalone Instance
  336. :steps:
  337. 1. Add Entry
  338. 2. Add ACI
  339. 3. Bind with test USER_ANUJ
  340. 4. Try search
  341. 5. Delete Entry,test USER_ANUJ, ACI
  342. :expectedresults:
  343. 1. Operation should success
  344. 2. Operation should success
  345. 3. Operation should success
  346. 4. Operation should Fail
  347. 5. Operation should success
  348. """
  349. ACI_TARGET = "(target = ldap:///{})(targetattr=\"*\")".format(DEFAULT_SUFFIX)
  350. ACI_ALLOW = '(version 3.0; acl "Name of the ACI"; deny absolute (all)'
  351. ACI_SUBJECT = 'userdn!="ldap:///{}";)'.format(USER_ANANDA)
  352. ACI_BODY = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
  353. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ACI_BODY)
  354. conn = UserAccount(topo.standalone, USER_ANANDA).bind(PW_DM)
  355. # aci will not block anything for USER_ANANDA , it block other users
  356. assert 4 == len(Accounts(conn, DEFAULT_SUFFIX).filter('(cn=*)'))
  357. conn = UserAccount(topo.standalone, USER_ANUJ).bind(PW_DM)
  358. # aci will block everything for other users
  359. assert 0 == len(Accounts(conn, DEFAULT_SUFFIX).filter('(cn=*)'))
  360. # with root there is no aci blockage
  361. assert 4 == len(Accounts(topo.standalone, DEFAULT_SUFFIX).filter('(cn=*)'))
  362. def test_deny_all_access_with_userdn(topo, test_uer, aci_of_user):
  363. """Search Test 20 Deny all access with userdn
  364. :id: 75aada86-6e12-11e8-bd34-8c16451d917b
  365. :setup: Standalone Instance
  366. :steps:
  367. 1. Add Entry
  368. 2. Add ACI
  369. 3. Bind with test USER_ANUJ
  370. 4. Try search
  371. 5. Delete Entry,test USER_ANUJ, ACI
  372. :expectedresults:
  373. 1. Operation should success
  374. 2. Operation should success
  375. 3. Operation should success
  376. 4. Operation should Fail
  377. 5. Operation should success
  378. """
  379. ACI_TARGET = "(target = ldap:///{})(targetattr=\"*\")".format(DEFAULT_SUFFIX)
  380. ACI_ALLOW = '(version 3.0; acl "Name of the ACI"; deny (all)'
  381. ACI_SUBJECT = 'userdn="ldap:///{}";)'.format(USER_ANANDA)
  382. ACI_BODY = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
  383. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ACI_BODY)
  384. conn = UserAccount(topo.standalone, USER_ANANDA).bind(PW_DM)
  385. # aci will block anything for USER_ANANDA , it not block other users
  386. assert 0 == len(Accounts(conn, DEFAULT_SUFFIX).filter('(cn=*)'))
  387. conn = UserAccount(topo.standalone, USER_ANUJ).bind(PW_DM)
  388. # aci will block anything for other users
  389. assert 4 == len(Accounts(conn, DEFAULT_SUFFIX).filter('(cn=*)'))
  390. # with root thers is no aci blockage
  391. assert 4 == len(Accounts(topo.standalone, DEFAULT_SUFFIX).filter('(cn=*)'))
  392. def test_deny_all_access_with_targetfilter_using_presence_search(
  393. topo, test_uer, aci_of_user
  394. ):
  395. """Search Test 21 Deny all access with targetfilter using presence search
  396. :id: 85244a42-6e12-11e8-9480-8c16451d917b
  397. :setup: Standalone Instance
  398. :steps:
  399. 1. Add Entry
  400. 2. Add ACI
  401. 3. Bind with test USER_ANUJ
  402. 4. Try search
  403. 5. Delete Entry,test USER_ANUJ, ACI
  404. :expectedresults:
  405. 1. Operation should success
  406. 2. Operation should success
  407. 3. Operation should success
  408. 4. Operation should Fail
  409. 5. Operation should success
  410. """
  411. user = UserAccounts(topo.standalone, DEFAULT_SUFFIX).create_test_user()
  412. user.set('userPassword', PW_DM)
  413. ACI_TARGET = '(targetfilter ="(cn=*)")(target = ldap:///{})(targetattr="*")'.format(
  414. DEFAULT_SUFFIX)
  415. ACI_ALLOW = '(version 3.0; acl "Name of the ACI"; deny absolute (all)'
  416. ACI_SUBJECT = 'userdn="ldap:///anyone";)'
  417. ACI_BODY = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
  418. Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ACI_BODY)
  419. conn = UserAccount(topo.standalone, USER_ANANDA).bind(PW_DM)
  420. # aci will eny_all_access_with_targetfilter_using_presence_search
  421. user = UserAccount(conn, 'uid=test_user_1000,ou=People,{}'.format(DEFAULT_SUFFIX))
  422. with pytest.raises(IndexError):
  423. user.get_attr_val_utf8('cn')
  424. # with root no blockage
  425. assert UserAccount(topo.standalone, 'uid=test_user_1000,ou=People,{}'.format(DEFAULT_SUFFIX)).get_attr_val_utf8('cn') == 'test_user_1000'
  426. if __name__ == "__main__":
  427. CURRENT_FILE = os.path.realpath(__file__)
  428. pytest.main("-s -v %s" % CURRENT_FILE)