| 1 |
# --- BEGIN COPYRIGHT BLOCK --- |
| 2 |
# Copyright (C) 2019 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 os |
| 10 |
import pytest |
| 11 |
from lib389._constants import DEFAULT_SUFFIX |
| 12 |
from lib389.replica import ReplicationManager |
| 13 |
from lib389.idm.user import UserAccounts, UserAccount |
| 14 |
from test389.topologies import topology_m2 |
| 15 |
|
| 16 |
pytestmark = pytest.mark.tier1 |
| 17 |
|
| 18 |
def test_user_compare_m2Repl(topology_m2): |
| 19 |
""" |
| 20 |
User compare test between users of supplier to supplier replicaton topology. |
| 21 |
|
| 22 |
:id: 7c243bea-4075-4304-864d-5b789d364871 |
| 23 |
|
| 24 |
:setup: 2 supplier MMR |
| 25 |
|
| 26 |
:steps: 1. Add a user to m1 |
| 27 |
2. Wait for replication |
| 28 |
3. Compare if the user is the same |
| 29 |
|
| 30 |
:expectedresults: 1. User is added |
| 31 |
2. Replication success |
| 32 |
3. The user is the same |
| 33 |
""" |
| 34 |
rm = ReplicationManager(DEFAULT_SUFFIX) |
| 35 |
m1 = topology_m2.ms.get('supplier1') |
| 36 |
m2 = topology_m2.ms.get('supplier2') |
| 37 |
|
| 38 |
m1_users = UserAccounts(m1, DEFAULT_SUFFIX) |
| 39 |
m2_users = UserAccounts(m2, DEFAULT_SUFFIX) |
| 40 |
|
| 41 |
# Create 1st user |
| 42 |
user1_properties = { |
| 43 |
'uid': 'testuser', |
| 44 |
'cn': 'testuser', |
| 45 |
'sn': 'user', |
| 46 |
'uidNumber': '1000', |
| 47 |
'gidNumber': '2000', |
| 48 |
'homeDirectory': '/home/testuser' |
| 49 |
} |
| 50 |
|
| 51 |
m1_users.create(properties=user1_properties) |
| 52 |
m1_testuser = m1_users.get('testuser') |
| 53 |
|
| 54 |
rm.wait_for_replication(m1, m2) |
| 55 |
|
| 56 |
m2_testuser = m2_users.get('testuser') |
| 57 |
|
| 58 |
assert UserAccount.compare(m1_testuser, m2_testuser) |
| 59 |
|
| 60 |
|
| 61 |
if __name__ == '__main__': |
| 62 |
# Run isolated |
| 63 |
# -s for DEBUG mode |
| 64 |
CURRENT_FILE = os.path.realpath(__file__) |
| 65 |
pytest.main("-s %s" % CURRENT_FILE) |