| 1 |
# Copyright (C) 2020 William Brown <[email protected]> |
| 2 |
# All rights reserved. |
| 3 |
# |
| 4 |
# License: GPL (version 3 or any later version). |
| 5 |
# See LICENSE for details. |
| 6 |
# --- END COPYRIGHT BLOCK --- |
| 7 |
|
| 8 |
import logging |
| 9 |
import ldap |
| 10 |
import time |
| 11 |
import pytest |
| 12 |
from test389.topologies import topology_st as topology |
| 13 |
from lib389.paths import Paths |
| 14 |
from lib389.utils import ds_is_older |
| 15 |
from lib389.plugins import RetroChangelogPlugin, ContentSyncPlugin |
| 16 |
from lib389._constants import ErrorLog, DEFAULT_SUFFIX |
| 17 |
from lib389.plugins import EntryUUIDPlugin |
| 18 |
|
| 19 |
from . import ISyncRepl, syncstate_assert |
| 20 |
|
| 21 |
default_paths = Paths() |
| 22 |
pytestmark = pytest.mark.tier1 |
| 23 |
|
| 24 |
log = logging.getLogger(__name__) |
| 25 |
|
| 26 |
@pytest.mark.skipif(ldap.__version__ < '3.3.1' or not default_paths.rust_enabled or ds_is_older('1.4.4.0'), |
| 27 |
reason="Sync repl does not support openldap compat in older versions, and without entryuuid") |
| 28 |
def test_syncrepl_openldap(topology): |
| 29 |
""" Test basic functionality of the openldap syncrepl |
| 30 |
compatability handler. |
| 31 |
|
| 32 |
:id: 03039178-2cc6-40bd-b32c-7d6de108828b |
| 33 |
|
| 34 |
:setup: Standalone instance |
| 35 |
|
| 36 |
:steps: |
| 37 |
1. Enable Retro Changelog |
| 38 |
2. Enable Syncrepl |
| 39 |
3. Run the syncstate test to check refresh, add, delete, mod. |
| 40 |
|
| 41 |
:expectedresults: |
| 42 |
1. Success |
| 43 |
1. Success |
| 44 |
1. Success |
| 45 |
""" |
| 46 |
st = topology.standalone |
| 47 |
# Ensure entryuuid is setup |
| 48 |
plug = EntryUUIDPlugin(st) |
| 49 |
task = plug.fixup(DEFAULT_SUFFIX) |
| 50 |
task.wait() |
| 51 |
st.config.loglevel(vals=(ErrorLog.DEFAULT,ErrorLog.PLUGIN)) |
| 52 |
assert(task.is_complete() and task.get_exit_code() == 0) |
| 53 |
|
| 54 |
# Enable RetroChangelog. |
| 55 |
rcl = RetroChangelogPlugin(st) |
| 56 |
rcl.enable() |
| 57 |
# Set the default targetid |
| 58 |
rcl.add('nsslapd-attribute', 'nsuniqueid:targetUniqueId') |
| 59 |
rcl.add('nsslapd-attribute', 'entryuuid:targetEntryUUID') |
| 60 |
# Enable sync repl |
| 61 |
csp = ContentSyncPlugin(st) |
| 62 |
csp.add('syncrepl-allow-openldap', 'on') |
| 63 |
csp.enable() |
| 64 |
# Restart DS |
| 65 |
st.restart() |
| 66 |
# Setup the syncer |
| 67 |
sync = ISyncRepl(st, openldap=True) |
| 68 |
# Run the checks |
| 69 |
syncstate_assert(st, sync) |
| 70 |
|