| 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 logging |
| 12 |
from test389.topologies import topology_m2 as topo_m2 |
| 13 |
from lib389.idm.user import nsUserAccounts |
| 14 |
from lib389.paths import Paths |
| 15 |
from lib389.utils import ds_is_older |
| 16 |
from lib389._constants import * |
| 17 |
from lib389.replica import ReplicationManager |
| 18 |
from lib389.plugins import EntryUUIDPlugin |
| 19 |
from lib389.tasks import EntryUUIDFixupTask |
| 20 |
|
| 21 |
default_paths = Paths() |
| 22 |
|
| 23 |
pytestmark = pytest.mark.tier1 |
| 24 |
|
| 25 |
@pytest.mark.skipif(not default_paths.rust_enabled or ds_is_older('1.4.2.0'), reason="Entryuuid is not available in older versions") |
| 26 |
|
| 27 |
def test_entryuuid_with_replication(topo_m2): |
| 28 |
""" Check that entryuuid works with replication |
| 29 |
|
| 30 |
:id: a5f15bf9-7f63-473a-840c-b9037b787024 |
| 31 |
|
| 32 |
:setup: two node mmr |
| 33 |
|
| 34 |
:steps: |
| 35 |
1. Create an entry on one server |
| 36 |
2. Wait for replication |
| 37 |
3. Assert it is on the second |
| 38 |
|
| 39 |
:expectedresults: |
| 40 |
1. Success |
| 41 |
1. Success |
| 42 |
1. Success |
| 43 |
""" |
| 44 |
|
| 45 |
server_a = topo_m2.ms["supplier1"] |
| 46 |
server_b = topo_m2.ms["supplier2"] |
| 47 |
server_a.config.loglevel(vals=(ErrorLog.DEFAULT,ErrorLog.TRACE)) |
| 48 |
server_b.config.loglevel(vals=(ErrorLog.DEFAULT,ErrorLog.TRACE)) |
| 49 |
|
| 50 |
repl = ReplicationManager(DEFAULT_SUFFIX) |
| 51 |
|
| 52 |
account_a = nsUserAccounts(server_a, DEFAULT_SUFFIX).create_test_user(uid=2000) |
| 53 |
euuid_a = account_a.get_attr_vals_utf8('entryUUID') |
| 54 |
print("🧩 %s" % euuid_a) |
| 55 |
assert(euuid_a is not None) |
| 56 |
assert(len(euuid_a) == 1) |
| 57 |
|
| 58 |
repl.wait_for_replication(server_a, server_b) |
| 59 |
|
| 60 |
account_b = nsUserAccounts(server_b, DEFAULT_SUFFIX).get("test_user_2000") |
| 61 |
euuid_b = account_b.get_attr_vals_utf8('entryUUID') |
| 62 |
print("🧩 %s" % euuid_b) |
| 63 |
|
| 64 |
server_a.config.loglevel(vals=(ErrorLog.DEFAULT,)) |
| 65 |
server_b.config.loglevel(vals=(ErrorLog.DEFAULT,)) |
| 66 |
|
| 67 |
assert(euuid_b is not None) |
| 68 |
assert(len(euuid_b) == 1) |
| 69 |
assert(euuid_b == euuid_a) |
| 70 |
|
| 71 |
account_b.set("description", "update") |
| 72 |
repl.wait_for_replication(server_b, server_a) |
| 73 |
|
| 74 |
euuid_c = account_a.get_attr_vals_utf8('entryUUID') |
| 75 |
print("🧩 %s" % euuid_c) |
| 76 |
assert(euuid_c is not None) |
| 77 |
assert(len(euuid_c) == 1) |
| 78 |
assert(euuid_c == euuid_a) |
| 79 |
|
| 80 |
@pytest.mark.skipif(not default_paths.rust_enabled or ds_is_older('1.4.2.0'), reason="Entryuuid is not available in older versions") |
| 81 |
def test_entryuuid_fixup_with_replication(topo_m2): |
| 82 |
""" Check that entryuuid fixup task works with replication |
| 83 |
|
| 84 |
:id: 4ff25022-2de8-11ed-b393-482ae39447e5 |
| 85 |
:setup: two node mmr |
| 86 |
|
| 87 |
:steps: |
| 88 |
1. Disable EntryUUID plugin. |
| 89 |
2. Create an user entry. |
| 90 |
3. Enable EntryUUID plugin. |
| 91 |
4. Check that the user entry does not have an entryuuid attribute |
| 92 |
5. Run fixup task |
| 93 |
6. Wait for task completion |
| 94 |
7. Check that the user entry has an entryuuid attribute |
| 95 |
8. Wait until changes get replicated |
| 96 |
9. Check that the user entry on the other supplier has same entryuuid attribute |
| 97 |
|
| 98 |
:expectedresults: |
| 99 |
1. Success |
| 100 |
2. Success |
| 101 |
3. Success |
| 102 |
4. Success |
| 103 |
5. Success |
| 104 |
6. Success |
| 105 |
7. Success |
| 106 |
8. Success |
| 107 |
9. Success |
| 108 |
""" |
| 109 |
server_a = topo_m2.ms["supplier1"] |
| 110 |
server_b = topo_m2.ms["supplier2"] |
| 111 |
server_a.config.loglevel(vals=(ErrorLog.DEFAULT,ErrorLog.TRACE)) |
| 112 |
server_b.config.loglevel(vals=(ErrorLog.DEFAULT,ErrorLog.TRACE)) |
| 113 |
|
| 114 |
# 1. Disable EntryUUID plugin. |
| 115 |
plugin = EntryUUIDPlugin(server_a) |
| 116 |
plugin.disable() |
| 117 |
server_a.restart() |
| 118 |
|
| 119 |
# 2. Create an user entry. |
| 120 |
# uid must differ than the test test_entryuuid_with_replication one |
| 121 |
# to avoid conflict between the tests. |
| 122 |
account_a = nsUserAccounts(server_a, DEFAULT_SUFFIX).create_test_user(uid=3000) |
| 123 |
|
| 124 |
# 3. Enable EntryUUID plugin. |
| 125 |
plugin.enable() |
| 126 |
server_a.restart() |
| 127 |
|
| 128 |
# 4. Check that the user entry does not have an entryuuid attribute |
| 129 |
euuid_a = account_a.get_attr_vals_utf8('entryUUID') |
| 130 |
assert(not euuid_a) |
| 131 |
|
| 132 |
# 5. Run fixup task |
| 133 |
task = EntryUUIDFixupTask(server_a).create(properties={ |
| 134 |
'basedn': DEFAULT_SUFFIX, |
| 135 |
'filter': "objectClass=*" |
| 136 |
}) |
| 137 |
|
| 138 |
# 6. Wait for task completion |
| 139 |
task.wait() |
| 140 |
assert task.is_complete() |
| 141 |
|
| 142 |
# 7. Check that the user entry has an entryuuid attribute |
| 143 |
euuid_a = account_a.get_attr_vals_utf8('entryUUID') |
| 144 |
assert(euuid_a) |
| 145 |
|
| 146 |
# 8. Wait until changes get replicated |
| 147 |
repl = ReplicationManager(DEFAULT_SUFFIX) |
| 148 |
repl.wait_for_replication(server_a, server_b) |
| 149 |
|
| 150 |
# 9. Check that the user entry on the other supplier has same entryuuid attribute |
| 151 |
account_b = nsUserAccounts(server_b, DEFAULT_SUFFIX).get("test_user_3000") |
| 152 |
euuid_b = account_b.get_attr_vals_utf8('entryUUID') |
| 153 |
assert euuid_a == euuid_b |