| 1 |
# --- BEGIN COPYRIGHT BLOCK --- |
| 2 |
# Copyright (C) 2022 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 |
import logging |
| 10 |
import pytest |
| 11 |
import os |
| 12 |
import time |
| 13 |
from lib389._constants import DEFAULT_SUFFIX, DN_CHANGELOG, DN_USERROOT_LDBM |
| 14 |
from test389.topologies import topology_m1c1 as topo |
| 15 |
from lib389.dseldif import DSEldif |
| 16 |
from lib389.utils import ds_supports_new_changelog |
| 17 |
from lib389.replica import Replicas |
| 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_cl_encryption_setup_process(topo): |
| 30 |
"""Take an already working replication deployment, and setup changelog |
| 31 |
encryption |
| 32 |
|
| 33 |
:id: 1a1b7d29-69f5-4f0e-91c4-e7f66140ff17 |
| 34 |
:setup: Supplier Instance, Consumer Instance |
| 35 |
:steps: |
| 36 |
1. Enable TLS for the server |
| 37 |
2. Export changelog |
| 38 |
3. Enable changelog encryption |
| 39 |
4. Import changelog |
| 40 |
5. Verify replication is still working |
| 41 |
:expectedresults: |
| 42 |
1. Success |
| 43 |
2. Success |
| 44 |
3. Success |
| 45 |
4. Success |
| 46 |
5. Success |
| 47 |
""" |
| 48 |
|
| 49 |
supplier = topo.ms['supplier1'] |
| 50 |
consumer = topo.cs['consumer1'] |
| 51 |
|
| 52 |
# Enable TLS |
| 53 |
log.info('Enable TLS ...') |
| 54 |
supplier.enable_tls() |
| 55 |
consumer.enable_tls() |
| 56 |
|
| 57 |
# Export changelog |
| 58 |
log.info('Export changelog ...') |
| 59 |
replicas = Replicas(supplier) |
| 60 |
replica = replicas.get(DEFAULT_SUFFIX) |
| 61 |
replica.begin_task_cl2ldif() |
| 62 |
replica.task_finished() |
| 63 |
|
| 64 |
# Enable changelog encryption |
| 65 |
log.info('Enable changelog encryption ...') |
| 66 |
dse_ldif = DSEldif(supplier) |
| 67 |
supplier.stop() |
| 68 |
if ds_supports_new_changelog(): |
| 69 |
changelog = 'cn=changelog,{}'.format(DN_USERROOT_LDBM) |
| 70 |
else: |
| 71 |
changelog = DN_CHANGELOG |
| 72 |
dse_ldif.replace(changelog, 'nsslapd-encryptionalgorithm', 'AES') |
| 73 |
if dse_ldif.get(changelog, 'nsSymmetricKey'): |
| 74 |
dse_ldif.delete(changelog, 'nsSymmetricKey') |
| 75 |
supplier.start() |
| 76 |
|
| 77 |
# Import changelog |
| 78 |
log.info('Import changelog ...') |
| 79 |
replica.begin_task_ldif2cl() |
| 80 |
replica.task_finished() |
| 81 |
|
| 82 |
# Verify replication is still working |
| 83 |
log.info('Test replication is still working ...') |
| 84 |
assert replica.test_replication([consumer]) |
| 85 |
|
| 86 |
if __name__ == '__main__': |
| 87 |
# Run isolated |
| 88 |
# -s for DEBUG mode |
| 89 |
CURRENT_FILE = os.path.realpath(__file__) |
| 90 |
pytest.main(["-s", CURRENT_FILE]) |
| 91 |
|