Allow renaming of the HBAC rule objects

The recent changes allow HBAC rule objects to be renamed.

https://pagure.io/freeipa/issue/6784

Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Stanislav Laznicka 2017-03-27 08:25:04 +02:00 committed by Pavel Vomacka
parent 8e4408e678
commit 55424c8677
4 changed files with 20 additions and 3 deletions

View File

@ -2163,7 +2163,7 @@ output: ListOfEntries('result')
output: Output('summary', type=[<type 'unicode'>, <type 'NoneType'>])
output: Output('truncated', type=[<type 'bool'>])
command: hbacrule_mod/1
args: 1,16,3
args: 1,17,3
arg: Str('cn', cli_name='name')
option: StrEnum('accessruletype?', autofill=False, cli_name='type', default=u'allow', values=[u'allow', u'deny'])
option: Str('addattr*', cli_name='addattr')
@ -2175,6 +2175,7 @@ option: StrEnum('hostcategory?', autofill=False, cli_name='hostcat', values=[u'a
option: Bool('ipaenabledflag?', autofill=False)
option: Flag('no_members', autofill=True, default=False)
option: Flag('raw', autofill=True, cli_name='raw', default=False)
option: Str('rename?', cli_name='rename')
option: Flag('rights', autofill=True, default=False)
option: StrEnum('servicecategory?', autofill=False, cli_name='servicecat', values=[u'all'])
option: Str('setattr*', cli_name='setattr')

View File

@ -73,8 +73,8 @@ define(IPA_DATA_VERSION, 20100614120000)
# #
########################################################
define(IPA_API_VERSION_MAJOR, 2)
define(IPA_API_VERSION_MINOR, 223)
# Last change: Add domain resolution order to ID views
define(IPA_API_VERSION_MINOR, 224)
# Last change: Add rename option to HBAC rule objects
########################################################

View File

@ -141,6 +141,7 @@ class hbacrule(LDAPObject):
]
uuid_attribute = 'ipauniqueid'
rdn_attribute = 'ipauniqueid'
allow_rename = True
attribute_members = {
'memberuser': ['user', 'group'],
'memberhost': ['host', 'hostgroup'],

View File

@ -34,6 +34,7 @@ class test_hbac(XMLRPC_test):
Test the `hbacrule` plugin.
"""
rule_name = u'testing_rule1234'
rule_renamed = u'mega_testing_rule'
rule_type = u'allow'
rule_type_fail = u'value not allowed'
rule_service = u'ssh'
@ -459,6 +460,20 @@ class test_hbac(XMLRPC_test):
assert_attr_equal(entry, 'cn', self.rule_name)
assert_attr_equal(entry, 'memberservice_hbacsvc', self.test_service)
def test_o_hbacrule_rename(self):
"""
Test renaming an HBAC rule, rename it back afterwards
"""
api.Command['hbacrule_mod'](
self.rule_name, rename=self.rule_renamed
)
entry = api.Command['hbacrule_show'](self.rule_renamed)['result']
assert_attr_equal(entry, 'cn', self.rule_renamed)
# clean up by renaming the rule back
api.Command['hbacrule_mod'](
self.rule_renamed, rename=self.rule_name
)
def test_y_hbacrule_zap_testing_data(self):
"""
Clear data for HBAC plugin testing.