URL: https://github.com/freeipa/freeipa/pull/3674 Author: serg-cymbaluk Title: #3674: [Backport][ipa-4-8] WebUI: Fix changing category on HBAC/Sudo/etc Rule pages Action: opened
PR body: """ This PR was opened automatically because PR #3619 was pushed to master and backport to ipa-4-8 is required. """ To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/3674/head:pr3674 git checkout pr3674
From 120b72c38c2a70e16bb3b844d2fdcbecae1764be Mon Sep 17 00:00:00 2001 From: Serhii Tsymbaliuk <[email protected]> Date: Wed, 4 Sep 2019 08:30:13 +0200 Subject: [PATCH] WebUI: Fix changing category on HBAC/Sudo/etc Rule pages No object can be added to a rule when object category is 'all'. So while editing rule there is needed to save actual category value before adding related objects. Ticket: https://pagure.io/freeipa/issue/7961 Signed-off-by: Serhii Tsymbaliuk <[email protected]> --- install/ui/src/freeipa/association.js | 2 + install/ui/src/freeipa/rule.js | 50 ++++++++++++++++++++++ ipatests/test_webui/test_selinuxusermap.py | 3 +- 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/install/ui/src/freeipa/association.js b/install/ui/src/freeipa/association.js index 8038e2d41d..f10ccb2a5c 100644 --- a/install/ui/src/freeipa/association.js +++ b/install/ui/src/freeipa/association.js @@ -668,6 +668,7 @@ IPA.association_table_widget = function (spec) { dialog.get_selected_values(), function(data) { that.refresh(); + that.facet.refresh(); dialog.close(); var succeeded = IPA.get_succeeded(data); @@ -676,6 +677,7 @@ IPA.association_table_widget = function (spec) { }, function() { that.refresh(); + that.facet.refresh(); dialog.close(); } ); diff --git a/install/ui/src/freeipa/rule.js b/install/ui/src/freeipa/rule.js index 7c7e6f1c1a..f9cbedc4c9 100644 --- a/install/ui/src/freeipa/rule.js +++ b/install/ui/src/freeipa/rule.js @@ -35,6 +35,14 @@ IPA.rule_details_widget = function(spec) { spec = spec || {}; + // Link association table with category option. + for (var i=0; i<spec.widgets.length; i++) { + var widget = spec.widgets[i]; + if (widget.$type == 'rule_association_table') { + widget.category_name = spec.radio_name; + } + } + var that = IPA.composite_widget(spec); that.radio_name = spec.radio_name; @@ -126,6 +134,7 @@ IPA.rule_association_table_widget = function(spec) { var that = IPA.association_table_widget(spec); that.external = spec.external; + that.category_name = spec.category_name; that.setup_column = function(column, div, record) { var suppress_link = false; @@ -177,6 +186,47 @@ IPA.rule_association_table_widget = function(spec) { }); }; + that.add = function(values, on_success, on_error) { + + var pkey = that.facet.get_pkey(); + + var batch = rpc.batch_command({ + name: 'add_association', + on_success: on_success, + on_error: on_error + }); + + if (that.category_name) { + var category_field = that.facet.get_field(that.category_name); + + // Save category option if the field value is changed. + if (category_field.dirty) { + var options = {}; + options[that.category_name] = category_field.value[0]; + + command = rpc.command({ + entity: that.entity.name, + method: 'mod', + args: [pkey], + options: options + }); + batch.add_command(command); + } + } + + var command = rpc.command({ + entity: that.entity.name, + method: that.add_method, + args: [pkey] + }); + + that.join_additional_option(command); + that.handle_entity_option(command, values); + batch.add_command(command); + + batch.execute(); + }; + return that; }; diff --git a/ipatests/test_webui/test_selinuxusermap.py b/ipatests/test_webui/test_selinuxusermap.py index ac27750fa1..038204e9d4 100644 --- a/ipatests/test_webui/test_selinuxusermap.py +++ b/ipatests/test_webui/test_selinuxusermap.py @@ -53,6 +53,7 @@ HBAC_DEL_ERR = ('{} cannot be deleted because SELinux User Map {} requires ' 'it') HBAC_MEMBER_ERR = 'HBAC rule and local members cannot both be set' +BATCH_ERR = 'Some operations failed.' @pytest.mark.tier1 @@ -185,7 +186,7 @@ def test_misc(self): self.navigate_to_record(selinuxmap.PKEY, entity=selinuxmap.ENTITY) self.add_table_associations('memberuser_user', ['admin'], negative=True) - self.assert_last_error_dialog(HBAC_MEMBER_ERR) + self.assert_last_error_dialog(BATCH_ERR) self.close_all_dialogs() # test adding HBAC rule together with user (should FAIL)
_______________________________________________ FreeIPA-devel mailing list -- [email protected] To unsubscribe send an email to [email protected] Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/[email protected]
