Allow renaming of the sudorule objects

The recent changes allow the sudorule objects to be renamed.

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

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:26:03 +02:00
committed by Pavel Vomacka
parent 55424c8677
commit 8c1409155e
4 changed files with 18 additions and 2 deletions

View File

@@ -5403,7 +5403,7 @@ output: ListOfEntries('result')
output: Output('summary', type=[<type 'unicode'>, <type 'NoneType'>])
output: Output('truncated', type=[<type 'bool'>])
command: sudorule_mod/1
args: 1,20,3
args: 1,21,3
arg: Str('cn', cli_name='sudorule_name')
option: Str('addattr*', cli_name='addattr')
option: Flag('all', autofill=True, cli_name='all', default=False)
@@ -5420,6 +5420,7 @@ option: StrEnum('ipasudorunasgroupcategory?', autofill=False, cli_name='runasgro
option: StrEnum('ipasudorunasusercategory?', autofill=False, cli_name='runasusercat', values=[u'all'])
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: Str('setattr*', cli_name='setattr')
option: Int('sudoorder?', autofill=False, cli_name='order', default=0)

View File

@@ -74,7 +74,7 @@ define(IPA_DATA_VERSION, 20100614120000)
########################################################
define(IPA_API_VERSION_MAJOR, 2)
define(IPA_API_VERSION_MINOR, 224)
# Last change: Add rename option to HBAC rule objects
# Last change: Add rename option to sudorule objects
########################################################

View File

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

View File

@@ -42,6 +42,7 @@ class test_sudorule(XMLRPC_test):
"""
rule_name = u'testing_sudorule1'
rule_name2 = u'testing_sudorule2'
rule_renamed = u'testing_mega_sudorule'
rule_command = u'/usr/bin/testsudocmd1'
rule_desc = u'description'
rule_desc_mod = u'description modified'
@@ -782,6 +783,19 @@ class test_sudorule(XMLRPC_test):
api.Command['sudorule_mod'](self.rule_name, sudoorder=None)
api.Command['sudorule_mod'](self.rule_name2, sudoorder=None)
def test_l_1_sudorule_rename(self):
"""
Test renaming an HBAC rule, rename it back afterwards
"""
api.Command['sudorule_mod'](
self.rule_name, rename=self.rule_renamed
)
entry = api.Command['sudorule_show'](self.rule_renamed)['result']
assert_attr_equal(entry, 'cn', self.rule_renamed)
# clean up by renaming the rule back
api.Command['sudorule_mod'](
self.rule_renamed, rename=self.rule_name
)
def test_m_sudorule_del(self):
"""