| 1 |
# --- BEGIN COPYRIGHT BLOCK --- |
| 2 |
# Copyright (C) 2020 William Brown <[email protected]> |
| 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 ldap |
| 10 |
import pytest |
| 11 |
import time |
| 12 |
import shutil |
| 13 |
from lib389.idm.account import Accounts, Account |
| 14 |
from test389.topologies import topology_i2 as topology |
| 15 |
from lib389.backend import Backends |
| 16 |
from lib389._constants import DEFAULT_SUFFIX |
| 17 |
from lib389.plugins import ChainingBackendPlugin |
| 18 |
from lib389.chaining import ChainingLinks |
| 19 |
from lib389.mappingTree import MappingTrees |
| 20 |
|
| 21 |
pytestmark = pytest.mark.tier1 |
| 22 |
|
| 23 |
def test_chaining_paged_search(topology): |
| 24 |
""" Test paged search through the chaining db. This |
| 25 |
would cause a SIGSEGV with paged search which could |
| 26 |
be triggered by SSSD. |
| 27 |
|
| 28 |
:id: 7b29b1f5-26cf-49fa-9fe7-ee29a1408633 |
| 29 |
:setup: Two standalones in chaining. |
| 30 |
:steps: |
| 31 |
1. Configure chaining between the nodes |
| 32 |
2. Do a chaining search (no page) to assert it works |
| 33 |
3. Do a paged search through chaining. |
| 34 |
|
| 35 |
:expectedresults: |
| 36 |
1. Success |
| 37 |
2. Success |
| 38 |
3. Success |
| 39 |
""" |
| 40 |
st1 = topology.ins["standalone1"] |
| 41 |
st2 = topology.ins["standalone2"] |
| 42 |
|
| 43 |
### We setup so that st1 -> st2 |
| 44 |
|
| 45 |
# Clear all the BE in st1 |
| 46 |
bes1 = Backends(st1) |
| 47 |
for be in bes1.list(): |
| 48 |
be.delete() |
| 49 |
|
| 50 |
# Setup st1 to chain to st2 |
| 51 |
chain_plugin_1 = ChainingBackendPlugin(st1) |
| 52 |
chain_plugin_1.enable() |
| 53 |
|
| 54 |
chains = ChainingLinks(st1) |
| 55 |
chain = chains.create(properties={ |
| 56 |
'cn': 'demochain', |
| 57 |
'nsslapd-suffix': DEFAULT_SUFFIX, |
| 58 |
'nsmultiplexorbinddn': '', |
| 59 |
'nsmultiplexorcredentials': '', |
| 60 |
'nsfarmserverurl': st2.toLDAPURL(), |
| 61 |
}) |
| 62 |
|
| 63 |
mts = MappingTrees(st1) |
| 64 |
# Due to a bug in lib389, we need to delete and recreate the mt. |
| 65 |
for mt in mts.list(): |
| 66 |
mt.delete() |
| 67 |
mts.ensure_state(properties={ |
| 68 |
'cn': DEFAULT_SUFFIX, |
| 69 |
'nsslapd-state': 'backend', |
| 70 |
'nsslapd-backend': 'demochain', |
| 71 |
}) |
| 72 |
# Restart to enable |
| 73 |
st1.restart() |
| 74 |
|
| 75 |
# Get an anonymous connection. |
| 76 |
anon = Account(st1, dn='') |
| 77 |
anon_conn = anon.bind(password='') |
| 78 |
|
| 79 |
# Now do a search from st1 -> st2 |
| 80 |
accs_1 = Accounts(anon_conn, DEFAULT_SUFFIX) |
| 81 |
assert len(accs_1.list()) > 0 |
| 82 |
|
| 83 |
# Allow time to attach lldb if needed. |
| 84 |
# import time |
| 85 |
# print("🔥🔥🔥") |
| 86 |
# time.sleep(45) |
| 87 |
|
| 88 |
# Now do a *paged* search from st1 -> st2 |
| 89 |
assert len(accs_1.list(paged_search=2, paged_critical=False)) > 0 |
| 90 |
|
| 91 |
|