| 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 |
ACLGROUP_OU_GLOBAL = "ou=ACLGroup,{}".format(DEFAULT_SUFFIX) |
| 21 |
NESTEDGROUP_OU_GLOBAL = "ou=nestedgroup, {}".format(DEFAULT_SUFFIX) |
| 22 |
TESTING_OU_GLOBAL = "ou=Product Testing,{}".format(DEFAULT_SUFFIX) |
| 23 |
DEEPUSER_GLOBAL = "uid=DEEPUSER_GLOBAL, {}".format(NESTEDGROUP_OU_GLOBAL) |
| 24 |
DEEPUSER1_GLOBAL = "uid=DEEPUSER1_GLOBAL, {}".format(NESTEDGROUP_OU_GLOBAL) |
| 25 |
DEEPUSER2_GLOBAL = "uid=DEEPUSER2_GLOBAL, {}".format(NESTEDGROUP_OU_GLOBAL) |
| 26 |
DEEPUSER3_GLOBAL = "uid=DEEPUSER3_GLOBAL, {}".format(NESTEDGROUP_OU_GLOBAL) |
| 27 |
DEEPGROUPSCRATCHENTRY_GLOBAL = "uid=scratchEntry,{}".format(NESTEDGROUP_OU_GLOBAL) |
| 28 |
GROUPDNATTRSCRATCHENTRY_GLOBAL = "uid=GROUPDNATTRSCRATCHENTRY_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL) |
| 29 |
GROUPDNATTRCHILDSCRATCHENTRY_GLOBAL = "uid=c1,{}".format(GROUPDNATTRSCRATCHENTRY_GLOBAL) |
| 30 |
NEWCHILDSCRATCHENTRY_GLOBAL = "uid=newChild,{}".format(NESTEDGROUP_OU_GLOBAL) |
| 31 |
BIG_GLOBAL = "cn=BIG_GLOBAL Group,{}".format(DEFAULT_SUFFIX) |
| 32 |
ALLGROUPS_GLOBAL = "cn=ALLGROUPS_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL) |
| 33 |
GROUPA_GLOBAL = "cn=GROUPA_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL) |
| 34 |
GROUPB_GLOBAL = "cn=GROUPB_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL) |
| 35 |
GROUPC_GLOBAL = "cn=GROUPC_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL) |
| 36 |
GROUPD_GLOBAL = "cn=GROUPD_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL) |
| 37 |
GROUPE_GLOBAL = "cn=GROUPE_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL) |
| 38 |
GROUPF_GLOBAL = "cn=GROUPF_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL) |
| 39 |
GROUPG_GLOBAL = "cn=GROUPG_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL) |
| 40 |
GROUPH_GLOBAL = "cn=GROUPH_GLOBAL,{}".format(NESTEDGROUP_OU_GLOBAL) |
| 41 |
CONTAINER_1_DELADD = "ou=Product Development,{}".format(DEFAULT_SUFFIX) |
| 42 |
CONTAINER_2_DELADD = "ou=Accounting,{}".format(DEFAULT_SUFFIX) |
| 43 |
|
| 44 |
|
| 45 |
@pytest.fixture(scope="function") |
| 46 |
def aci_of_user(request, topo): |
| 47 |
aci_list = Domain(topo.standalone, DEFAULT_SUFFIX).get_attr_vals('aci') |
| 48 |
|
| 49 |
def finofaci(): |
| 50 |
domain = Domain(topo.standalone, DEFAULT_SUFFIX) |
| 51 |
domain.set('aci', None) |
| 52 |
for i in aci_list: |
| 53 |
domain.add("aci", i) |
| 54 |
|
| 55 |
request.addfinalizer(finofaci) |
| 56 |
|
| 57 |
|
| 58 |
@pytest.fixture(scope="module") |
| 59 |
def add_test_user(request, topo): |
| 60 |
for demo in ['Product Development', 'Accounting', 'Product Testing', 'nestedgroup', 'ACLGroup']: |
| 61 |
OrganizationalUnit(topo.standalone, "ou={},{}".format(demo, DEFAULT_SUFFIX)).create(properties={'ou': demo}) |
| 62 |
|
| 63 |
user = UserAccounts(topo.standalone, DEFAULT_SUFFIX, rdn='ou=Accounting') |
| 64 |
for demo1 in ['Ted Morris', 'David Miller']: |
| 65 |
user.create(properties= { |
| 66 |
'uid': demo1, |
| 67 |
'cn': demo1, |
| 68 |
'sn': 'user', |
| 69 |
'uidNumber': '1000', |
| 70 |
'gidNumber': '2000', |
| 71 |
'homeDirectory': '/home/' + demo1, |
| 72 |
'userPassword': PW_DM |
| 73 |
}) |
| 74 |
|
| 75 |
# Add anonymous access aci |
| 76 |
ACI_TARGET = "(targetattr=\"*\")(target = \"ldap:///%s\")" % (DEFAULT_SUFFIX) |
| 77 |
ACI_ALLOW = "(version 3.0; acl \"Anonymous Read access\"; allow (read,search,compare)" |
| 78 |
ACI_SUBJECT = "(userdn=\"ldap:///anyone\");)" |
| 79 |
ANON_ACI = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT |
| 80 |
suffix = Domain(topo.standalone, DEFAULT_SUFFIX) |
| 81 |
suffix.add('aci', ANON_ACI) |
| 82 |
|
| 83 |
uas = UserAccounts(topo.standalone, DEFAULT_SUFFIX, 'ou=nestedgroup') |
| 84 |
for demo1 in ['DEEPUSER_GLOBAL', 'scratchEntry', 'DEEPUSER2_GLOBAL', 'DEEPUSER1_GLOBAL', |
| 85 |
'DEEPUSER3_GLOBAL', 'GROUPDNATTRSCRATCHENTRY_GLOBAL', 'newChild']: |
| 86 |
uas.create(properties={ |
| 87 |
'uid': demo1, |
| 88 |
'cn': demo1, |
| 89 |
'sn': 'user', |
| 90 |
'uidNumber': '1000', |
| 91 |
'gidNumber': '2000', |
| 92 |
'homeDirectory': '/home/' + demo1, |
| 93 |
'userPassword': PW_DM |
| 94 |
}) |
| 95 |
|
| 96 |
uas = UserAccounts(topo.standalone, DEFAULT_SUFFIX, 'uid=GROUPDNATTRSCRATCHENTRY_GLOBAL,ou=nestedgroup') |
| 97 |
for demo1 in ['c1', 'CHILD1_GLOBAL']: |
| 98 |
uas.create(properties={ |
| 99 |
'uid': demo1, |
| 100 |
'cn': demo1, |
| 101 |
'sn': 'user', |
| 102 |
'uidNumber': '1000', |
| 103 |
'gidNumber': '2000', |
| 104 |
'homeDirectory': '/home/' + demo1, |
| 105 |
'userPassword': PW_DM |
| 106 |
}) |
| 107 |
|
| 108 |
grp = UniqueGroups(topo.standalone, DEFAULT_SUFFIX, rdn='ou=nestedgroup') |
| 109 |
for i in [('ALLGROUPS_GLOBAL', GROUPA_GLOBAL), ('GROUPA_GLOBAL', GROUPB_GLOBAL), ('GROUPB_GLOBAL', GROUPC_GLOBAL), |
| 110 |
('GROUPC_GLOBAL', GROUPD_GLOBAL), ('GROUPD_GLOBAL', GROUPE_GLOBAL), ('GROUPE_GLOBAL', GROUPF_GLOBAL), |
| 111 |
('GROUPF_GLOBAL', GROUPG_GLOBAL), ('GROUPG_GLOBAL', GROUPH_GLOBAL), ('GROUPH_GLOBAL', DEEPUSER_GLOBAL)]: |
| 112 |
grp.create(properties={'cn': i[0], |
| 113 |
'ou': 'groups', |
| 114 |
'uniquemember': i[1] |
| 115 |
}) |
| 116 |
|
| 117 |
grp = UniqueGroup(topo.standalone, 'cn=BIG_GLOBAL Group,{}'.format(DEFAULT_SUFFIX)) |
| 118 |
grp.create(properties={'cn': 'BIG_GLOBAL Group', |
| 119 |
'ou': 'groups', |
| 120 |
'uniquemember': ["uid=Ted Morris,ou=Accounting,{}".format(DEFAULT_SUFFIX), |
| 121 |
"uid=David Miller,ou=Accounting,{}".format(DEFAULT_SUFFIX),] |
| 122 |
}) |
| 123 |
|
| 124 |
|
| 125 |
def test_caching_changes(topo, aci_of_user, add_test_user): |
| 126 |
""" |
| 127 |
Add user and then test deny |
| 128 |
|
| 129 |
:id: 26ed2dc2-783f-11e8-b1a5-8c16451d917b |
| 130 |
:setup: server |
| 131 |
:steps: |
| 132 |
1. Add test entry |
| 133 |
2. Take a count of users using DN_DM |
| 134 |
3. Add test user |
| 135 |
4. add aci |
| 136 |
5. test should fullfil the aci rules |
| 137 |
:expectedresults: |
| 138 |
1. Entry should be added |
| 139 |
2. Operation should succeed |
| 140 |
3. Operation should succeed |
| 141 |
4. Operation should succeed |
| 142 |
5. Operation should succeed |
| 143 |
""" |
| 144 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr="roomnumber")(version 3.0; acl "ACLGroup"; deny ( read, search ) userdn = "ldap:///all" ;)') |
| 145 |
user = UserAccounts(topo.standalone, DEFAULT_SUFFIX, "ou=AclGroup").create_test_user() |
| 146 |
user.set('roomnumber', '3445') |
| 147 |
conn = UserAccount(topo.standalone, DEEPUSER_GLOBAL).bind(PW_DM) |
| 148 |
# targetattr="roomnumber" will be denied access |
| 149 |
user = UserAccount(conn, 'uid=test_user_1000,ou=ACLGroup,dc=example,dc=com') |
| 150 |
with pytest.raises(AssertionError): |
| 151 |
assert user.get_attr_val_utf8('roomNumber') |
| 152 |
UserAccount(topo.standalone, 'uid=test_user_1000,ou=ACLGroup,dc=example,dc=com').delete() |
| 153 |
|
| 154 |
|
| 155 |
def test_deny_group_member_all_rights_to_user(topo, aci_of_user, add_test_user): |
| 156 |
""" |
| 157 |
Try deleting user while no access |
| 158 |
|
| 159 |
:id: 0da68a4c-7840-11e8-98c2-8c16451d917b |
| 160 |
:setup: server |
| 161 |
:steps: |
| 162 |
1. Add test entry |
| 163 |
2. Take a count of users using DN_DM |
| 164 |
3. delete test user |
| 165 |
4. add aci |
| 166 |
5. test should fullfil the aci rules |
| 167 |
:expectedresults: |
| 168 |
1. Entry should be added |
| 169 |
2. Operation should succeed |
| 170 |
3. Operation should succeed |
| 171 |
4. Operation should succeed |
| 172 |
5. Operation should succeed |
| 173 |
""" |
| 174 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr="*")(version 3.0; acl "ACLGroup"; deny (all) groupdn = "ldap:///{}" ;)'.format(BIG_GLOBAL)) |
| 175 |
conn = UserAccount(topo.standalone, "uid=Ted Morris, ou=Accounting, {}".format(DEFAULT_SUFFIX)).bind(PW_DM) |
| 176 |
# group BIG_GLOBAL will have no access |
| 177 |
user = UserAccount(conn, DEEPUSER3_GLOBAL) |
| 178 |
with pytest.raises(ldap.INSUFFICIENT_ACCESS): |
| 179 |
user.delete() |
| 180 |
|
| 181 |
|
| 182 |
def test_deny_group_member_all_rights_to_group_members(topo, aci_of_user, add_test_user): |
| 183 |
""" |
| 184 |
Deny group member all rights |
| 185 |
|
| 186 |
:id: 2d4ff70c-7840-11e8-8472-8c16451d917b |
| 187 |
:setup: server |
| 188 |
:steps: |
| 189 |
1. Add test entry |
| 190 |
2. Take a count of users using DN_DM |
| 191 |
3. Add test user |
| 192 |
4. add aci |
| 193 |
5. test should fullfil the aci rules |
| 194 |
:expectedresults: |
| 195 |
1. Entry should be added |
| 196 |
2. Operation should succeed |
| 197 |
3. Operation should succeed |
| 198 |
4. Operation should succeed |
| 199 |
5. Operation should succeed |
| 200 |
""" |
| 201 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr="*")(version 3.0; acl "ACLGroup"; deny (all) groupdn = "ldap:///{}" ;)'.format(BIG_GLOBAL)) |
| 202 |
UserAccounts(topo.standalone, DEFAULT_SUFFIX, "ou=AclGroup").create_test_user() |
| 203 |
conn = UserAccount(topo.standalone, "uid=Ted Morris, ou=Accounting, {}".format(DEFAULT_SUFFIX)).bind(PW_DM) |
| 204 |
# group BIG_GLOBAL no access |
| 205 |
user = UserAccount(conn, 'uid=test_user_1000,ou=ACLGroup,dc=example,dc=com') |
| 206 |
assert len(user.get_attr_val_utf8('uid')) == 0 |
| 207 |
UserAccount(topo.standalone, 'uid=test_user_1000,ou=ACLGroup,dc=example,dc=com').delete() |
| 208 |
|
| 209 |
|
| 210 |
def test_deeply_nested_groups_aci_denial(topo, add_test_user, aci_of_user): |
| 211 |
""" |
| 212 |
Test deeply nested groups (1) |
| 213 |
This aci will not allow search or modify to a user too deep to be detected. |
| 214 |
|
| 215 |
:id: 3d98229c-7840-11e8-9f55-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; acl "ACLGroup"; allow (all) groupdn = "ldap:///{}" ;)'.format(ALLGROUPS_GLOBAL)) |
| 231 |
conn = UserAccount(topo.standalone, DEEPUSER_GLOBAL).bind(PW_DM) |
| 232 |
# ALLGROUPS_GLOBAL have all access |
| 233 |
assert UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL).get_attr_val_utf8('uid') == 'scratchEntry' |
| 234 |
user = UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL) |
| 235 |
with pytest.raises(ldap.INSUFFICIENT_ACCESS): |
| 236 |
user.delete() |
| 237 |
|
| 238 |
|
| 239 |
def test_deeply_nested_groups_aci_denial_two(topo, add_test_user, aci_of_user): |
| 240 |
""" |
| 241 |
Test deeply nested groups (2) |
| 242 |
This aci will allow search and modify |
| 243 |
|
| 244 |
:id: 4ef6348e-7840-11e8-a70c-8c16451d917b |
| 245 |
:setup: server |
| 246 |
:steps: |
| 247 |
1. Add test entry |
| 248 |
2. Take a count of users using DN_DM |
| 249 |
3. Add test user |
| 250 |
4. add aci |
| 251 |
5. test should fullfil the aci rules |
| 252 |
:expectedresults: |
| 253 |
1. Entry should be added |
| 254 |
2. Operation should succeed |
| 255 |
3. Operation should succeed |
| 256 |
4. Operation should succeed |
| 257 |
5. Operation should succeed |
| 258 |
""" |
| 259 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr="*")(version 3.0; acl "ACLGroup"; allow (all) groupdn = "ldap:///{}" ;)'.format(GROUPE_GLOBAL)) |
| 260 |
conn = UserAccount(topo.standalone, DEEPUSER_GLOBAL).bind(PW_DM) |
| 261 |
# GROUPE_GLOBAL have all access |
| 262 |
user = UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL) |
| 263 |
user.add("sn", "Fred") |
| 264 |
user.remove("sn", "Fred") |
| 265 |
|
| 266 |
|
| 267 |
def test_deeply_nested_groups_aci_allow(topo, add_test_user, aci_of_user): |
| 268 |
""" |
| 269 |
Test deeply nested groups (3) |
| 270 |
This aci will allow search and modify |
| 271 |
|
| 272 |
:id: 8d338210-7840-11e8-8584-8c16451d917b |
| 273 |
:setup: server |
| 274 |
:steps: |
| 275 |
1. Add test entry |
| 276 |
2. Take a count of users using DN_DM |
| 277 |
3. Add test user |
| 278 |
4. add aci |
| 279 |
5. test should fullfil the aci rules |
| 280 |
:expectedresults: |
| 281 |
1. Entry should be added |
| 282 |
2. Operation should succeed |
| 283 |
3. Operation should succeed |
| 284 |
4. Operation should succeed |
| 285 |
5. Operation should succeed |
| 286 |
""" |
| 287 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ['(targetattr="*")(version 3.0; acl "ACLGroup"; allow (all) groupdn = "ldap:///{}" ;)'.format(ALLGROUPS_GLOBAL), '(targetattr="*")(version 3.0; acl "ACLGroup"; allow (all) groupdn = "ldap:///{}" ;)'.format(GROUPE_GLOBAL)]) |
| 288 |
conn = UserAccount(topo.standalone, DEEPUSER_GLOBAL).bind(PW_DM) |
| 289 |
# test deeply nested groups |
| 290 |
user = UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL) |
| 291 |
user.add("sn", "Fred") |
| 292 |
user.remove("sn", "Fred") |
| 293 |
|
| 294 |
|
| 295 |
def test_deeply_nested_groups_aci_allow_two(topo, add_test_user, aci_of_user): |
| 296 |
""" |
| 297 |
This aci will not allow search or modify to a user too deep to be detected. |
| 298 |
|
| 299 |
:id: 8d3459c4-7840-11e8-8ed8-8c16451d917b |
| 300 |
:setup: server |
| 301 |
:steps: |
| 302 |
1. Add test entry |
| 303 |
2. Take a count of users using DN_DM |
| 304 |
3. Add test user |
| 305 |
4. add aci |
| 306 |
5. test should fullfil the aci rules |
| 307 |
:expectedresults: |
| 308 |
1. Entry should be added |
| 309 |
2. Operation should succeed |
| 310 |
3. Operation should succeed |
| 311 |
4. Operation should succeed |
| 312 |
5. Operation should succeed |
| 313 |
""" |
| 314 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr="*")(version 3.0; acl "ACLGroup"; allow (all) groupdn = "ldap:///{}" ;)'.format(ALLGROUPS_GLOBAL)) |
| 315 |
conn = UserAccount(topo.standalone, DEEPUSER_GLOBAL).bind(PW_DM) |
| 316 |
# This aci should not allow search or modify to a user too deep to be detected. |
| 317 |
user = UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL) |
| 318 |
with pytest.raises(ldap.INSUFFICIENT_ACCESS): |
| 319 |
user.add("sn", "Fred") |
| 320 |
assert user.get_attr_val_utf8('uid') == 'scratchEntry' |
| 321 |
|
| 322 |
|
| 323 |
def test_undefined_in_group_eval(topo, add_test_user, aci_of_user): |
| 324 |
""" |
| 325 |
|
| 326 |
This aci will not allow access . |
| 327 |
|
| 328 |
:id: f1605e16-7840-11e8-b954-8c16451d917b |
| 329 |
:setup: server |
| 330 |
:steps: |
| 331 |
1. Add test entry |
| 332 |
2. Take a count of users using DN_DM |
| 333 |
3. Add test user |
| 334 |
4. add aci |
| 335 |
5. test should fullfil the aci rules |
| 336 |
:expectedresults: |
| 337 |
1. Entry should be added |
| 338 |
2. Operation should succeed |
| 339 |
3. Operation should succeed |
| 340 |
4. Operation should succeed |
| 341 |
5. Operation should succeed |
| 342 |
""" |
| 343 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr="*")(version 3.0; acl "ACLGroup"; allow (all) groupdn != "ldap:///{}" ;)'.format(ALLGROUPS_GLOBAL)) |
| 344 |
conn = UserAccount(topo.standalone, DEEPUSER_GLOBAL).bind(PW_DM) |
| 345 |
# This aci should NOT allow access |
| 346 |
user = UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL) |
| 347 |
with pytest.raises(ldap.INSUFFICIENT_ACCESS): |
| 348 |
user.add("sn", "Fred") |
| 349 |
assert user.get_attr_val_utf8('uid') == 'scratchEntry' |
| 350 |
|
| 351 |
|
| 352 |
def test_undefined_in_group_eval_two(topo, add_test_user, aci_of_user): |
| 353 |
""" |
| 354 |
This aci will allow access |
| 355 |
|
| 356 |
:id: fcfbcce2-7840-11e8-ba77-8c16451d917b |
| 357 |
:setup: server |
| 358 |
:steps: |
| 359 |
1. Add test entry |
| 360 |
2. Take a count of users using DN_DM |
| 361 |
3. Add test user |
| 362 |
4. add aci |
| 363 |
5. test should fullfil the aci rules |
| 364 |
:expectedresults: |
| 365 |
1. Entry should be added |
| 366 |
2. Operation should succeed |
| 367 |
3. Operation should succeed |
| 368 |
4. Operation should succeed |
| 369 |
5. Operation should succeed |
| 370 |
""" |
| 371 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr="*")(version 3.0; aci "tester"; allow(all) groupdn = "ldap:///{}\ || ldap:///{}";)'.format(ALLGROUPS_GLOBAL, GROUPG_GLOBAL)) |
| 372 |
conn = UserAccount(topo.standalone, DEEPUSER_GLOBAL).bind(PW_DM) |
| 373 |
user = UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL) |
| 374 |
# This aci should allow access |
| 375 |
user.add("sn", "Fred") |
| 376 |
assert UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL).get_attr_val_utf8('uid') == 'scratchEntry' |
| 377 |
user.remove("sn", "Fred") |
| 378 |
|
| 379 |
|
| 380 |
def test_undefined_in_group_eval_three(topo, add_test_user, aci_of_user): |
| 381 |
""" |
| 382 |
This aci will allow access |
| 383 |
|
| 384 |
:id: 04943dcc-7841-11e8-8c46-8c16451d917b |
| 385 |
:setup: server |
| 386 |
:steps: |
| 387 |
1. Add test entry |
| 388 |
2. Take a count of users using DN_DM |
| 389 |
3. Add test user |
| 390 |
4. add aci |
| 391 |
5. test should fullfil the aci rules |
| 392 |
:expectedresults: |
| 393 |
1. Entry should be added |
| 394 |
2. Operation should succeed |
| 395 |
3. Operation should succeed |
| 396 |
4. Operation should succeed |
| 397 |
5. Operation should succeed |
| 398 |
""" |
| 399 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr="*")(version 3.0; aci "tester"; allow(all) groupdn = "ldap:///{}\ || ldap:///{}";)'.format(GROUPG_GLOBAL, ALLGROUPS_GLOBAL)) |
| 400 |
conn = UserAccount(topo.standalone, DEEPUSER_GLOBAL).bind(PW_DM) |
| 401 |
user = Domain(conn, DEEPGROUPSCRATCHENTRY_GLOBAL) |
| 402 |
# test UNDEFINED in group |
| 403 |
user.add("sn", "Fred") |
| 404 |
assert UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL).get_attr_val_utf8('uid') == 'scratchEntry' |
| 405 |
user.remove("sn", "Fred") |
| 406 |
|
| 407 |
|
| 408 |
def test_undefined_in_group_eval_four(topo, add_test_user, aci_of_user): |
| 409 |
""" |
| 410 |
This aci will not allow access |
| 411 |
|
| 412 |
:id: 0b03d10e-7841-11e8-9341-8c16451d917b |
| 413 |
:setup: server |
| 414 |
:steps: |
| 415 |
1. Add test entry |
| 416 |
2. Take a count of users using DN_DM |
| 417 |
3. Add test user |
| 418 |
4. add aci |
| 419 |
5. test should fullfil the aci rules |
| 420 |
:expectedresults: |
| 421 |
1. Entry should be added |
| 422 |
2. Operation should succeed |
| 423 |
3. Operation should succeed |
| 424 |
4. Operation should succeed |
| 425 |
5. Operation should succeed |
| 426 |
""" |
| 427 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci",'(targetattr="*")(version 3.0; aci "tester"; allow(all) groupdn != "ldap:///{}\ || ldap:///{}";)'.format(ALLGROUPS_GLOBAL, GROUPG_GLOBAL)) |
| 428 |
conn = UserAccount(topo.standalone, DEEPUSER1_GLOBAL).bind(PW_DM) |
| 429 |
# test UNDEFINED in group |
| 430 |
user = UserAccount(conn, DEEPGROUPSCRATCHENTRY_GLOBAL) |
| 431 |
with pytest.raises(ldap.INSUFFICIENT_ACCESS): |
| 432 |
user.add("sn", "Fred") |
| 433 |
assert user.get_attr_val_utf8('uid') == 'scratchEntry' |
| 434 |
|
| 435 |
|
| 436 |
if __name__ == "__main__": |
| 437 |
CURRENT_FILE = os.path.realpath(__file__) |
| 438 |
pytest.main("-s -v %s" % CURRENT_FILE) |