| 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 |
|
| 9 |
import pytest, os, ldap |
| 10 |
from lib389._constants import DEFAULT_SUFFIX, PW_DM |
| 11 |
from lib389.idm.user import UserAccount |
| 12 |
from lib389.idm.account import Anonymous |
| 13 |
from lib389.idm.organizationalunit import OrganizationalUnit |
| 14 |
from test389.topologies import topology_st as topo |
| 15 |
from lib389.idm.domain import Domain |
| 16 |
|
| 17 |
pytestmark = pytest.mark.tier1 |
| 18 |
|
| 19 |
CONTAINER_1_DELADD = "ou=Product Development,{}".format(DEFAULT_SUFFIX) |
| 20 |
CONTAINER_2_DELADD = "ou=Accounting,{}".format(DEFAULT_SUFFIX) |
| 21 |
USER_DELADD = "cn=Jeff Vedder,{}".format(CONTAINER_1_DELADD) |
| 22 |
USER_WITH_ACI_DELADD = "cn=Sam Carter,{}".format(CONTAINER_2_DELADD) |
| 23 |
FRED = "cn=FRED,ou=Accounting,{}".format(DEFAULT_SUFFIX) |
| 24 |
HARRY = "cn=HARRY,ou=Accounting,{}".format(DEFAULT_SUFFIX) |
| 25 |
KIRSTENVAUGHAN = "cn=Kirsten Vaughan,ou=Human Resources,{}".format(DEFAULT_SUFFIX) |
| 26 |
HUMAN_OU_GLOBAL = "ou=Human Resources,{}".format(DEFAULT_SUFFIX) |
| 27 |
|
| 28 |
|
| 29 |
@pytest.fixture(scope="function") |
| 30 |
def aci_of_user(request, topo): |
| 31 |
# Add anonymous access aci |
| 32 |
ACI_TARGET = "(targetattr != \"userpassword\")(target = \"ldap:///%s\")" % (DEFAULT_SUFFIX) |
| 33 |
ACI_ALLOW = "(version 3.0; acl \"Anonymous Read access\"; allow (read,search,compare)" |
| 34 |
ACI_SUBJECT = "(userdn=\"ldap:///anyone\");)" |
| 35 |
ANON_ACI = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT |
| 36 |
suffix = Domain(topo.standalone, DEFAULT_SUFFIX) |
| 37 |
try: |
| 38 |
suffix.add('aci', ANON_ACI) |
| 39 |
except ldap.TYPE_OR_VALUE_EXISTS: |
| 40 |
pass |
| 41 |
|
| 42 |
aci_list = Domain(topo.standalone, DEFAULT_SUFFIX).get_attr_vals('aci') |
| 43 |
|
| 44 |
def finofaci(): |
| 45 |
domain = Domain(topo.standalone, DEFAULT_SUFFIX) |
| 46 |
domain.set('aci', None) |
| 47 |
for i in aci_list: |
| 48 |
domain.add("aci", i) |
| 49 |
|
| 50 |
request.addfinalizer(finofaci) |
| 51 |
|
| 52 |
|
| 53 |
@pytest.fixture(scope="function") |
| 54 |
def _add_user(request, topo): |
| 55 |
for i in ["Product Development", 'Accounting', "Human Resources"]: |
| 56 |
ou = OrganizationalUnit(topo.standalone, "ou={},{}".format(i, DEFAULT_SUFFIX)) |
| 57 |
ou.create(properties={'ou': i}) |
| 58 |
|
| 59 |
properties = { |
| 60 |
'uid': 'Jeff Vedder', |
| 61 |
'cn': 'Jeff Vedder', |
| 62 |
'sn': 'user', |
| 63 |
'uidNumber': '1000', |
| 64 |
'gidNumber': '2000', |
| 65 |
'homeDirectory': '/home/' + 'JeffVedder', |
| 66 |
'userPassword': 'password' |
| 67 |
} |
| 68 |
user = UserAccount(topo.standalone, 'cn=Jeff Vedder,{}'.format(CONTAINER_1_DELADD)) |
| 69 |
user.create(properties=properties) |
| 70 |
user.set('secretary', 'cn=Arpitoo Borah, o=Red Hat, c=As') |
| 71 |
user.set('mail', '[email protected]') |
| 72 |
|
| 73 |
properties = { |
| 74 |
'uid': 'Sam Carter', |
| 75 |
'cn': 'Sam Carter', |
| 76 |
'sn': 'user', |
| 77 |
'uidNumber': '1000', |
| 78 |
'gidNumber': '2000', |
| 79 |
'homeDirectory': '/home/' + 'SamCarter', |
| 80 |
'userPassword': 'password' |
| 81 |
} |
| 82 |
user = UserAccount(topo.standalone, 'cn=Sam Carter,{}'.format(CONTAINER_2_DELADD)) |
| 83 |
user.create(properties=properties) |
| 84 |
|
| 85 |
properties = { |
| 86 |
'uid': 'Kirsten Vaughan', |
| 87 |
'cn': 'Kirsten Vaughan', |
| 88 |
'sn': 'Kirsten Vaughan', |
| 89 |
'uidNumber': '1000', |
| 90 |
'gidNumber': '2000', |
| 91 |
'homeDirectory': '/home/' + 'KirstenVaughan', |
| 92 |
'userPassword': 'password' |
| 93 |
} |
| 94 |
user = UserAccount(topo.standalone, 'cn=Kirsten Vaughan, ou=Human Resources,{}'.format(DEFAULT_SUFFIX)) |
| 95 |
user.create(properties=properties) |
| 96 |
|
| 97 |
properties = { |
| 98 |
'uid': 'HARRY', |
| 99 |
'cn': 'HARRY', |
| 100 |
'sn': 'HARRY', |
| 101 |
'uidNumber': '1000', |
| 102 |
'gidNumber': '2000', |
| 103 |
'homeDirectory': '/home/' + 'HARRY', |
| 104 |
'userPassword': 'password' |
| 105 |
} |
| 106 |
user = UserAccount(topo.standalone, 'cn=HARRY, ou=Accounting,{}'.format(DEFAULT_SUFFIX)) |
| 107 |
user.create(properties=properties) |
| 108 |
|
| 109 |
def fin(): |
| 110 |
for DN in [USER_DELADD, USER_WITH_ACI_DELADD, FRED, HARRY, KIRSTENVAUGHAN, |
| 111 |
HUMAN_OU_GLOBAL, CONTAINER_2_DELADD,CONTAINER_1_DELADD]: |
| 112 |
ua = UserAccount(topo.standalone, DN) |
| 113 |
try: |
| 114 |
ua.delete() |
| 115 |
except: |
| 116 |
pass |
| 117 |
|
| 118 |
request.addfinalizer(fin) |
| 119 |
|
| 120 |
|
| 121 |
def test_we_can_search_as_expected(topo, _add_user, aci_of_user, request): |
| 122 |
"""Testing the targattrfilters keyword that allows access control based on the value of the attributes being added (or deleted)) |
| 123 |
Test that we can search as expected |
| 124 |
|
| 125 |
:id: e845dbba-7aa9-11e8-8988-8c16451d917b |
| 126 |
:setup: server |
| 127 |
:steps: |
| 128 |
1. Add test entry |
| 129 |
2. Add ACI |
| 130 |
3. User should follow ACI role |
| 131 |
:expectedresults: |
| 132 |
1. Entry should be added |
| 133 |
2. Operation should succeed |
| 134 |
3. Operation should succeed |
| 135 |
""" |
| 136 |
ACI_BODY = '(target="ldap:///cn=*,ou=Product Development, {}")' \ |
| 137 |
'(targetfilter="cn=Jeff*")(targetattr="secretary || objectclass || mail")' \ |
| 138 |
'(targattrfilters = "add=title:(title=arch*)")(version 3.0; acl "{}"; ' \ |
| 139 |
'allow (write,read,search,compare) (userdn = "ldap:///anyone") ;)'.format(DEFAULT_SUFFIX, request.node.name) |
| 140 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ACI_BODY) |
| 141 |
conn = Anonymous(topo.standalone).bind() |
| 142 |
# aci will allow secretary , mail , objectclass |
| 143 |
user = UserAccount(conn, USER_DELADD) |
| 144 |
assert user.get_attr_vals('secretary') |
| 145 |
assert user.get_attr_vals('mail') |
| 146 |
assert user.get_attr_vals('objectclass') |
| 147 |
|
| 148 |
|
| 149 |
def test_we_can_mod_title_as_expected(topo, _add_user, aci_of_user, request): |
| 150 |
"""Testing the targattrfilters keyword that allows access control based on the |
| 151 |
value of the attributes being added (or deleted)) |
| 152 |
Test search will work with targattrfilters present. |
| 153 |
|
| 154 |
:id: f8c1ea88-7aa9-11e8-a55c-8c16451d917b |
| 155 |
:setup: server |
| 156 |
:steps: |
| 157 |
1. Add test entry |
| 158 |
2. Add ACI |
| 159 |
3. User should follow ACI role |
| 160 |
:expectedresults: |
| 161 |
1. Entry should be added |
| 162 |
2. Operation should succeed |
| 163 |
3. Operation should succeed |
| 164 |
""" |
| 165 |
ACI_BODY = '(target="ldap:///cn=*,ou=Product Development, {}")' \ |
| 166 |
'(targetfilter="cn=Jeff*")(targetattr="secretary || objectclass || mail")' \ |
| 167 |
'(targattrfilters = "add=title:(title=arch*)")(version 3.0; acl "{}"; ' \ |
| 168 |
'allow (write,read,search,compare) (userdn = "ldap:///anyone") ;)'.format(DEFAULT_SUFFIX, request.node.name) |
| 169 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ACI_BODY) |
| 170 |
# aci will not allow 'title', 'topdog' |
| 171 |
conn = UserAccount(topo.standalone, USER_WITH_ACI_DELADD).bind(PW_DM) |
| 172 |
user = UserAccount(conn, USER_DELADD) |
| 173 |
with pytest.raises(ldap.INSUFFICIENT_ACCESS): |
| 174 |
user.add('title', 'topdog') |
| 175 |
|
| 176 |
|
| 177 |
def test_modify_with_multiple_filters(topo, _add_user, aci_of_user, request): |
| 178 |
"""Testing the targattrfilters keyword that allows access control based on the |
| 179 |
value of the attributes being added (or deleted)) |
| 180 |
Allowed by multiple filters |
| 181 |
|
| 182 |
:id: fd9d223e-7aa9-11e8-a83b-8c16451d917b |
| 183 |
:setup: server |
| 184 |
:steps: |
| 185 |
1. Add test entry |
| 186 |
2. Add ACI |
| 187 |
3. User should follow ACI role |
| 188 |
:expectedresults: |
| 189 |
1. Entry should be added |
| 190 |
2. Operation should succeed |
| 191 |
3. Operation should succeed |
| 192 |
""" |
| 193 |
ACI_BODY = '(targattrfilters = "add=title:(title=architect) && secretary:' \ |
| 194 |
'(secretary=cn=Meylan,{}), del=title:(title=architect) && secretary:' \ |
| 195 |
'(secretary=cn=Meylan,{})")(version 3.0; acl "{}"; allow (write) ' \ |
| 196 |
'(userdn = "ldap:///anyone") ;)'.format( |
| 197 |
DEFAULT_SUFFIX, DEFAULT_SUFFIX, request.node.name |
| 198 |
) |
| 199 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ACI_BODY) |
| 200 |
conn = UserAccount(topo.standalone, USER_WITH_ACI_DELADD).bind(PW_DM) |
| 201 |
# aci will allow title some attribute only |
| 202 |
user = UserAccount(conn, USER_DELADD) |
| 203 |
user.add("title", "architect") |
| 204 |
assert user.get_attr_val('title') |
| 205 |
user.add("secretary", "cn=Meylan,dc=example,dc=com") |
| 206 |
assert user.get_attr_val('secretary') |
| 207 |
|
| 208 |
|
| 209 |
def test_denied_by_multiple_filters(topo, _add_user, aci_of_user, request): |
| 210 |
"""Testing the targattrfilters keyword that allows access control based on the value of the |
| 211 |
attributes being added (or deleted)) |
| 212 |
Denied by multiple filters |
| 213 |
|
| 214 |
:id: 034c6c62-7aaa-11e8-8634-8c16451d917b |
| 215 |
:setup: server |
| 216 |
:steps: |
| 217 |
1. Add test entry |
| 218 |
2. Add ACI |
| 219 |
3. User should follow ACI role |
| 220 |
:expectedresults: |
| 221 |
1. Entry should be added |
| 222 |
2. Operation should succeed |
| 223 |
3. Operation should succeed |
| 224 |
""" |
| 225 |
ACI_BODY = '(targattrfilters = "add=title:(title=architect) && secretary:' \ |
| 226 |
'(secretary=cn=Meylan,{}), del=title:(title=architect) && secretary:' \ |
| 227 |
'(secretary=cn=Meylan,{})")(version 3.0; acl "{}"; allow (write) ' \ |
| 228 |
'(userdn = "ldap:///anyone") ;)'.format(DEFAULT_SUFFIX, DEFAULT_SUFFIX, request.node.name) |
| 229 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ACI_BODY) |
| 230 |
conn = UserAccount(topo.standalone, USER_WITH_ACI_DELADD).bind(PW_DM) |
| 231 |
# aci will allow title some attribute only |
| 232 |
user = UserAccount(conn, USER_DELADD) |
| 233 |
user.add("title", "architect") |
| 234 |
assert user.get_attr_val('title') |
| 235 |
user.add("secretary", "cn=Meylan,dc=example,dc=com") |
| 236 |
assert user.get_attr_val('secretary') |
| 237 |
# aci will allow title some attribute only |
| 238 |
with pytest.raises(ldap.INSUFFICIENT_ACCESS): |
| 239 |
user.add("secretary", "cn=Grenoble,dc=example,dc=com") |
| 240 |
|
| 241 |
|
| 242 |
def test_allowed_add_one_attribute(topo, _add_user, aci_of_user, request): |
| 243 |
"""Testing the targattrfilters keyword that allows access control based on the value of the |
| 244 |
attributes being added (or deleted)) |
| 245 |
Allowed add one attribute (in presence of multiple filters) |
| 246 |
|
| 247 |
:id: 086c7f0c-7aaa-11e8-b69f-8c16451d917b |
| 248 |
:setup: server |
| 249 |
:steps: |
| 250 |
1. Add test entry |
| 251 |
2. Add ACI |
| 252 |
3. User should follow ACI role |
| 253 |
:expectedresults: |
| 254 |
1. Entry should be added |
| 255 |
2. Operation should succeed |
| 256 |
3. Operation should succeed |
| 257 |
""" |
| 258 |
ACI_BODY = '(targattrfilters = "add=title:(title=architect) && secretary:(secretary=cn=Meylan, {}), ' \ |
| 259 |
'del=title:(title=architect) && secretary:(secretary=cn=Meylan, {})")(version 3.0; acl "{}"; ' \ |
| 260 |
'allow (write) (userdn = "ldap:///{}") ;)'.format( |
| 261 |
DEFAULT_SUFFIX, DEFAULT_SUFFIX, request.node.name, USER_WITH_ACI_DELADD) |
| 262 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ACI_BODY) |
| 263 |
conn = UserAccount(topo.standalone, USER_WITH_ACI_DELADD).bind(PW_DM) |
| 264 |
user = UserAccount(conn, USER_DELADD) |
| 265 |
# aci will allow add ad delete |
| 266 |
user.add('title', 'architect') |
| 267 |
assert user.get_attr_val('title') |
| 268 |
user.remove('title', 'architect') |
| 269 |
|
| 270 |
|
| 271 |
def test_cannot_add_an_entry_with_attribute_values_we_are_not_allowed_add( |
| 272 |
topo, _add_user, aci_of_user, request |
| 273 |
): |
| 274 |
"""Testing the targattrfilters keyword that allows access control based on the value of the |
| 275 |
attributes being added (or deleted)) |
| 276 |
Test not allowed add an entry |
| 277 |
|
| 278 |
:id: 0d0effee-7aaa-11e8-b673-8c16451d917b |
| 279 |
:setup: server |
| 280 |
:steps: |
| 281 |
1. Add test entry |
| 282 |
2. Add ACI |
| 283 |
3. User should follow ACI role |
| 284 |
:expectedresults: |
| 285 |
1. Entry should be added |
| 286 |
2. Operation should succeed |
| 287 |
3. Operation should succeed |
| 288 |
""" |
| 289 |
ACI_BODY = '(targattrfilters = "add=title:(|(title=engineer)(title=cool dude)(title=scum)) ' \ |
| 290 |
'&& secretary:(secretary=cn=Meylan, {}), del=title:(|(title=engineer)(title=cool dude)' \ |
| 291 |
'(title=scum))")(version 3.0; aci "{}"; allow (add) userdn = "ldap:///{}";)'.format( |
| 292 |
DEFAULT_SUFFIX, request.node.name, DEFAULT_SUFFIX) |
| 293 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ACI_BODY) |
| 294 |
properties = { |
| 295 |
'uid': 'FRED', |
| 296 |
'cn': 'FRED', |
| 297 |
'sn': 'user', |
| 298 |
'uidNumber': '1000', |
| 299 |
'gidNumber': '2000', |
| 300 |
'homeDirectory': '/home/' + 'FRED' |
| 301 |
} |
| 302 |
user = UserAccount(topo.standalone, 'cn=FRED,ou=Accounting,{}'.format(DEFAULT_SUFFIX)) |
| 303 |
user.create(properties=properties) |
| 304 |
user.set('title', ['anuj', 'kumar', 'borah']) |
| 305 |
conn = UserAccount(topo.standalone, USER_WITH_ACI_DELADD).bind(PW_DM) |
| 306 |
# aci will not allow adding objectclass |
| 307 |
user = UserAccount(conn, USER_WITH_ACI_DELADD) |
| 308 |
with pytest.raises(ldap.INSUFFICIENT_ACCESS): |
| 309 |
user.add("objectclass", "person") |
| 310 |
|
| 311 |
|
| 312 |
def test_on_modrdn(topo, _add_user, aci_of_user, request): |
| 313 |
"""Testing the targattrfilters keyword that allows access control based on the value of the |
| 314 |
attributes being added (or deleted)) |
| 315 |
Test that valuacls kick in for modrdn operation. |
| 316 |
|
| 317 |
:id: 12985dde-7aaa-11e8-abde-8c16451d917b |
| 318 |
:setup: server |
| 319 |
:steps: |
| 320 |
1. Add test entry |
| 321 |
2. Add ACI |
| 322 |
3. User should follow ACI role |
| 323 |
:expectedresults: |
| 324 |
1. Entry should be added |
| 325 |
2. Operation should succeed |
| 326 |
3. Operation should succeed |
| 327 |
""" |
| 328 |
ACI_BODY = '(target="ldap:///cn=*,ou=Accounting,{}")(targattrfilters = "add=cn:(|(cn=engineer)), ' \ |
| 329 |
'del=title:(|(title=engineer)(title=cool dude)(title=scum))")(version 3.0; aci "{}"; ' \ |
| 330 |
'allow (write) userdn = "ldap:///{}";)'.format(DEFAULT_SUFFIX, request.node.name, USER_WITH_ACI_DELADD) |
| 331 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ACI_BODY) |
| 332 |
conn = UserAccount(topo.standalone, USER_WITH_ACI_DELADD).bind(PW_DM) |
| 333 |
# modrdn_s is not allowed with ou=OU1 |
| 334 |
useraccount = UserAccount(conn, FRED) |
| 335 |
with pytest.raises(ldap.INSUFFICIENT_ACCESS): |
| 336 |
useraccount.rename("ou=OU1") |
| 337 |
|
| 338 |
|
| 339 |
def test_on_modrdn_allow(topo, _add_user, aci_of_user, request): |
| 340 |
"""Testing the targattrfilters keyword that allows access control based on the value of the attributes being |
| 341 |
added (or deleted)) |
| 342 |
Test modrdn still works (2) |
| 343 |
|
| 344 |
:id: 17720562-7aaa-11e8-82ee-8c16451d917b |
| 345 |
:setup: server |
| 346 |
:steps: |
| 347 |
1. Add test entry |
| 348 |
2. Add ACI |
| 349 |
3. User should follow ACI role |
| 350 |
:expectedresults: |
| 351 |
1. Entry should be added |
| 352 |
2. Operation should succeed |
| 353 |
3. Operation should succeed |
| 354 |
""" |
| 355 |
ACI_BODY = '(target="ldap:///{}")(targattrfilters = "add=cn:((cn=engineer)), del=cn:((cn=jonny))")' \ |
| 356 |
'(version 3.0; aci "{}"; allow (write) ' \ |
| 357 |
'userdn = "ldap:///{}";)'.format(DEFAULT_SUFFIX, request.node.name, USER_WITH_ACI_DELADD) |
| 358 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", ACI_BODY) |
| 359 |
properties = { |
| 360 |
'uid': 'jonny', |
| 361 |
'cn': 'jonny', |
| 362 |
'sn': 'user', |
| 363 |
'uidNumber': '1000', |
| 364 |
'gidNumber': '2000', |
| 365 |
'homeDirectory': '/home/' + 'jonny' |
| 366 |
} |
| 367 |
user = UserAccount(topo.standalone, 'cn=jonny,{}'.format(DEFAULT_SUFFIX)) |
| 368 |
user.create(properties=properties) |
| 369 |
conn = UserAccount(topo.standalone, USER_WITH_ACI_DELADD).bind(PW_DM) |
| 370 |
# aci will allow modrdn_s on cn=engineer |
| 371 |
useraccount = UserAccount(conn, "cn=jonny,{}".format(DEFAULT_SUFFIX)) |
| 372 |
useraccount.rename("cn=engineer") |
| 373 |
assert useraccount.dn == 'cn=engineer,dc=example,dc=com' |
| 374 |
|
| 375 |
|
| 376 |
def test_targattrfilters_keyword(topo): |
| 377 |
"""Testing the targattrfilters keyword that allows access control based on the value |
| 378 |
of the attributes being added (or deleted)) |
| 379 |
"Bug #979515 - ACLs inoperative in some search scenarios [rhel-6.5]" |
| 380 |
"Bug #979516 is a clone for DS8.2 on RHEL5.9" |
| 381 |
"Bug #979514 is a clone for RHEL6.4 zStream errata" |
| 382 |
|
| 383 |
:id: 23f9e9d0-7aaa-11e8-b16b-8c16451d917b |
| 384 |
:setup: server |
| 385 |
:steps: |
| 386 |
1. Add test entry |
| 387 |
2. Add ACI |
| 388 |
3. User should follow ACI role |
| 389 |
:expectedresults: |
| 390 |
1. Entry should be added |
| 391 |
2. Operation should succeed |
| 392 |
3. Operation should succeed |
| 393 |
""" |
| 394 |
domain = Domain(topo.standalone, DEFAULT_SUFFIX) |
| 395 |
domain.set('aci', None) |
| 396 |
ou = OrganizationalUnit(topo.standalone, 'ou=bug979515,{}'.format(DEFAULT_SUFFIX)) |
| 397 |
ou.create(properties={'ou': 'bug979515'}) |
| 398 |
Domain(topo.standalone, DEFAULT_SUFFIX).add("aci", '(target="ldap:///ou=bug979515,{}") ' |
| 399 |
'(targetattr= "uid") ( version 3.0; acl "read other subscriber"; allow (compare, read, search) ' |
| 400 |
'userdn="ldap:///uid=*,ou=bug979515,{}" ; )'.format(DEFAULT_SUFFIX, DEFAULT_SUFFIX)) |
| 401 |
properties = { |
| 402 |
'uid': 'acientryusr1', |
| 403 |
'cn': 'acientryusr1', |
| 404 |
'sn': 'user', |
| 405 |
'uidNumber': '1000', |
| 406 |
'gidNumber': '2000', |
| 407 |
'homeDirectory': '/home/' + 'acientryusr1' |
| 408 |
} |
| 409 |
user = UserAccount(topo.standalone, 'cn=acientryusr1,ou=bug979515,{}'.format(DEFAULT_SUFFIX)) |
| 410 |
user.create(properties=properties) |
| 411 |
user.set('telephoneNumber', '99972566596') |
| 412 |
user.set('mail', '[email protected]') |
| 413 |
user.set("userPassword", "password") |
| 414 |
|
| 415 |
properties = { |
| 416 |
'uid': 'newaciphoneusr1', |
| 417 |
'cn': 'newaciphoneusr1', |
| 418 |
'sn': 'user', |
| 419 |
'uidNumber': '1000', |
| 420 |
'gidNumber': '2000', |
| 421 |
'homeDirectory': '/home/' + 'newaciphoneusr1' |
| 422 |
} |
| 423 |
user = UserAccount(topo.standalone, 'cn=newaciphoneusr1,ou=bug979515,{}'.format(DEFAULT_SUFFIX)) |
| 424 |
user.create(properties=properties) |
| 425 |
user.set('telephoneNumber', '99972566596') |
| 426 |
user.set('mail', '[email protected]') |
| 427 |
conn = UserAccount(topo.standalone, "cn=acientryusr1,ou=bug979515,{}".format(DEFAULT_SUFFIX)).bind(PW_DM) |
| 428 |
# Testing the targattrfilters keyword that allows access control based on the value of the attributes being added (or deleted)) |
| 429 |
user = UserAccount(conn, "cn=acientryusr1,ou=bug979515,{}".format(DEFAULT_SUFFIX)) |
| 430 |
assert len(user.get_attr_vals('mail')) == 0 |
| 431 |
assert len(user.get_attr_vals('telephoneNumber')) == 0 |
| 432 |
assert len(user.get_attr_vals('cn')) == 0 |
| 433 |
user = UserAccount(topo.standalone, "cn=acientryusr1,ou=bug979515,{}".format(DEFAULT_SUFFIX)) |
| 434 |
user.get_attr_vals('mail') |
| 435 |
user.get_attr_vals('telephoneNumber') |
| 436 |
user.get_attr_vals('cn') |
| 437 |
|
| 438 |
|
| 439 |
if __name__ == '__main__': |
| 440 |
CURRENT_FILE = os.path.realpath(__file__) |
| 441 |
pytest.main("-s -v %s" % CURRENT_FILE) |