mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
schema: do not validate unrequested params in command_defaults
Request specific params when getting the defaults instead of getting defaults for all params and filtering the result. This fixes command_defaults failing with validation errors on unrequested params. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
This commit is contained in:
parent
4660bb7ff0
commit
9c19dd3506
@ -670,7 +670,7 @@ class Command(HasParam):
|
||||
if kw.get(param.name, None) is None:
|
||||
continue
|
||||
|
||||
def get_default(self, **kw):
|
||||
def get_default(self, _params=None, **kw):
|
||||
"""
|
||||
Return a dictionary of defaults for all missing required values.
|
||||
|
||||
@ -687,8 +687,10 @@ class Command(HasParam):
|
||||
>>> c.get_default(color=u'Yellow')
|
||||
{}
|
||||
"""
|
||||
params = [p.name for p in self.params() if p.name not in kw and (p.required or p.autofill)]
|
||||
return dict(self.__get_default_iter(params, kw))
|
||||
if _params is None:
|
||||
_params = [p.name for p in self.params()
|
||||
if p.name not in kw and (p.required or p.autofill)]
|
||||
return dict(self.__get_default_iter(_params, kw))
|
||||
|
||||
def get_default_of(self, _name, **kw):
|
||||
"""
|
||||
|
@ -229,8 +229,7 @@ class command_defaults(PKQuery):
|
||||
raise errors.ConversionError(name=name,
|
||||
error=_("must be a dictionary"))
|
||||
|
||||
result = command.get_default(**kw)
|
||||
result = {n: v for n, v in result.items() if n in params}
|
||||
result = command.get_default(params, **kw)
|
||||
|
||||
return dict(result=result)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user