mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-23 23:50:03 -06:00
Fix addattr internal error
When ADD command is being executed and a single-value object attribute is being set with both option and addattr IPA ends up in an internal error. Make better value sanitizing job in this case and let IPA throw a user-friendly error. Unit test exercising this situation is added. https://fedorahosted.org/freeipa/ticket/2429
This commit is contained in:
parent
d491ba0289
commit
cd7a85c12c
@ -882,7 +882,17 @@ last, after all sets and adds."""),
|
||||
entry_attrs[attr] = val
|
||||
|
||||
for attr in direct_add:
|
||||
entry_attrs.setdefault(attr, []).extend(adddict[attr])
|
||||
try:
|
||||
val = entry_attrs[attr]
|
||||
except KeyError:
|
||||
val = []
|
||||
else:
|
||||
if not isinstance(val, (list, tuple)):
|
||||
val = [val]
|
||||
elif isinstance(val, tuple):
|
||||
val = list(val)
|
||||
val.extend(adddict[attr])
|
||||
entry_attrs[attr] = val
|
||||
|
||||
for attr in direct_del:
|
||||
for delval in deldict[attr]:
|
||||
|
@ -36,6 +36,16 @@ class test_attr(Declarative):
|
||||
|
||||
tests = [
|
||||
|
||||
dict(
|
||||
desc='Try to add user %r with single-value attribute set via '
|
||||
'option and --addattr' % user1,
|
||||
command=(
|
||||
'user_add', [user1], dict(givenname=u'Test', sn=u'User1',
|
||||
addattr=u'sn=User2')
|
||||
),
|
||||
expected=errors.OnlyOneValueAllowed(attr='sn'),
|
||||
),
|
||||
|
||||
dict(
|
||||
desc='Create %r' % user1,
|
||||
command=(
|
||||
|
Loading…
Reference in New Issue
Block a user