specify type of exceeded limit when warning about truncated search results

API commands inheriting from LDAPSearch should mention which limit was
exceeded in the warning message sent with truncated results.

https://fedorahosted.org/freeipa/ticket/5677

Reviewed-By: Petr Spacek <pspacek@redhat.com>
This commit is contained in:
Martin Babinsky 2016-03-18 09:56:08 +01:00 committed by Martin Basti
parent 1f0959735f
commit 62bb478e11
4 changed files with 14 additions and 11 deletions

View File

@ -338,7 +338,7 @@ class SearchResultTruncated(PublicMessage):
errno = 13017
type = "warning"
format = _("Search result has been truncated to configured search limit.")
format = _("Search result has been truncated: %(reason)s")
class BrokenTrust(PublicMessage):

View File

@ -2104,8 +2104,11 @@ class LDAPSearch(BaseLDAPCommand, crud.Search):
truncated=bool(truncated),
)
if truncated:
add_message(options['version'], result, SearchResultTruncated())
try:
ldap.handle_truncated_result(truncated)
except errors.LimitsExceeded as e:
add_message(options['version'], result, SearchResultTruncated(
reason=e))
return result

View File

@ -525,8 +525,8 @@ class test_old_permission(Declarative):
},
],
messages=({
'message': (u'Search result has been truncated to '
'configured search limit.'),
'message': (u'Search result has been truncated: '
u'Configured size limit exceeded'),
'code': 13017,
'type': u'warning',
'name': u'SearchResultTruncated'
@ -585,8 +585,8 @@ class test_old_permission(Declarative):
api.env.basedn)) and
'ipapermission' in res['objectclass']],
messages=({
'message': (u'Search result has been truncated to '
'configured search limit.'),
'message': (u'Search result has been truncated: '
u'Configured size limit exceeded'),
'code': 13017,
'type': u'warning',
'name': u'SearchResultTruncated'

View File

@ -818,8 +818,8 @@ class test_permission(Declarative):
],
messages=(
{
'message': (u'Search result has been truncated to '
'configured search limit.'),
'message': (u'Search result has been truncated: '
u'Configured size limit exceeded'),
'code': 13017,
'type': u'warning',
'name': u'SearchResultTruncated'
@ -882,8 +882,8 @@ class test_permission(Declarative):
'ipapermission' in res['objectclass']],
messages=(
{
'message': (u'Search result has been truncated to '
'configured search limit.'),
'message': (u'Search result has been truncated: '
u'Configured size limit exceeded'),
'code': 13017,
'type': u'warning',
'name': u'SearchResultTruncated'