File: ticket47921_test.py

package info (click to toggle)
389-ds-base 2.3.1%2Bdfsg1-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 37,536 kB
  • sloc: ansic: 306,972; python: 96,937; cpp: 10,257; perl: 2,854; makefile: 2,046; sh: 925; yacc: 806; xml: 379; lex: 366; javascript: 148; java: 50
file content (88 lines) | stat: -rw-r--r-- 3,284 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# --- BEGIN COPYRIGHT BLOCK ---
# Copyright (C) 2016 Red Hat, Inc.
# All rights reserved.
#
# License: GPL (version 3 or any later version).
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
#
import pytest
from lib389.tasks import *
from lib389.utils import *
from lib389.topologies import topology_st

pytestmark = pytest.mark.tier2

logging.getLogger(__name__).setLevel(logging.DEBUG)
log = logging.getLogger(__name__)


def test_ticket47921(topology_st):
    '''
    Test that indirect cos reflects the current value of the indirect entry
    '''

    INDIRECT_COS_DN = 'cn=cos definition,' + DEFAULT_SUFFIX
    MANAGER_DN = 'uid=my manager,ou=people,' + DEFAULT_SUFFIX
    USER_DN = 'uid=user,ou=people,' + DEFAULT_SUFFIX

    # Add COS definition
    topology_st.standalone.add_s(Entry((INDIRECT_COS_DN,
                                        {
                                            'objectclass': 'top cosSuperDefinition cosIndirectDefinition ldapSubEntry'.split(),
                                            'cosIndirectSpecifier': 'manager',
                                            'cosAttribute': 'roomnumber'
                                            })))

    # Add manager entry
    topology_st.standalone.add_s(Entry((MANAGER_DN,
                                        {'objectclass': 'top extensibleObject'.split(),
                                         'uid': 'my manager',
                                         'roomnumber': '1'
                                         })))

    # Add user entry
    topology_st.standalone.add_s(Entry((USER_DN,
                                        {'objectclass': 'top person organizationalPerson inetorgperson'.split(),
                                         'sn': 'last',
                                         'cn': 'full',
                                         'givenname': 'mark',
                                         'uid': 'user',
                                         'manager': MANAGER_DN
                                         })))

    # Test COS is working
    entry = topology_st.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE,
                                            "uid=user",
                                            ['roomnumber'])
    if entry:
        if ensure_str(entry[0].getValue('roomnumber')) != '1':
            log.fatal('COS is not working.')
            assert False
    else:
        log.fatal('Failed to find user entry')
        assert False

    # Modify manager entry
    topology_st.standalone.modify_s(MANAGER_DN, [(ldap.MOD_REPLACE, 'roomnumber', b'2')])

    # Confirm COS is returning the new value
    entry = topology_st.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE,
                                            "uid=user",
                                            ['roomnumber'])
    if entry:
        if ensure_str(entry[0].getValue('roomnumber')) != '2':
            log.fatal('COS is not working after manager update.')
            assert False
    else:
        log.fatal('Failed to find user entry')
        assert False

    log.info('Test complete')


if __name__ == '__main__':
    # Run isolated
    # -s for DEBUG mode
    CURRENT_FILE = os.path.realpath(__file__)
    pytest.main("-s %s" % CURRENT_FILE)