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