File: ticket49471_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 (81 lines) | stat: -rw-r--r-- 2,445 bytes parent folder | download
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
import logging
import pytest
import os
import time
import ldap
from lib389._constants import *
from lib389.topologies import topology_st as topo
from lib389 import Entry

pytestmark = pytest.mark.tier2

DEBUGGING = os.getenv("DEBUGGING", default=False)
if DEBUGGING:
    logging.getLogger(__name__).setLevel(logging.DEBUG)
else:
    logging.getLogger(__name__).setLevel(logging.INFO)
log = logging.getLogger(__name__)


USER_CN='user_'
def _user_get_dn(no):
    cn = '%s%d' % (USER_CN, no)
    dn = 'cn=%s,ou=people,%s' % (cn, SUFFIX)
    return (cn, dn)

def add_user(server, no, desc='dummy', sleep=True):
    (cn, dn) = _user_get_dn(no)
    log.fatal('Adding user (%s): ' % dn)
    server.add_s(Entry((dn, {'objectclass': ['top', 'person', 'inetuser', 'userSecurityInformation'],
                             'cn': [cn],
                             'description': [desc],
                             'sn': [cn],
                             'description': ['add on that host']})))
    if sleep:
        time.sleep(2)

def test_ticket49471(topo):
    """Specify a test case purpose or name here

    :id: 457ab172-9455-4eb2-89a0-150e3de5993f
    :setup: Fill in set up configuration here
    :steps:
        1. Fill in test case steps here
        2. And indent them like this (RST format requirement)
    :expectedresults:
        1. Fill in the result that is expected
        2. For each test step
    """

    # If you need any test suite initialization,
    # please, write additional fixture for that (including finalizer).
    # Topology for suites are predefined in lib389/topologies.py.

    # If you need host, port or any other data about instance,
    # Please, use the instance object attributes for that (for example, topo.ms["supplier1"].serverid)

    S1 = topo.standalone
    add_user(S1, 1)

    Filter = "(description:2.16.840.1.113730.3.3.2.1.1.6:=\*on\*)"
    ents = S1.search_s(SUFFIX, ldap.SCOPE_SUBTREE, Filter)
    assert len(ents) == 1

    #
    # The following is for the test 49491
    # skipped here else it crashes in ASAN
    #Filter = "(description:2.16.840.1.113730.3.3.2.1.1.6:=\*host)"
    #ents = S1.search_s(SUFFIX, ldap.SCOPE_SUBTREE, Filter)
    #assert len(ents) == 1

    if DEBUGGING:
        # Add debugging steps(if any)...
        pass


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