2009-06-24 08:12:27 -05:00
|
|
|
# Authors:
|
|
|
|
# Rob Crittenden <rcritten@redhat.com>
|
|
|
|
# Pavel Zuna <pzuna@redhat.com>
|
2009-12-09 10:09:53 -06:00
|
|
|
# Jason Gerard DeRose <jderose@redhat.com>
|
2009-06-24 08:12:27 -05:00
|
|
|
#
|
2009-12-09 10:09:53 -06:00
|
|
|
# Copyright (C) 2008, 2009 Red Hat
|
2009-06-24 08:12:27 -05:00
|
|
|
# see file 'COPYING' for use and warranty information
|
|
|
|
#
|
2010-12-09 06:59:11 -06:00
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
2009-06-24 08:12:27 -05:00
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2010-12-09 06:59:11 -06:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-12-09 10:09:53 -06:00
|
|
|
|
2009-06-24 08:12:27 -05:00
|
|
|
"""
|
|
|
|
Test the `ipalib/plugins/user.py` module.
|
|
|
|
"""
|
|
|
|
|
2009-12-09 10:09:53 -06:00
|
|
|
from ipalib import api, errors
|
2009-12-17 07:16:18 -06:00
|
|
|
from tests.test_xmlrpc import objectclasses
|
|
|
|
from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid
|
|
|
|
|
2009-12-09 10:09:53 -06:00
|
|
|
|
2009-12-18 09:57:40 -06:00
|
|
|
user_memberof = (u'cn=ipausers,cn=groups,cn=accounts,%s' % api.env.basedn,)
|
2009-12-17 07:16:18 -06:00
|
|
|
user1=u'tuser1'
|
2010-09-21 12:03:40 -05:00
|
|
|
user2=u'tuser2'
|
2010-10-18 13:53:32 -05:00
|
|
|
renameduser1=u'tuser'
|
2010-12-13 08:53:29 -06:00
|
|
|
group1=u'group1'
|
2009-12-09 10:09:53 -06:00
|
|
|
|
2010-07-27 15:35:23 -05:00
|
|
|
invaliduser1=u'+tuser1'
|
|
|
|
invaliduser2=u'tuser1234567890123456789012345678901234567890'
|
|
|
|
|
2009-12-09 10:09:53 -06:00
|
|
|
|
|
|
|
class test_user(Declarative):
|
|
|
|
|
|
|
|
cleanup_commands = [
|
2010-09-21 12:03:40 -05:00
|
|
|
('user_del', [user1, user2], {}),
|
2010-12-13 08:53:29 -06:00
|
|
|
('group_del', [group1], {}),
|
2009-12-09 10:09:53 -06:00
|
|
|
]
|
|
|
|
|
|
|
|
tests = [
|
|
|
|
|
|
|
|
dict(
|
2009-12-17 07:16:18 -06:00
|
|
|
desc='Try to retrieve non-existent %r' % user1,
|
|
|
|
command=('user_show', [user1], {}),
|
|
|
|
expected=errors.NotFound(reason='no such entry'),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to update non-existent %r' % user1,
|
|
|
|
command=('user_mod', [user1], dict(givenname=u'Foo')),
|
2009-12-09 10:09:53 -06:00
|
|
|
expected=errors.NotFound(reason='no such entry'),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
2009-12-17 07:16:18 -06:00
|
|
|
desc='Try to delete non-existent %r' % user1,
|
|
|
|
command=('user_del', [user1], {}),
|
|
|
|
expected=errors.NotFound(reason='no such entry'),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2010-10-18 13:53:32 -05:00
|
|
|
dict(
|
|
|
|
desc='Try to rename non-existent %r' % user1,
|
|
|
|
command=('user_mod', [user1], dict(setattr=u'uid=tuser')),
|
|
|
|
expected=errors.NotFound(reason='no such entry'),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2009-12-17 07:16:18 -06:00
|
|
|
dict(
|
|
|
|
desc='Create %r' % user1,
|
2009-12-09 10:09:53 -06:00
|
|
|
command=(
|
2010-09-21 12:03:40 -05:00
|
|
|
'user_add', [user1], dict(givenname=u'Test', sn=u'User1')
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
|
|
|
expected=dict(
|
2009-12-17 07:16:18 -06:00
|
|
|
value=user1,
|
|
|
|
summary=u'Added user "tuser1"',
|
2009-12-09 10:09:53 -06:00
|
|
|
result=dict(
|
2009-12-17 07:16:18 -06:00
|
|
|
gecos=[user1],
|
|
|
|
givenname=[u'Test'],
|
|
|
|
homedirectory=[u'/home/tuser1'],
|
|
|
|
krbprincipalname=[u'tuser1@' + api.env.realm],
|
|
|
|
loginshell=[u'/bin/sh'],
|
|
|
|
objectclass=objectclasses.user,
|
|
|
|
sn=[u'User1'],
|
|
|
|
uid=[user1],
|
2010-07-27 15:35:23 -05:00
|
|
|
uidnumber=[fuzzy_digits],
|
2010-12-09 13:57:34 -06:00
|
|
|
displayname=[u'Test User1'],
|
|
|
|
cn=[u'Test User1'],
|
|
|
|
initials=[u'TU'],
|
2009-12-17 07:16:18 -06:00
|
|
|
ipauniqueid=[fuzzy_uuid],
|
|
|
|
dn=u'uid=tuser1,cn=users,cn=accounts,' + api.env.basedn,
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
2009-12-17 07:16:18 -06:00
|
|
|
desc='Try to create duplicate %r' % user1,
|
2009-12-09 10:09:53 -06:00
|
|
|
command=(
|
2010-09-21 12:03:40 -05:00
|
|
|
'user_add', [user1], dict(givenname=u'Test', sn=u'User1')
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
|
|
|
expected=errors.DuplicateEntry(),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
2009-12-17 07:16:18 -06:00
|
|
|
desc='Retrieve %r' % user1,
|
2009-12-09 10:09:53 -06:00
|
|
|
command=(
|
2009-12-17 07:16:18 -06:00
|
|
|
'user_show', [user1], {}
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
result=dict(
|
2009-12-18 09:57:40 -06:00
|
|
|
dn=u'uid=tuser1,cn=users,cn=accounts,%s' % api.env.basedn,
|
2009-12-17 07:16:18 -06:00
|
|
|
givenname=[u'Test'],
|
|
|
|
homedirectory=[u'/home/tuser1'],
|
|
|
|
loginshell=[u'/bin/sh'],
|
|
|
|
sn=[u'User1'],
|
|
|
|
uid=[user1],
|
2010-02-12 15:34:21 -06:00
|
|
|
memberof_group=[u'ipausers'],
|
2010-11-03 14:31:46 -05:00
|
|
|
nsaccountlock=[u'False'],
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
2009-12-17 07:16:18 -06:00
|
|
|
value=user1,
|
2009-12-09 10:09:53 -06:00
|
|
|
summary=None,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
2009-12-17 07:16:18 -06:00
|
|
|
desc='Search for %r with all=True' % user1,
|
2009-12-09 10:09:53 -06:00
|
|
|
command=(
|
2009-12-17 07:16:18 -06:00
|
|
|
'user_find', [user1], {'all': True}
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
|
|
|
expected=dict(
|
2009-12-17 07:16:18 -06:00
|
|
|
result=[
|
2009-12-09 10:09:53 -06:00
|
|
|
{
|
2010-02-22 13:29:26 -06:00
|
|
|
'dn': u'uid=tuser1,cn=users,cn=accounts,' + api.env.basedn,
|
2009-12-17 07:16:18 -06:00
|
|
|
'cn': [u'Test User1'],
|
|
|
|
'gecos': [user1],
|
|
|
|
'givenname': [u'Test'],
|
|
|
|
'homedirectory': [u'/home/tuser1'],
|
|
|
|
'krbprincipalname': [u'tuser1@' + api.env.realm],
|
|
|
|
'loginshell': [u'/bin/sh'],
|
2010-02-12 15:34:21 -06:00
|
|
|
'memberof_group': [u'ipausers'],
|
2010-08-09 15:39:53 -05:00
|
|
|
'objectclass': objectclasses.user + [u'mepOriginEntry'],
|
2009-12-17 07:16:18 -06:00
|
|
|
'sn': [u'User1'],
|
|
|
|
'uid': [user1],
|
|
|
|
'uidnumber': [fuzzy_digits],
|
|
|
|
'gidnumber': [fuzzy_digits],
|
|
|
|
'ipauniqueid': [fuzzy_uuid],
|
2010-10-25 16:58:37 -05:00
|
|
|
'mepmanagedentry': [u'cn=%s,cn=groups,cn=accounts,%s' % (user1, api.env.basedn)],
|
|
|
|
'krbpwdpolicyreference': [u'cn=global_policy,cn=%s,cn=kerberos,%s' % (api.env.realm, api.env.basedn)],
|
2010-11-03 14:31:46 -05:00
|
|
|
'nsaccountlock': [u'False'],
|
2010-12-09 13:57:34 -06:00
|
|
|
'displayname': [u'Test User1'],
|
|
|
|
'cn': [u'Test User1'],
|
|
|
|
'initials': [u'TU'],
|
2009-12-09 10:09:53 -06:00
|
|
|
},
|
2009-12-17 07:16:18 -06:00
|
|
|
],
|
2009-12-09 10:09:53 -06:00
|
|
|
summary=u'1 user matched',
|
2010-02-12 15:34:21 -06:00
|
|
|
count=1, truncated=False,
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
2009-12-17 07:16:18 -06:00
|
|
|
desc='Search for %r with minimal attributes' % user1,
|
2009-12-09 10:09:53 -06:00
|
|
|
command=(
|
2009-12-17 07:16:18 -06:00
|
|
|
'user_find', [user1], {}
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
|
|
|
expected=dict(
|
2009-12-17 07:16:18 -06:00
|
|
|
result=[
|
2009-12-09 10:09:53 -06:00
|
|
|
dict(
|
2010-02-22 13:29:26 -06:00
|
|
|
dn=u'uid=tuser1,cn=users,cn=accounts,' + api.env.basedn,
|
2009-12-17 07:16:18 -06:00
|
|
|
givenname=[u'Test'],
|
|
|
|
homedirectory=[u'/home/tuser1'],
|
|
|
|
loginshell=[u'/bin/sh'],
|
|
|
|
sn=[u'User1'],
|
|
|
|
uid=[user1],
|
2010-02-12 15:34:21 -06:00
|
|
|
memberof_group=[u'ipausers'],
|
2010-11-03 14:31:46 -05:00
|
|
|
nsaccountlock=[u'False'],
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
2009-12-17 07:16:18 -06:00
|
|
|
],
|
2009-12-09 10:09:53 -06:00
|
|
|
summary=u'1 user matched',
|
|
|
|
count=1,
|
|
|
|
truncated=False,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Search for all users',
|
|
|
|
command=(
|
|
|
|
'user_find', [], {}
|
|
|
|
),
|
|
|
|
expected=dict(
|
2009-12-17 07:16:18 -06:00
|
|
|
result=[
|
2009-12-09 10:09:53 -06:00
|
|
|
dict(
|
2010-02-22 13:29:26 -06:00
|
|
|
dn=u'uid=admin,cn=users,cn=accounts,' + api.env.basedn,
|
2009-12-17 07:16:18 -06:00
|
|
|
homedirectory=[u'/home/admin'],
|
|
|
|
loginshell=[u'/bin/bash'],
|
|
|
|
sn=[u'Administrator'],
|
|
|
|
uid=[u'admin'],
|
2010-02-12 15:34:21 -06:00
|
|
|
memberof_group=[u'admins'],
|
2010-11-03 14:31:46 -05:00
|
|
|
nsaccountlock=[u'False'],
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
|
|
|
dict(
|
2010-02-22 13:29:26 -06:00
|
|
|
dn=u'uid=tuser1,cn=users,cn=accounts,' + api.env.basedn,
|
2009-12-17 07:16:18 -06:00
|
|
|
givenname=[u'Test'],
|
|
|
|
homedirectory=[u'/home/tuser1'],
|
|
|
|
loginshell=[u'/bin/sh'],
|
|
|
|
sn=[u'User1'],
|
|
|
|
uid=[user1],
|
2010-02-12 15:34:21 -06:00
|
|
|
memberof_group=[u'ipausers'],
|
2010-11-03 14:31:46 -05:00
|
|
|
nsaccountlock=[u'False'],
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
2009-12-17 07:16:18 -06:00
|
|
|
],
|
2009-12-09 10:09:53 -06:00
|
|
|
summary=u'2 users matched',
|
|
|
|
count=2,
|
|
|
|
truncated=False,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2010-08-18 13:04:58 -05:00
|
|
|
dict(
|
|
|
|
desc='Search for all users with a limit of 1',
|
|
|
|
command=(
|
|
|
|
'user_find', [], dict(sizelimit=1,),
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
result=[
|
|
|
|
dict(
|
|
|
|
dn=u'uid=admin,cn=users,cn=accounts,' + api.env.basedn,
|
|
|
|
homedirectory=[u'/home/admin'],
|
|
|
|
loginshell=[u'/bin/bash'],
|
|
|
|
sn=[u'Administrator'],
|
|
|
|
uid=[u'admin'],
|
|
|
|
memberof_group=[u'admins'],
|
2010-11-03 14:31:46 -05:00
|
|
|
nsaccountlock=[u'False'],
|
2010-08-18 13:04:58 -05:00
|
|
|
),
|
|
|
|
],
|
|
|
|
summary=u'1 user matched',
|
|
|
|
count=1,
|
|
|
|
truncated=True,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2009-12-09 10:09:53 -06:00
|
|
|
dict(
|
2010-10-05 14:37:37 -05:00
|
|
|
desc='Disable %r' % user1,
|
2009-12-09 10:09:53 -06:00
|
|
|
command=(
|
2010-10-05 14:37:37 -05:00
|
|
|
'user_disable', [user1], {}
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
result=True,
|
2009-12-17 07:16:18 -06:00
|
|
|
value=user1,
|
2010-10-05 14:37:37 -05:00
|
|
|
summary=u'Disabled user account "tuser1"',
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
2010-10-05 14:37:37 -05:00
|
|
|
desc='Enable %r' % user1,
|
2009-12-09 10:09:53 -06:00
|
|
|
command=(
|
2010-10-05 14:37:37 -05:00
|
|
|
'user_enable', [user1], {}
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
result=True,
|
2009-12-17 07:16:18 -06:00
|
|
|
value=user1,
|
2010-10-05 14:37:37 -05:00
|
|
|
summary=u'Enabled user account "tuser1"',
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
2009-12-17 07:16:18 -06:00
|
|
|
desc='Update %r' % user1,
|
2009-12-09 10:09:53 -06:00
|
|
|
command=(
|
2009-12-17 07:16:18 -06:00
|
|
|
'user_mod', [user1], dict(givenname=u'Finkle')
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
result=dict(
|
2009-12-17 07:16:18 -06:00
|
|
|
givenname=[u'Finkle'],
|
2010-02-12 15:34:21 -06:00
|
|
|
homedirectory=[u'/home/tuser1'],
|
|
|
|
loginshell=[u'/bin/sh'],
|
|
|
|
sn=[u'User1'],
|
|
|
|
uid=[user1],
|
|
|
|
memberof_group=[u'ipausers'],
|
2010-11-03 14:31:46 -05:00
|
|
|
nsaccountlock=[u'False'],
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
|
|
|
summary=u'Modified user "tuser1"',
|
2009-12-17 07:16:18 -06:00
|
|
|
value=user1,
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
2009-12-17 07:16:18 -06:00
|
|
|
desc='Retrieve %r to verify update' % user1,
|
|
|
|
command=('user_show', [user1], {}),
|
2009-12-09 10:09:53 -06:00
|
|
|
expected=dict(
|
|
|
|
result=dict(
|
2009-12-18 09:57:40 -06:00
|
|
|
dn=u'uid=tuser1,cn=users,cn=accounts,%s' % api.env.basedn,
|
2009-12-17 07:16:18 -06:00
|
|
|
givenname=[u'Finkle'],
|
|
|
|
homedirectory=[u'/home/tuser1'],
|
|
|
|
loginshell=[u'/bin/sh'],
|
|
|
|
sn=[u'User1'],
|
|
|
|
uid=[user1],
|
2010-02-12 15:34:21 -06:00
|
|
|
memberof_group=[u'ipausers'],
|
2010-11-03 14:31:46 -05:00
|
|
|
nsaccountlock=[u'False'],
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
|
|
|
summary=None,
|
2009-12-17 07:16:18 -06:00
|
|
|
value=user1,
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2010-10-18 13:53:32 -05:00
|
|
|
dict(
|
|
|
|
desc='Rename %r' % user1,
|
|
|
|
command=('user_mod', [user1], dict(setattr=u'uid=%s' % renameduser1)),
|
|
|
|
expected=dict(
|
|
|
|
result=dict(
|
|
|
|
givenname=[u'Finkle'],
|
|
|
|
homedirectory=[u'/home/tuser1'],
|
|
|
|
loginshell=[u'/bin/sh'],
|
|
|
|
sn=[u'User1'],
|
|
|
|
uid=[renameduser1],
|
|
|
|
memberof_group=[u'ipausers'],
|
2010-11-03 14:31:46 -05:00
|
|
|
nsaccountlock=[u'False'],
|
2010-10-18 13:53:32 -05:00
|
|
|
),
|
|
|
|
summary=u'Modified user "%s"' % user1,
|
|
|
|
value=user1,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Rename %r to same value' % renameduser1,
|
|
|
|
command=('user_mod', [renameduser1], dict(setattr=u'uid=%s' % renameduser1)),
|
|
|
|
expected=errors.EmptyModlist(),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Rename back %r' % renameduser1,
|
|
|
|
command=('user_mod', [renameduser1], dict(setattr=u'uid=%s' % user1)),
|
|
|
|
expected=dict(
|
|
|
|
result=dict(
|
|
|
|
givenname=[u'Finkle'],
|
|
|
|
homedirectory=[u'/home/tuser1'],
|
|
|
|
loginshell=[u'/bin/sh'],
|
|
|
|
sn=[u'User1'],
|
|
|
|
uid=[user1],
|
|
|
|
memberof_group=[u'ipausers'],
|
2010-11-03 14:31:46 -05:00
|
|
|
nsaccountlock=[u'False'],
|
2010-10-18 13:53:32 -05:00
|
|
|
),
|
|
|
|
summary=u'Modified user "%s"' % renameduser1,
|
|
|
|
value=renameduser1,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2009-12-09 10:09:53 -06:00
|
|
|
dict(
|
2009-12-17 07:16:18 -06:00
|
|
|
desc='Delete %r' % user1,
|
|
|
|
command=('user_del', [user1], {}),
|
2009-12-09 10:09:53 -06:00
|
|
|
expected=dict(
|
2011-01-07 10:17:55 -06:00
|
|
|
result=dict(failed=u''),
|
2009-12-09 10:09:53 -06:00
|
|
|
summary=u'Deleted user "tuser1"',
|
2009-12-17 07:16:18 -06:00
|
|
|
value=user1,
|
2009-12-09 10:09:53 -06:00
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
2009-12-17 07:16:18 -06:00
|
|
|
desc='Try to delete non-existent %r' % user1,
|
|
|
|
command=('user_del', [user1], {}),
|
2009-12-09 10:09:53 -06:00
|
|
|
expected=errors.NotFound(reason='no such entry'),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2010-09-21 12:03:40 -05:00
|
|
|
dict(
|
|
|
|
desc='Create %r' % user1,
|
|
|
|
command=(
|
|
|
|
'user_add', [user1], dict(givenname=u'Test', sn=u'User1')
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=user1,
|
|
|
|
summary=u'Added user "tuser1"',
|
|
|
|
result=dict(
|
|
|
|
gecos=[user1],
|
|
|
|
givenname=[u'Test'],
|
|
|
|
homedirectory=[u'/home/tuser1'],
|
|
|
|
krbprincipalname=[u'tuser1@' + api.env.realm],
|
|
|
|
loginshell=[u'/bin/sh'],
|
|
|
|
objectclass=objectclasses.user,
|
|
|
|
sn=[u'User1'],
|
|
|
|
uid=[user1],
|
|
|
|
uidnumber=[fuzzy_digits],
|
2010-12-09 13:57:34 -06:00
|
|
|
displayname=[u'Test User1'],
|
|
|
|
cn=[u'Test User1'],
|
|
|
|
initials=[u'TU'],
|
2010-09-21 12:03:40 -05:00
|
|
|
ipauniqueid=[fuzzy_uuid],
|
|
|
|
dn=u'uid=tuser1,cn=users,cn=accounts,' + api.env.basedn,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2011-01-07 10:17:55 -06:00
|
|
|
|
2010-09-21 12:03:40 -05:00
|
|
|
dict(
|
|
|
|
desc='Create %r' % user2,
|
|
|
|
command=(
|
|
|
|
'user_add', [user2], dict(givenname=u'Test', sn=u'User2')
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=user2,
|
|
|
|
summary=u'Added user "tuser2"',
|
|
|
|
result=dict(
|
|
|
|
gecos=[user2],
|
|
|
|
givenname=[u'Test'],
|
|
|
|
homedirectory=[u'/home/tuser2'],
|
|
|
|
krbprincipalname=[u'tuser2@' + api.env.realm],
|
|
|
|
loginshell=[u'/bin/sh'],
|
|
|
|
objectclass=objectclasses.user,
|
|
|
|
sn=[u'User2'],
|
|
|
|
uid=[user2],
|
|
|
|
uidnumber=[fuzzy_digits],
|
2010-12-09 13:57:34 -06:00
|
|
|
displayname=[u'Test User2'],
|
|
|
|
cn=[u'Test User2'],
|
|
|
|
initials=[u'TU'],
|
2010-09-21 12:03:40 -05:00
|
|
|
ipauniqueid=[fuzzy_uuid],
|
|
|
|
dn=u'uid=tuser2,cn=users,cn=accounts,' + api.env.basedn,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2011-01-07 10:17:55 -06:00
|
|
|
|
2010-09-21 12:03:40 -05:00
|
|
|
dict(
|
|
|
|
desc='Delete %r and %r at the same time' % (user1, user2),
|
|
|
|
command=('user_del', [user1, user2], {}),
|
|
|
|
expected=dict(
|
2011-01-07 10:17:55 -06:00
|
|
|
result=dict(failed=u''),
|
2010-09-21 12:03:40 -05:00
|
|
|
summary=u'Deleted user "tuser1,tuser2"',
|
|
|
|
value=u','.join((user1, user2)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2009-12-09 10:09:53 -06:00
|
|
|
dict(
|
2009-12-17 07:16:18 -06:00
|
|
|
desc='Try to retrieve non-existent %r' % user1,
|
|
|
|
command=('user_show', [user1], {}),
|
|
|
|
expected=errors.NotFound(reason='no such entry'),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to update non-existent %r' % user1,
|
|
|
|
command=('user_mod', [user1], dict(givenname=u'Foo')),
|
2009-12-09 10:09:53 -06:00
|
|
|
expected=errors.NotFound(reason='no such entry'),
|
|
|
|
),
|
2009-06-24 08:12:27 -05:00
|
|
|
|
2009-12-17 07:16:18 -06:00
|
|
|
|
2010-07-27 15:35:23 -05:00
|
|
|
dict(
|
|
|
|
desc='Test an invalid login name %r' % invaliduser1,
|
|
|
|
command=('user_add', [invaliduser1], dict(givenname=u'Test', sn=u'User1')),
|
|
|
|
expected=errors.ValidationError(name='uid', error='may only include letters, numbers, _, -, . and $'),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Test a login name that is too long %r' % invaliduser2,
|
|
|
|
command=('user_add', [invaliduser2], dict(givenname=u'Test', sn=u'User1')),
|
|
|
|
expected=errors.ValidationError(name='uid', error='can be at most 33 characters'),
|
|
|
|
),
|
|
|
|
|
2010-12-13 08:53:29 -06:00
|
|
|
dict(
|
|
|
|
desc='Create %r' % group1,
|
|
|
|
command=(
|
|
|
|
'group_add', [group1], dict(description=u'Test desc')
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=group1,
|
|
|
|
summary=u'Added group "%s"' % group1,
|
|
|
|
result=dict(
|
|
|
|
cn=[group1],
|
|
|
|
description=[u'Test desc'],
|
|
|
|
gidnumber=[fuzzy_digits],
|
|
|
|
objectclass=objectclasses.group + [u'posixgroup'],
|
|
|
|
ipauniqueid=[fuzzy_uuid],
|
|
|
|
dn=u'cn=%s,cn=groups,cn=accounts,%s' % (group1, api.env.basedn),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to user %r where the managed group exists' % group1,
|
|
|
|
command=(
|
|
|
|
'user_add', [group1], dict(givenname=u'Test', sn=u'User1')
|
|
|
|
),
|
|
|
|
expected=errors.ManagedGroupExistsError(group=group1)
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2011-02-02 13:16:27 -06:00
|
|
|
dict(
|
|
|
|
desc='Create %r with a full address' % user1,
|
|
|
|
command=(
|
|
|
|
'user_add', [user1], dict(givenname=u'Test', sn=u'User1',
|
2011-02-10 12:29:52 -06:00
|
|
|
street=u'123 Maple Rd', locality=u'Anytown', st=u'MD',
|
|
|
|
telephonenumber=u'410-555-1212',)
|
2011-02-02 13:16:27 -06:00
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=user1,
|
|
|
|
summary=u'Added user "tuser1"',
|
|
|
|
result=dict(
|
|
|
|
gecos=[user1],
|
|
|
|
givenname=[u'Test'],
|
|
|
|
homedirectory=[u'/home/tuser1'],
|
|
|
|
krbprincipalname=[u'tuser1@' + api.env.realm],
|
|
|
|
loginshell=[u'/bin/sh'],
|
|
|
|
objectclass=objectclasses.user,
|
|
|
|
sn=[u'User1'],
|
|
|
|
uid=[user1],
|
|
|
|
uidnumber=[fuzzy_digits],
|
|
|
|
displayname=[u'Test User1'],
|
|
|
|
cn=[u'Test User1'],
|
|
|
|
initials=[u'TU'],
|
|
|
|
street=[u'123 Maple Rd'],
|
|
|
|
locality=[u'Anytown'],
|
|
|
|
st=[u'MD'],
|
|
|
|
telephonenumber=[u'410-555-1212'],
|
|
|
|
ipauniqueid=[fuzzy_uuid],
|
|
|
|
dn=u'uid=tuser1,cn=users,cn=accounts,' + api.env.basedn,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Delete %r' % user1,
|
|
|
|
command=('user_del', [user1], {}),
|
|
|
|
expected=dict(
|
|
|
|
result=dict(failed=u''),
|
|
|
|
summary=u'Deleted user "tuser1"',
|
|
|
|
value=user1,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2009-12-09 10:09:53 -06:00
|
|
|
]
|