| 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 logging |
| 11 |
import pytest |
| 12 |
import os |
| 13 |
import ldap |
| 14 |
from lib389.dbgen import dbgen_users |
| 15 |
from lib389._constants import * |
| 16 |
from test389.topologies import topology_st as topo |
| 17 |
from lib389._controls import SSSRequestControl |
| 18 |
|
| 19 |
pytestmark = pytest.mark.tier1 |
| 20 |
|
| 21 |
DEBUGGING = os.getenv("DEBUGGING", default=False) |
| 22 |
if DEBUGGING: |
| 23 |
logging.getLogger(__name__).setLevel(logging.DEBUG) |
| 24 |
else: |
| 25 |
logging.getLogger(__name__).setLevel(logging.INFO) |
| 26 |
log = logging.getLogger(__name__) |
| 27 |
|
| 28 |
|
| 29 |
def test_sss_mr(topo): |
| 30 |
"""Test matching rule/server side sort does not crash DS |
| 31 |
|
| 32 |
:id: 48c73d76-1694-420f-ab55-187135f2d260 |
| 33 |
:setup: Standalone Instance |
| 34 |
:steps: |
| 35 |
1. Add sample entries to the database |
| 36 |
2. Perform search using server side control (uid:2.5.13.3) |
| 37 |
:expectedresults: |
| 38 |
1. Success |
| 39 |
2. Success |
| 40 |
""" |
| 41 |
|
| 42 |
log.info("Creating LDIF...") |
| 43 |
ldif_dir = topo.standalone.get_ldif_dir() |
| 44 |
ldif_file = os.path.join(ldif_dir, 'mr-crash.ldif') |
| 45 |
dbgen_users(topo.standalone, 5, ldif_file, DEFAULT_SUFFIX) |
| 46 |
|
| 47 |
log.info("Importing LDIF...") |
| 48 |
topo.standalone.stop() |
| 49 |
assert topo.standalone.ldif2db(DEFAULT_BENAME, None, None, None, ldif_file) |
| 50 |
topo.standalone.start() |
| 51 |
|
| 52 |
log.info('Search using server side sorting using undefined mr in the attr...') |
| 53 |
sort_ctrl = SSSRequestControl(True, ['uid:2.5.13.3']) |
| 54 |
controls = [sort_ctrl] |
| 55 |
msg_id = topo.standalone.search_ext(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, |
| 56 |
"objectclass=*", serverctrls=controls) |
| 57 |
try: |
| 58 |
rtype, rdata, rmsgid, response_ctrl = topo.standalone.result3(msg_id) |
| 59 |
except ldap.OPERATIONS_ERROR: |
| 60 |
pass |
| 61 |
|
| 62 |
log.info("Test PASSED") |
| 63 |
|
| 64 |
|
| 65 |
if __name__ == '__main__': |
| 66 |
# Run isolated |
| 67 |
# -s for DEBUG mode |
| 68 |
CURRENT_FILE = os.path.realpath(__file__) |
| 69 |
pytest.main(["-s", CURRENT_FILE]) |
| 70 |
|