def assert_data_present(inst): # Do we have the backend marker? d = Domain(inst, DEFAULT_SUFFIX) try: desc = d.get_attr_val_utf8('description') if desc == TEST_MARKER: return except: # Just reset everything. pass # Reset the backends bes = Backends(inst) try: be = bes.get(DEFAULT_SUFFIX) be.delete() except: pass be = bes.create(properties={ 'nsslapd-suffix': DEFAULT_SUFFIX, 'cn': 'userRoot', }) be.create_sample_entries('001004002') # Load our data # We can't use dbgen as that relies on local access :( # Add 40,000 groups groups = Groups(inst, DEFAULT_SUFFIX) for i in range(1, GROUP_MAX): rdn = 'group_{0:07d}'.format(i) groups.create(properties={ 'cn': rdn, }) # Add 60,000 users users = nsUserAccounts(inst, DEFAULT_SUFFIX) for i in range(1, USER_MAX): rdn = 'user_{0:07d}'.format(i) users.create( properties={ 'uid': rdn, 'cn': rdn, 'displayName': rdn, 'uidNumber': '%s' % i, 'gidNumber': '%s' % i, 'homeDirectory': '/home/%s' % rdn, 'userPassword': rdn, }) # Add the marker d.replace('description', TEST_MARKER)
def test_entryuuid_fixup_task(topology): """Test that when an entries without UUID's can have one generated via the fixup process. :id: ad42bba2-ffb2-4c22-a37d-cbe7bcf73d6b :setup: Standalone instance :steps: 1. Disable the entryuuid plugin 2. Create an entry 3. Enable the entryuuid plugin 4. Run the fixup 5. Assert the entryuuid now exists 6. Restart and check they persist :expectedresults: 1. Success 2. Success 3. Success 4. Success 5. Suddenly EntryUUID! 6. Still has EntryUUID! """ # 1. Disable the plugin plug = EntryUUIDPlugin(topology.standalone) plug.disable() topology.standalone.restart() # 2. create the account account = nsUserAccounts(topology.standalone, DEFAULT_SUFFIX).create_test_user(uid=2000) euuid = account.get_attr_val_utf8('entryUUID') assert (euuid is None) # 3. enable the plugin plug.enable() topology.standalone.restart() # 4. run the fix up # For now set the log level to high! topology.standalone.config.loglevel(vals=(ErrorLog.DEFAULT, ErrorLog.PLUGIN)) task = plug.fixup(DEFAULT_SUFFIX) task.wait() assert (task.is_complete() and task.get_exit_code() == 0) topology.standalone.config.loglevel(vals=(ErrorLog.DEFAULT, )) # 5.1 Assert the uuid on the user. euuid_user = account.get_attr_val_utf8('entryUUID') assert (euuid_user is not None) # 5.2 Assert it on the domain entry. domain = Domain(topology.standalone, dn=DEFAULT_SUFFIX) euuid_domain = domain.get_attr_val_utf8('entryUUID') assert (euuid_domain is not None) # Assert it persists after a restart. topology.standalone.restart() # 6.1 Assert the uuid on the use. euuid_user_2 = account.get_attr_val_utf8('entryUUID') assert (euuid_user_2 == euuid_user) # 6.2 Assert it on the domain entry. euuid_domain_2 = domain.get_attr_val_utf8('entryUUID') assert (euuid_domain_2 == euuid_domain)