| 1 |
# --- BEGIN COPYRIGHT BLOCK --- |
| 2 |
# Copyright (C) 2017 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 |
|
| 11 |
import os |
| 12 |
import logging |
| 13 |
import pytest |
| 14 |
import ldap |
| 15 |
|
| 16 |
from lib389.idm.user import UserAccounts |
| 17 |
from test389.topologies import topology_st as topology |
| 18 |
from lib389._constants import DEFAULT_SUFFIX |
| 19 |
|
| 20 |
pytestmark = pytest.mark.tier1 |
| 21 |
|
| 22 |
DEBUGGING = os.getenv('DEBUGGING', False) |
| 23 |
|
| 24 |
if DEBUGGING is not False: |
| 25 |
DEBUGGING = True |
| 26 |
|
| 27 |
if DEBUGGING: |
| 28 |
logging.getLogger(__name__).setLevel(logging.DEBUG) |
| 29 |
else: |
| 30 |
logging.getLogger(__name__).setLevel(logging.INFO) |
| 31 |
|
| 32 |
log = logging.getLogger(__name__) |
| 33 |
|
| 34 |
|
| 35 |
def test_account_locking(topology): |
| 36 |
"""Test the eduperson schema works |
| 37 |
|
| 38 |
:id: f2f15449-a822-4ec6-b4ea-bd6db6240a6c |
| 39 |
|
| 40 |
:setup: Standalone instance |
| 41 |
|
| 42 |
:steps: |
| 43 |
1. Add a common user |
| 44 |
2. Extend the user with eduPerson objectClass |
| 45 |
3. Add attributes in eduPerson |
| 46 |
|
| 47 |
:expectedresults: |
| 48 |
1. User should be added with its properties |
| 49 |
2. User should be extended with eduPerson as the objectClass |
| 50 |
3. eduPerson should be added |
| 51 |
""" |
| 52 |
|
| 53 |
if DEBUGGING: |
| 54 |
# Add debugging steps(if any)... |
| 55 |
pass |
| 56 |
|
| 57 |
users = UserAccounts(topology.standalone, DEFAULT_SUFFIX) |
| 58 |
|
| 59 |
user_properties = { |
| 60 |
'uid': 'testuser', |
| 61 |
'cn' : 'testuser', |
| 62 |
'sn' : 'user', |
| 63 |
'uidNumber' : '1000', |
| 64 |
'gidNumber' : '2000', |
| 65 |
'homeDirectory' : '/home/testuser', |
| 66 |
} |
| 67 |
testuser = users.create(properties=user_properties) |
| 68 |
|
| 69 |
# Extend the user with eduPerson |
| 70 |
testuser.add('objectClass', 'eduPerson') |
| 71 |
|
| 72 |
# now add eduPerson attrs |
| 73 |
testuser.add('eduPersonAffiliation', 'value') # From 2002 |
| 74 |
testuser.add('eduPersonNickName', 'value') # From 2002 |
| 75 |
testuser.add('eduPersonOrgDN', 'ou=People,%s' % DEFAULT_SUFFIX) # From 2002 |
| 76 |
testuser.add('eduPersonOrgUnitDN', 'ou=People,%s' % DEFAULT_SUFFIX) # From 2002 |
| 77 |
testuser.add('eduPersonPrimaryAffiliation', 'value') # From 2002 |
| 78 |
testuser.add('eduPersonPrincipalName', 'value') # From 2002 |
| 79 |
testuser.add('eduPersonEntitlement', 'value') # From 2002 |
| 80 |
testuser.add('eduPersonPrimaryOrgUnitDN', 'ou=People,%s' % DEFAULT_SUFFIX) # From 2002 |
| 81 |
testuser.add('eduPersonScopedAffiliation', 'value') # From 2003 |
| 82 |
testuser.add('eduPersonTargetedID', 'value') # From 2003 |
| 83 |
testuser.add('eduPersonAssurance', 'value') # From 2008 |
| 84 |
testuser.add('eduPersonPrincipalNamePrior', 'value') # From 2012 |
| 85 |
testuser.add('eduPersonUniqueId', 'value') # From 2013 |
| 86 |
testuser.add('eduPersonOrcid', 'value') # From 2016 |
| 87 |
|
| 88 |
log.info('Test PASSED') |
| 89 |
|
| 90 |
|