def test_dsidm_user_create(topology_st): """ Test dsidm user create option :id: 862f5875-11fd-4e8e-92c1-397010386eb8 :setup: Standalone instance :steps: 1. Run dsidm user create 2. Check that a message is provided on creation 3. Check that created user exists :expectedresults: 1. Success 2. Success 3. Success """ standalone = topology_st.standalone user_name = 'new_user' output = 'Successfully created {}'.format(user_name) args = FakeArgs() args.uid = user_name args.cn = user_name args.displayName = user_name args.uidNumber = '1030' args.gidNumber = '2030' args.homeDirectory = '/home/{}'.format(user_name) log.info('Test dsidm user create') create(standalone, DEFAULT_SUFFIX, topology_st.logcap.log, args) check_value_in_log_and_reset(topology_st, check_value=output) log.info('Check that user is present') users = nsUserAccounts(standalone, DEFAULT_SUFFIX) new_user = users.get(user_name) assert new_user.exists() log.info('Clean up for next test') new_user.delete()
def test_group_tasks(topology): # First check that our test group isn't there: topology.logcap.flush() g_args = FakeArgs() g_args.selector = 'testgroup' with pytest.raises(ldap.NO_SUCH_OBJECT): get(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, g_args) # Create a group topology.logcap.flush() g_args.cn = 'testgroup' create(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, g_args) assert (topology.logcap.contains("Sucessfully created testgroup")) # Assert it exists topology.logcap.flush() g_args = FakeArgs() g_args.selector = 'testgroup' get(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, g_args) assert (topology.logcap.contains( "dn: cn=testgroup,ou=groups,dc=example,dc=com")) # Add a user topology.logcap.flush() u_args = FakeArgs() u_args.uid = 'testuser' u_args.cn = 'Test User' u_args.displayName = 'Test User' u_args.homeDirectory = '/home/testuser' u_args.uidNumber = '5000' u_args.gidNumber = '5000' create_user(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, u_args) assert (topology.logcap.contains("Sucessfully created testuser")) # Add them to the group as a member topology.logcap.flush() g_args.cn = "testgroup" g_args.dn = "uid=testuser,ou=people,dc=example,dc=com" add_member(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, g_args) assert (topology.logcap.contains("added member")) # Check they are a member topology.logcap.flush() g_args.cn = "testgroup" members(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, g_args) assert ( topology.logcap.contains("uid=testuser,ou=people,dc=example,dc=com")) # Remove them from the group topology.logcap.flush() g_args.cn = "testgroup" g_args.dn = "uid=testuser,ou=people,dc=example,dc=com" remove_member(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, g_args) assert (topology.logcap.contains("removed member")) # Check they are not a member topology.logcap.flush() g_args.cn = "testgroup" members(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, g_args) assert (topology.logcap.contains("No members to display")) # Delete the group topology.logcap.flush() g_args.dn = "cn=testgroup,ou=groups,dc=example,dc=com" delete(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, g_args, warn=False) assert (topology.logcap.contains( "Sucessfully deleted cn=testgroup,ou=groups,dc=example,dc=com"))
def test_user_tasks(topology): be_args = FakeArgs() be_args.cn = 'userRoot' be_args.nsslapd_suffix = DEFAULT_SUFFIX backend_create(topology.standalone, None, topology.logcap.log, be_args) # And add the skeleton objects. init_args = FakeArgs() init_args.version = INSTALL_LATEST_CONFIG initialise(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, init_args) # First check that our test user isn't there: topology.logcap.flush() u_args = FakeArgs() u_args.selector = 'testuser' with pytest.raises(ldap.NO_SUCH_OBJECT): get(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, u_args) # Create the user topology.logcap.flush() u_args.uid = 'testuser' # u_args.sn = 'testuser' u_args.cn = 'Test User' u_args.displayName = 'Test User' u_args.homeDirectory = '/home/testuser' u_args.uidNumber = '5000' u_args.gidNumber = '5000' create(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, u_args) assert(topology.logcap.contains("Sucessfully created testuser")) # Assert they exist topology.logcap.flush() get(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, u_args) assert(topology.logcap.contains('dn: uid=testuser,ou=people,dc=example,dc=com')) # Reset the password # Lock the account, check status topology.logcap.flush() lock(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, u_args) assert(topology.logcap.contains('locked')) topology.logcap.flush() status(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, u_args) assert(topology.logcap.contains('locked: True')) # Unlock check status topology.logcap.flush() unlock(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, u_args) assert(topology.logcap.contains('unlocked')) topology.logcap.flush() status(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, u_args) assert(topology.logcap.contains('locked: False')) # Enroll a dummy cert # Enroll a dummy sshkey # Delete it topology.logcap.flush() u_args.dn = 'uid=testuser,ou=people,dc=example,dc=com' delete(topology.standalone, DEFAULT_SUFFIX, topology.logcap.log, u_args, warn=False) assert(topology.logcap.contains('Sucessfully deleted uid=testuser,ou=people,dc=example,dc=com'))