summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2011-11-29 09:59:11 +0100
committerMartin Kosek <mkosek@redhat.com>2011-11-29 10:08:28 +0100
commit1b0b9645d197f512eee61051775414ca35ee7f6d (patch)
treeaf96542f62da62d8c4021474fc326b7470e46a95 /tests
parent046147b3a44b793049ee0100d775b8fe5c709999 (diff)
downloadfreeipa-1b0b9645d197f512eee61051775414ca35ee7f6d.tar.gz
freeipa-1b0b9645d197f512eee61051775414ca35ee7f6d.tar.xz
freeipa-1b0b9645d197f512eee61051775414ca35ee7f6d.zip
Add --delattr option to complement --setattr/--addattr
Add a --delattr option to round out multi-valued attribute manipulation. The new option is available for all LDAPUpdate based commands. --delattr is evaluated last, it can remove any value present either in --addattr/--setattr option or in current LDAP object. --*attr processing was completely refactored and placed to one independent function available for all baseldap commands. For this purpose a missing common base class for all baseldap commands has been implemented. The new class should serve not only for --*attr processing but also for other common baseldap methods and attributes. This approach will also benefit other custom commands based neither on LDAPCreate nor LDAPUpdate. They can easily integrate --*attr option processing when needed. https://fedorahosted.org/freeipa/ticket/1929
Diffstat (limited to 'tests')
-rw-r--r--tests/test_xmlrpc/test_attr.py126
-rw-r--r--tests/test_xmlrpc/test_group_plugin.py4
2 files changed, 128 insertions, 2 deletions
diff --git a/tests/test_xmlrpc/test_attr.py b/tests/test_xmlrpc/test_attr.py
index 11aaa01e3..ef239709d 100644
--- a/tests/test_xmlrpc/test_attr.py
+++ b/tests/test_xmlrpc/test_attr.py
@@ -210,6 +210,128 @@ class test_attr(Declarative):
dict(
+ desc='Delete one phone number for %r' % user1,
+ command=(
+ 'user_mod', [user1], dict(delattr=u'telephoneNumber=301-555-1212')
+ ),
+ expected=dict(
+ result=dict(
+ givenname=[u'Finkle'],
+ homedirectory=[u'/home/tuser1'],
+ loginshell=[u'/bin/sh'],
+ sn=[u'User1'],
+ uid=[user1],
+ uidnumber=[fuzzy_digits],
+ gidnumber=[fuzzy_digits],
+ mail=[u'test@example.com', u'test2@example.com'],
+ memberof_group=[u'ipausers'],
+ telephonenumber=[u'202-888-9833', u'703-555-1212'],
+ nsaccountlock=False,
+ has_keytab=False,
+ has_password=False,
+ ),
+ summary=u'Modified user "tuser1"',
+ value=user1,
+ ),
+ ),
+
+
+ dict(
+ desc='Try deleting the number again for %r' % user1,
+ command=(
+ 'user_mod', [user1], dict(delattr=u'telephoneNumber=301-555-1212')
+ ),
+ expected=errors.AttrValueNotFound(attr='telephoneNumber', value='301-555-1212')
+ ),
+
+
+ dict(
+ desc='Add and delete one phone number for %r' % user1,
+ command=(
+ 'user_mod', [user1], dict(addattr=u'telephoneNumber=301-555-1212',
+ delattr=u'telephoneNumber=202-888-9833')
+ ),
+ expected=dict(
+ result=dict(
+ givenname=[u'Finkle'],
+ homedirectory=[u'/home/tuser1'],
+ loginshell=[u'/bin/sh'],
+ sn=[u'User1'],
+ uid=[user1],
+ uidnumber=[fuzzy_digits],
+ gidnumber=[fuzzy_digits],
+ mail=[u'test@example.com', u'test2@example.com'],
+ memberof_group=[u'ipausers'],
+ telephonenumber=[u'301-555-1212', u'703-555-1212'],
+ nsaccountlock=False,
+ has_keytab=False,
+ has_password=False,
+ ),
+ summary=u'Modified user "tuser1"',
+ value=user1,
+ ),
+ ),
+
+
+ dict(
+ desc='Add and delete the same phone number for %r' % user1,
+ command=(
+ 'user_mod', [user1], dict(addattr=(u'telephoneNumber=301-555-1212',
+ u'telephoneNumber=202-888-9833'),
+ delattr=u'telephoneNumber=301-555-1212')
+ ),
+ expected=dict(
+ result=dict(
+ givenname=[u'Finkle'],
+ homedirectory=[u'/home/tuser1'],
+ loginshell=[u'/bin/sh'],
+ sn=[u'User1'],
+ uid=[user1],
+ uidnumber=[fuzzy_digits],
+ gidnumber=[fuzzy_digits],
+ mail=[u'test@example.com', u'test2@example.com'],
+ memberof_group=[u'ipausers'],
+ telephonenumber=[u'703-555-1212', u'301-555-1212', u'202-888-9833'],
+ nsaccountlock=False,
+ has_keytab=False,
+ has_password=False,
+ ),
+ summary=u'Modified user "tuser1"',
+ value=user1,
+ ),
+ ),
+
+
+ dict(
+ desc='Set and delete the a phone number for %r' % user1,
+ command=(
+ 'user_mod', [user1], dict(setattr=(u'telephoneNumber=301-555-1212',
+ u'telephoneNumber=202-888-9833'),
+ delattr=u'telephoneNumber=301-555-1212')
+ ),
+ expected=dict(
+ result=dict(
+ givenname=[u'Finkle'],
+ homedirectory=[u'/home/tuser1'],
+ loginshell=[u'/bin/sh'],
+ sn=[u'User1'],
+ uid=[user1],
+ uidnumber=[fuzzy_digits],
+ gidnumber=[fuzzy_digits],
+ mail=[u'test@example.com', u'test2@example.com'],
+ memberof_group=[u'ipausers'],
+ telephonenumber=[u'202-888-9833'],
+ nsaccountlock=False,
+ has_keytab=False,
+ has_password=False,
+ ),
+ summary=u'Modified user "tuser1"',
+ value=user1,
+ ),
+ ),
+
+
+ dict(
desc='Try setting givenname to None with setattr in %r' % user1,
command=(
'user_mod', [user1], dict(setattr=(u'givenname='))
@@ -243,7 +365,7 @@ class test_attr(Declarative):
gidnumber=[fuzzy_digits],
mail=[u'test@example.com', u'test2@example.com'],
memberof_group=[u'ipausers'],
- telephonenumber=[u'301-555-1212', u'202-888-9833', u'703-555-1212'],
+ telephonenumber=[u'202-888-9833'],
nsaccountlock=False,
has_keytab=False,
has_password=False,
@@ -270,7 +392,7 @@ class test_attr(Declarative):
gidnumber=[fuzzy_digits],
mail=[u'test@example.com', u'test2@example.com'],
memberof_group=[u'ipausers'],
- telephonenumber=[u'301-555-1212', u'202-888-9833', u'703-555-1212'],
+ telephonenumber=[u'202-888-9833'],
nsaccountlock=False,
has_keytab=False,
has_password=False,
diff --git a/tests/test_xmlrpc/test_group_plugin.py b/tests/test_xmlrpc/test_group_plugin.py
index 6403251e6..86c0d90da 100644
--- a/tests/test_xmlrpc/test_group_plugin.py
+++ b/tests/test_xmlrpc/test_group_plugin.py
@@ -755,6 +755,10 @@ class test_group(Declarative):
dn=lambda x: DN(x) == \
DN(('uid','tuser1'),('cn','users'),('cn','accounts'),
api.env.basedn),
+ krbpwdpolicyreference=lambda x: [DN(i) for i in x] == \
+ [DN(('cn','global_policy'),('cn',api.env.realm),
+ ('cn','kerberos'),api.env.basedn)],
+ memberof_group=[u'ipausers'],
has_keytab=False,
has_password=False,
),