| 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 os |
| 10 |
import pytest |
| 11 |
from lib389._constants import DEFAULT_SUFFIX |
| 12 |
from lib389.idm.user import UserAccounts, UserAccount |
| 13 |
from test389.topologies import topology_i2 |
| 14 |
|
| 15 |
pytestmark = pytest.mark.tier1 |
| 16 |
|
| 17 |
def test_user_compare_i2(topology_i2): |
| 18 |
""" |
| 19 |
Compare test between users of two different Directory Server intances. |
| 20 |
|
| 21 |
:id: f0ffaf59-e2c2-41ec-9f26-e9b1ef287463 |
| 22 |
|
| 23 |
:setup: two isolated directory servers |
| 24 |
|
| 25 |
:steps: 1. Add an identical user to each server |
| 26 |
2. Compare if the users are "the same" |
| 27 |
|
| 28 |
:expectedresults: 1. Users are added |
| 29 |
2. The users are reported as the same |
| 30 |
""" |
| 31 |
st1_users = UserAccounts(topology_i2.ins.get('standalone1'), DEFAULT_SUFFIX) |
| 32 |
st2_users = UserAccounts(topology_i2.ins.get('standalone2'), DEFAULT_SUFFIX) |
| 33 |
|
| 34 |
# Create user |
| 35 |
user_properties = { |
| 36 |
'uid': 'testuser', |
| 37 |
'cn': 'testuser', |
| 38 |
'sn': 'user', |
| 39 |
'uidNumber': '1000', |
| 40 |
'gidNumber': '2000', |
| 41 |
'homeDirectory': '/home/testuser' |
| 42 |
} |
| 43 |
|
| 44 |
st1_users.create(properties=user_properties) |
| 45 |
st1_testuser = st1_users.get('testuser') |
| 46 |
|
| 47 |
st2_users.create(properties=user_properties) |
| 48 |
st2_testuser = st2_users.get('testuser') |
| 49 |
|
| 50 |
st1_testuser._compare_exclude.append('entryuuid') |
| 51 |
st2_testuser._compare_exclude.append('entryuuid') |
| 52 |
|
| 53 |
assert UserAccount.compare(st1_testuser, st2_testuser) |
| 54 |
|
| 55 |
|
| 56 |
if __name__ == '__main__': |
| 57 |
# Run isolated |
| 58 |
# -s for DEBUG mode |
| 59 |
CURRENT_FILE = os.path.realpath(__file__) |
| 60 |
pytest.main("-s %s" % CURRENT_FILE) |