mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-10 15:36:17 -06:00
HBAC plugin inconsistent output
This patch adds a proper summary text to HBAC command which is then printed out in CLI. Now, HBAC plugin output is consistent with other plugins. https://fedorahosted.org/freeipa/ticket/596
This commit is contained in:
parent
a9dc175bc5
commit
e5d57d237b
12
API.txt
12
API.txt
@ -1035,13 +1035,17 @@ output: Output('summary', (<type 'unicode'>, <type 'NoneType'>), 'User-friendly
|
||||
output: Output('result', <type 'dict'>, 'list of deletions that failed')
|
||||
output: Output('value', <type 'unicode'>, "The primary_key value of the entry, e.g. 'jdoe' for a user")
|
||||
command: hbacrule_disable
|
||||
args: 1,0,1
|
||||
args: 1,0,3
|
||||
arg: Str('cn', attribute=True, cli_name='name', label=Gettext('Rule name', domain='ipa', localedir=None), multivalue=False, primary_key=True, query=True, required=True)
|
||||
output: Output('result', None, None)
|
||||
output: Output('summary', (<type 'unicode'>, <type 'NoneType'>), 'User-friendly description of action performed')
|
||||
output: Output('result', <type 'bool'>, 'True means the operation was successful')
|
||||
output: Output('value', <type 'unicode'>, "The primary_key value of the entry, e.g. 'jdoe' for a user")
|
||||
command: hbacrule_enable
|
||||
args: 1,0,1
|
||||
args: 1,0,3
|
||||
arg: Str('cn', attribute=True, cli_name='name', label=Gettext('Rule name', domain='ipa', localedir=None), multivalue=False, primary_key=True, query=True, required=True)
|
||||
output: Output('result', None, None)
|
||||
output: Output('summary', (<type 'unicode'>, <type 'NoneType'>), 'User-friendly description of action performed')
|
||||
output: Output('result', <type 'bool'>, 'True means the operation was successful')
|
||||
output: Output('value', <type 'unicode'>, "The primary_key value of the entry, e.g. 'jdoe' for a user")
|
||||
command: hbacrule_find
|
||||
args: 1,12,4
|
||||
arg: Str('criteria?')
|
||||
|
@ -211,6 +211,9 @@ class hbacrule_add(LDAPCreate):
|
||||
"""
|
||||
Create a new HBAC rule.
|
||||
"""
|
||||
|
||||
msg_summary = _('Added HBAC rule "%(value)s"')
|
||||
|
||||
def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
|
||||
# HBAC rules are enabled by default
|
||||
entry_attrs['ipaenabledflag'] = 'TRUE'
|
||||
@ -224,6 +227,8 @@ class hbacrule_del(LDAPDelete):
|
||||
Delete an HBAC rule.
|
||||
"""
|
||||
|
||||
msg_summary = _('Deleted HBAC rule "%(value)s"')
|
||||
|
||||
api.register(hbacrule_del)
|
||||
|
||||
|
||||
@ -232,6 +237,8 @@ class hbacrule_mod(LDAPUpdate):
|
||||
Modify an HBAC rule.
|
||||
"""
|
||||
|
||||
msg_summary = _('Modified HBAC rule "%(value)s"')
|
||||
|
||||
def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
|
||||
try:
|
||||
(dn, entry_attrs) = ldap.get_entry(dn, attrs_list)
|
||||
@ -256,6 +263,10 @@ class hbacrule_find(LDAPSearch):
|
||||
Search for HBAC rules.
|
||||
"""
|
||||
|
||||
msg_summary = ngettext(
|
||||
'%(count)d HBAC rule matched', '%(count)d HBAC rules matched', 0
|
||||
)
|
||||
|
||||
api.register(hbacrule_find)
|
||||
|
||||
|
||||
@ -271,6 +282,10 @@ class hbacrule_enable(LDAPQuery):
|
||||
"""
|
||||
Enable an HBAC rule.
|
||||
"""
|
||||
|
||||
msg_summary = _('Enabled HBAC rule "%(value)s"')
|
||||
has_output = output.standard_value
|
||||
|
||||
def execute(self, cn):
|
||||
ldap = self.obj.backend
|
||||
|
||||
@ -284,11 +299,10 @@ class hbacrule_enable(LDAPQuery):
|
||||
except errors.NotFound:
|
||||
self.obj.handle_not_found(cn)
|
||||
|
||||
return dict(result=True)
|
||||
|
||||
def output_for_cli(self, textui, result, cn):
|
||||
textui.print_name(self.name)
|
||||
textui.print_dashed('Enabled HBAC rule "%s".' % cn)
|
||||
return dict(
|
||||
result=True,
|
||||
value=cn,
|
||||
)
|
||||
|
||||
api.register(hbacrule_enable)
|
||||
|
||||
@ -297,6 +311,10 @@ class hbacrule_disable(LDAPQuery):
|
||||
"""
|
||||
Disable an HBAC rule.
|
||||
"""
|
||||
|
||||
msg_summary = _('Disabled HBAC rule "%(value)s"')
|
||||
has_output = output.standard_value
|
||||
|
||||
def execute(self, cn):
|
||||
ldap = self.obj.backend
|
||||
|
||||
@ -310,11 +328,10 @@ class hbacrule_disable(LDAPQuery):
|
||||
except errors.NotFound:
|
||||
self.obj.handle_not_found(cn)
|
||||
|
||||
return dict(result=True)
|
||||
|
||||
def output_for_cli(self, textui, result, cn):
|
||||
textui.print_name(self.name)
|
||||
textui.print_dashed('Disabled HBAC rule "%s".' % cn)
|
||||
return dict(
|
||||
result=True,
|
||||
value=cn,
|
||||
)
|
||||
|
||||
api.register(hbacrule_disable)
|
||||
|
||||
|
@ -64,14 +64,14 @@ class hbacsvc(LDAPObject):
|
||||
Str('cn',
|
||||
cli_name='service',
|
||||
label=_('Service name'),
|
||||
doc=_('HBAC Service'),
|
||||
doc=_('HBAC service'),
|
||||
primary_key=True,
|
||||
normalizer=lambda value: value.lower(),
|
||||
),
|
||||
Str('description?',
|
||||
cli_name='desc',
|
||||
label=_('Description'),
|
||||
doc=_('Description of service'),
|
||||
doc=_('HBAC service description'),
|
||||
),
|
||||
)
|
||||
|
||||
@ -82,7 +82,7 @@ class hbacsvc_add(LDAPCreate):
|
||||
"""
|
||||
Add a new HBAC service.
|
||||
"""
|
||||
msg_summary = _('Added service "%(value)s"')
|
||||
msg_summary = _('Added HBAC service "%(value)s"')
|
||||
|
||||
api.register(hbacsvc_add)
|
||||
|
||||
@ -91,7 +91,7 @@ class hbacsvc_del(LDAPDelete):
|
||||
"""
|
||||
Delete an existing HBAC service.
|
||||
"""
|
||||
msg_summary = _('Deleted service "%(value)s"')
|
||||
msg_summary = _('Deleted HBAC service "%(value)s"')
|
||||
|
||||
api.register(hbacsvc_del)
|
||||
|
||||
@ -101,6 +101,8 @@ class hbacsvc_mod(LDAPUpdate):
|
||||
Modify an HBAC service.
|
||||
"""
|
||||
|
||||
msg_summary = _('Modified HBAC service "%(value)s"')
|
||||
|
||||
api.register(hbacsvc_mod)
|
||||
|
||||
|
||||
@ -109,6 +111,10 @@ class hbacsvc_find(LDAPSearch):
|
||||
Search for HBAC services.
|
||||
"""
|
||||
|
||||
msg_summary = ngettext(
|
||||
'%(count)d HBAC service matched', '%(count)d HBAC services matched', 0
|
||||
)
|
||||
|
||||
api.register(hbacsvc_find)
|
||||
|
||||
|
||||
|
@ -61,7 +61,7 @@ class hbacsvcgroup(LDAPObject):
|
||||
'member': ['hbacsvc'],
|
||||
}
|
||||
|
||||
label = _('HBAC Service Groups')
|
||||
label = _('HBAC service Groups')
|
||||
|
||||
takes_params = (
|
||||
Str('cn',
|
||||
@ -84,7 +84,7 @@ class hbacsvcgroup_add(LDAPCreate):
|
||||
"""
|
||||
Add a new HBAC services group.
|
||||
"""
|
||||
msg_summary = _('Added HBAC Service group "%(value)s"')
|
||||
msg_summary = _('Added HBAC service group "%(value)s"')
|
||||
|
||||
api.register(hbacsvcgroup_add)
|
||||
|
||||
@ -93,7 +93,7 @@ class hbacsvcgroup_del(LDAPDelete):
|
||||
"""
|
||||
Delete an HBAC services group.
|
||||
"""
|
||||
msg_summary = _('Deleted HBAC Service group "%(value)s"')
|
||||
msg_summary = _('Deleted HBAC service group "%(value)s"')
|
||||
|
||||
api.register(hbacsvcgroup_del)
|
||||
|
||||
@ -102,7 +102,7 @@ class hbacsvcgroup_mod(LDAPUpdate):
|
||||
"""
|
||||
Modify an HBAC services group.
|
||||
"""
|
||||
msg_summary = _('Modified HBAC Service group "%(value)s"')
|
||||
msg_summary = _('Modified HBAC service group "%(value)s"')
|
||||
|
||||
api.register(hbacsvcgroup_mod)
|
||||
|
||||
@ -112,7 +112,7 @@ class hbacsvcgroup_find(LDAPSearch):
|
||||
Search for an HBAC services group.
|
||||
"""
|
||||
msg_summary = ngettext(
|
||||
'%(count)d group matched', '%(count)d groups matched', 0
|
||||
'%(count)d HBAC service group matched', '%(count)d HBAC service groups matched', 0
|
||||
)
|
||||
|
||||
api.register(hbacsvcgroup_find)
|
||||
|
@ -71,7 +71,7 @@ class test_hbacsvcgroup(Declarative):
|
||||
),
|
||||
expected=dict(
|
||||
value=hbacsvcgroup1,
|
||||
summary=u'Added HBAC Service group "testhbacsvcgroup1"',
|
||||
summary=u'Added HBAC service group "testhbacsvcgroup1"',
|
||||
result=dict(
|
||||
dn=dn1,
|
||||
cn=[hbacsvcgroup1],
|
||||
@ -101,7 +101,7 @@ class test_hbacsvcgroup(Declarative):
|
||||
),
|
||||
expected=dict(
|
||||
value=hbacsvc1,
|
||||
summary=u'Added service "%s"' % hbacsvc1,
|
||||
summary=u'Added HBAC service "%s"' % hbacsvc1,
|
||||
result=dict(
|
||||
dn=hbacsvc_dn1,
|
||||
cn=[hbacsvc1],
|
||||
@ -157,7 +157,7 @@ class test_hbacsvcgroup(Declarative):
|
||||
expected=dict(
|
||||
count=1,
|
||||
truncated=False,
|
||||
summary=u'1 group matched',
|
||||
summary=u'1 HBAC service group matched',
|
||||
result=[
|
||||
{
|
||||
'dn': dn1,
|
||||
@ -177,7 +177,7 @@ class test_hbacsvcgroup(Declarative):
|
||||
),
|
||||
expected=dict(
|
||||
value=hbacsvcgroup1,
|
||||
summary=u'Modified HBAC Service group "testhbacsvcgroup1"',
|
||||
summary=u'Modified HBAC service group "testhbacsvcgroup1"',
|
||||
result=dict(
|
||||
cn=[hbacsvcgroup1],
|
||||
description=[u'Updated hbacsvcgroup 1'],
|
||||
@ -229,7 +229,7 @@ class test_hbacsvcgroup(Declarative):
|
||||
command=('hbacsvcgroup_del', [hbacsvcgroup1], {}),
|
||||
expected=dict(
|
||||
value=hbacsvcgroup1,
|
||||
summary=u'Deleted HBAC Service group "testhbacsvcgroup1"',
|
||||
summary=u'Deleted HBAC service group "testhbacsvcgroup1"',
|
||||
result=dict(failed=u''),
|
||||
),
|
||||
),
|
||||
@ -240,7 +240,7 @@ class test_hbacsvcgroup(Declarative):
|
||||
command=('hbacsvc_del', [hbacsvc1], {}),
|
||||
expected=dict(
|
||||
value=hbacsvc1,
|
||||
summary=u'Deleted service "%s"' % hbacsvc1,
|
||||
summary=u'Deleted HBAC service "%s"' % hbacsvc1,
|
||||
result=dict(failed=u''),
|
||||
),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user