Debian Codegraph @

dirsrvtests/tests/suites/replication/tombstone_test.py

raw
1 # --- BEGIN COPYRIGHT BLOCK ---
2 # Copyright (C) 2017 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 pytest
10 from lib389.tasks import *
11 from lib389.utils import *
12 from test389.topologies import topology_m1
13 from lib389.tombstone import Tombstones
14 from lib389.idm.user import UserAccounts, TEST_USER_PROPERTIES
15
16 pytestmark = pytest.mark.tier1
17
18
19 def test_purge_success(topology_m1):
20 """Verify that tombstones are created successfully
21
22 :id: adb86f50-ae76-4ed6-82b4-3cdc30ccab78
23 :setup: Standalone instance
24 :steps:
25 1. Enable replication to unexisting instance
26 2. Add an entry to the replicated suffix
27 3. Delete the entry
28 4. Check that tombstone entry exists (objectclass=nsTombstone)
29 :expectedresults: Tombstone entry exist
30 1. Operation should be successful
31 2. The entry should be successfully added
32 3. The entry should be successfully deleted
33 4. Tombstone entry should exist
34 """
35 m1 = topology_m1.ms['supplier1']
36
37 users = UserAccounts(m1, DEFAULT_SUFFIX)
38 user = users.create(properties=TEST_USER_PROPERTIES)
39
40 tombstones = Tombstones(m1, DEFAULT_SUFFIX)
41
42 assert len(tombstones.list()) == 0
43
44 user.delete()
45
46 assert len(tombstones.list()) == 1
47 assert len(users.list()) == 0
48
49 ts = tombstones.get('testuser')
50 assert ts.exists()
51
52 if not ds_is_older('1.4.0'):
53 ts.revive()
54
55 assert len(users.list()) == 1
56 user_revived = users.get('testuser')
57
58
59 if __name__ == '__main__':
60 # Run isolated
61 # -s for DEBUG mode
62 CURRENT_FILE = os.path.realpath(__file__)
63 pytest.main("-s %s" % CURRENT_FILE)