pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0029-Allow-renaming-of-the-HBAC-rule-objects.patch

ac7d03
From 496255286bdf83c11deeba08755de56e639de000 Mon Sep 17 00:00:00 2001
ac7d03
From: Stanislav Laznicka <slaznick@redhat.com>
ac7d03
Date: Mon, 27 Mar 2017 08:25:04 +0200
ac7d03
Subject: [PATCH] Allow renaming of the HBAC rule objects
ac7d03
ac7d03
The recent changes allow HBAC rule objects to be renamed.
ac7d03
ac7d03
https://pagure.io/freeipa/issue/6784
ac7d03
ac7d03
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
ac7d03
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
ac7d03
Reviewed-By: Martin Basti <mbasti@redhat.com>
ac7d03
---
ac7d03
 API.txt                                  |  3 ++-
ac7d03
 VERSION.m4                               |  4 ++--
ac7d03
 ipaserver/plugins/hbacrule.py            |  1 +
ac7d03
 ipatests/test_xmlrpc/test_hbac_plugin.py | 15 +++++++++++++++
ac7d03
 4 files changed, 20 insertions(+), 3 deletions(-)
ac7d03
ac7d03
diff --git a/API.txt b/API.txt
ac7d03
index f0bd1b6495854decf4470efdcf1f2d915ce71c52..2a63c983a343b07ec7928bc774c6443a84b7c64c 100644
ac7d03
--- a/API.txt
ac7d03
+++ b/API.txt
ac7d03
@@ -2163,7 +2163,7 @@ output: ListOfEntries('result')
ac7d03
 output: Output('summary', type=[<type 'unicode'>, <type 'NoneType'>])
ac7d03
 output: Output('truncated', type=[<type 'bool'>])
ac7d03
 command: hbacrule_mod/1
ac7d03
-args: 1,16,3
ac7d03
+args: 1,17,3
ac7d03
 arg: Str('cn', cli_name='name')
ac7d03
 option: StrEnum('accessruletype?', autofill=False, cli_name='type', default=u'allow', values=[u'allow', u'deny'])
ac7d03
 option: Str('addattr*', cli_name='addattr')
ac7d03
@@ -2175,6 +2175,7 @@ option: StrEnum('hostcategory?', autofill=False, cli_name='hostcat', values=[u'a
ac7d03
 option: Bool('ipaenabledflag?', autofill=False)
ac7d03
 option: Flag('no_members', autofill=True, default=False)
ac7d03
 option: Flag('raw', autofill=True, cli_name='raw', default=False)
ac7d03
+option: Str('rename?', cli_name='rename')
ac7d03
 option: Flag('rights', autofill=True, default=False)
ac7d03
 option: StrEnum('servicecategory?', autofill=False, cli_name='servicecat', values=[u'all'])
ac7d03
 option: Str('setattr*', cli_name='setattr')
ac7d03
diff --git a/VERSION.m4 b/VERSION.m4
ac7d03
index 743f2dbe0d05126f11c67574c5a9b712cb1f112d..bbb5212e5b8cd9604b6ec90d4a0bd4c3276b1856 100644
ac7d03
--- a/VERSION.m4
ac7d03
+++ b/VERSION.m4
ac7d03
@@ -73,8 +73,8 @@ define(IPA_DATA_VERSION, 20100614120000)
ac7d03
 #                                                      #
ac7d03
 ########################################################
ac7d03
 define(IPA_API_VERSION_MAJOR, 2)
ac7d03
-define(IPA_API_VERSION_MINOR, 223)
ac7d03
-# Last change: Add domain resolution order to ID views
ac7d03
+define(IPA_API_VERSION_MINOR, 224)
ac7d03
+# Last change: Add rename option to HBAC rule objects
ac7d03
 
ac7d03
 
ac7d03
 ########################################################
ac7d03
diff --git a/ipaserver/plugins/hbacrule.py b/ipaserver/plugins/hbacrule.py
ac7d03
index 60e5e606fff6d2ffb93db608328c5987b91d1fa8..2495702e87accaf60eb38dae0fb122ac0764452f 100644
ac7d03
--- a/ipaserver/plugins/hbacrule.py
ac7d03
+++ b/ipaserver/plugins/hbacrule.py
ac7d03
@@ -141,6 +141,7 @@ class hbacrule(LDAPObject):
ac7d03
     ]
ac7d03
     uuid_attribute = 'ipauniqueid'
ac7d03
     rdn_attribute = 'ipauniqueid'
ac7d03
+    allow_rename = True
ac7d03
     attribute_members = {
ac7d03
         'memberuser': ['user', 'group'],
ac7d03
         'memberhost': ['host', 'hostgroup'],
ac7d03
diff --git a/ipatests/test_xmlrpc/test_hbac_plugin.py b/ipatests/test_xmlrpc/test_hbac_plugin.py
ac7d03
index 75c15c5abe472d975f0c2bc78eb9dd5fda8af45e..b495fe3341f8d0682f65b4fc1d408734d130a7cd 100644
ac7d03
--- a/ipatests/test_xmlrpc/test_hbac_plugin.py
ac7d03
+++ b/ipatests/test_xmlrpc/test_hbac_plugin.py
ac7d03
@@ -34,6 +34,7 @@ class test_hbac(XMLRPC_test):
ac7d03
     Test the `hbacrule` plugin.
ac7d03
     """
ac7d03
     rule_name = u'testing_rule1234'
ac7d03
+    rule_renamed = u'mega_testing_rule'
ac7d03
     rule_type = u'allow'
ac7d03
     rule_type_fail = u'value not allowed'
ac7d03
     rule_service = u'ssh'
ac7d03
@@ -459,6 +460,20 @@ class test_hbac(XMLRPC_test):
ac7d03
         assert_attr_equal(entry, 'cn', self.rule_name)
ac7d03
         assert_attr_equal(entry, 'memberservice_hbacsvc', self.test_service)
ac7d03
 
ac7d03
+    def test_o_hbacrule_rename(self):
ac7d03
+        """
ac7d03
+        Test renaming an HBAC rule, rename it back afterwards
ac7d03
+        """
ac7d03
+        api.Command['hbacrule_mod'](
ac7d03
+            self.rule_name, rename=self.rule_renamed
ac7d03
+        )
ac7d03
+        entry = api.Command['hbacrule_show'](self.rule_renamed)['result']
ac7d03
+        assert_attr_equal(entry, 'cn', self.rule_renamed)
ac7d03
+        # clean up by renaming the rule back
ac7d03
+        api.Command['hbacrule_mod'](
ac7d03
+            self.rule_renamed, rename=self.rule_name
ac7d03
+        )
ac7d03
+
ac7d03
     def test_y_hbacrule_zap_testing_data(self):
ac7d03
         """
ac7d03
         Clear data for HBAC plugin testing.
ac7d03
-- 
ac7d03
2.12.1
ac7d03