Blame SOURCES/0001-WebUI-Fix-IPA-Error-3007-RequirmentError-while-addin_rhbz#1757045.patch

5144c6
From c2ba333b9681d008d9c528a79dbdd76ce11a3ecd Mon Sep 17 00:00:00 2001
5144c6
From: Serhii Tsymbaliuk <stsymbal@redhat.com>
5144c6
Date: Thu, 28 May 2020 08:47:49 +0200
5144c6
Subject: [PATCH 01/22] WebUI: Fix "IPA Error 3007: RequirmentError" while
5144c6
 adding idoverrideuser association
5144c6
5144c6
Add builder for association adder dialog which allows to override behavior of the component.
5144c6
Replace default implementation with a custom one for idoverrideuser.
5144c6
Replace text filter with 'ID view' select box in the idoverrideuser dialog.
5144c6
5144c6
Ticket: https://pagure.io/freeipa/issue/8335
5144c6
5144c6
Signed-off-by: Serhii Tsymbaliuk <stsymbal@redhat.com>
5144c6
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
5144c6
---
5144c6
 install/ui/src/freeipa/association.js | 13 ++++-
5144c6
 install/ui/src/freeipa/dialog.js      | 73 ++++++++++++++++-----------
5144c6
 install/ui/src/freeipa/group.js       | 14 +++++
5144c6
 install/ui/src/freeipa/idviews.js     | 58 +++++++++++++++++++++
5144c6
 ipaserver/plugins/internal.py         |  6 +++
5144c6
 5 files changed, 133 insertions(+), 31 deletions(-)
5144c6
5144c6
diff --git a/install/ui/src/freeipa/association.js b/install/ui/src/freeipa/association.js
5144c6
index f10ccb2a5..b083a79f9 100644
5144c6
--- a/install/ui/src/freeipa/association.js
5144c6
+++ b/install/ui/src/freeipa/association.js
5144c6
@@ -25,6 +25,7 @@
5144c6
 define([
5144c6
     'dojo/_base/lang',
5144c6
     'dojo/Deferred',
5144c6
+    './builder',
5144c6
     './metadata',
5144c6
     './ipa',
5144c6
     './jquery',
5144c6
@@ -38,7 +39,7 @@ define([
5144c6
     './facet',
5144c6
     './search',
5144c6
     './dialog'],
5144c6
-        function(lang, Deferred, metadata_provider, IPA, $, metadata,
5144c6
+        function(lang, Deferred, builder, metadata_provider, IPA, $, metadata,
5144c6
                  navigation, phases, reg, rpc, su, text) {
5144c6
 
5144c6
 /**
5144c6
@@ -1209,7 +1210,8 @@ exp.association_facet = IPA.association_facet = function (spec, no_init) {
5144c6
 
5144c6
         var pkeys = that.data.result.result[that.get_attribute_name()];
5144c6
 
5144c6
-        var dialog = IPA.association_adder_dialog({
5144c6
+        var dialog = builder.build('association_adder_dialog', {
5144c6
+            $type: that.other_entity.name,
5144c6
             title: title,
5144c6
             entity: that.entity,
5144c6
             pkey: pkey,
5144c6
@@ -1675,6 +1677,13 @@ IPA.attr_read_only_evaluator = function(spec) {
5144c6
     return that;
5144c6
 };
5144c6
 
5144c6
+// Create a registry for adder dialogs where key is name of 'other entity'.
5144c6
+// It allows to override dialogs for some specific cases of association
5144c6
+// creation.
5144c6
+var dialog_builder = builder.get('association_adder_dialog');
5144c6
+dialog_builder.factory = IPA.association_adder_dialog;
5144c6
+reg.set('association_adder_dialog', dialog_builder.registry);
5144c6
+
5144c6
 phases.on('registration', function() {
5144c6
     var w = reg.widget;
5144c6
     var f = reg.field;
5144c6
diff --git a/install/ui/src/freeipa/dialog.js b/install/ui/src/freeipa/dialog.js
5144c6
index c153120df..d67d63b6d 100644
5144c6
--- a/install/ui/src/freeipa/dialog.js
5144c6
+++ b/install/ui/src/freeipa/dialog.js
5144c6
@@ -919,35 +919,7 @@ IPA.adder_dialog = function(spec) {
5144c6
             'class': 'input-group col-md-12 adder-dialog-top'
5144c6
         }).appendTo(container);
5144c6
 
5144c6
-        var filter_placeholder = text.get('@i18n:association.filter_placeholder');
5144c6
-        filter_placeholder = filter_placeholder.replace('${other_entity}',
5144c6
-            that.other_entity.metadata.label);
5144c6
-
5144c6
-        that.filter_field = $('<input/>', {
5144c6
-            type: 'text',
5144c6
-            name: 'filter',
5144c6
-            'class': 'form-control',
5144c6
-            'placeholder': filter_placeholder,
5144c6
-            keyup: function(event) {
5144c6
-                if (event.keyCode === keys.ENTER) {
5144c6
-                    that.search();
5144c6
-                    return false;
5144c6
-                }
5144c6
-            }
5144c6
-        }).appendTo(input_group);
5144c6
-
5144c6
-        var input_group_btn = $('
', {
5144c6
-            'class': 'input-group-btn'
5144c6
-        }).appendTo(input_group);
5144c6
-
5144c6
-        that.find_button = IPA.button({
5144c6
-            name: 'find',
5144c6
-            label: '@i18n:buttons.filter',
5144c6
-            click: function() {
5144c6
-                that.search();
5144c6
-                return false;
5144c6
-            }
5144c6
-        }).appendTo(input_group_btn);
5144c6
+        that.filter_field = that.get_filter_field(input_group);
5144c6
 
5144c6
         var row = $('
', { 'class': 'row adder-dialog-main'}).appendTo(container);
5144c6
         //
5144c6
@@ -1132,6 +1104,49 @@ IPA.adder_dialog = function(spec) {
5144c6
         return that.filter_field.val();
5144c6
     };
5144c6
 
5144c6
+    /**
5144c6
+     * Return field for filtering available items
5144c6
+     *
5144c6
+     * Default implementation returns text input + "Filter" button.
5144c6
+     * It can be overridden.
5144c6
+     *
5144c6
+     * @param {HTMLElement} input_group - container for a filter field
5144c6
+     * @return {HTMLElement}
5144c6
+     */
5144c6
+    that.get_filter_field = function(input_group) {
5144c6
+        var filter_placeholder = text.get(
5144c6
+            '@i18n:association.filter_placeholder'
5144c6
+        ).replace('${other_entity}', that.other_entity.metadata.label);
5144c6
+
5144c6
+        var filter_field = $('<input/>', {
5144c6
+            type: 'text',
5144c6
+            name: 'filter',
5144c6
+            'class': 'form-control',
5144c6
+            'placeholder': filter_placeholder,
5144c6
+            keyup: function(event) {
5144c6
+                if (event.keyCode === keys.ENTER) {
5144c6
+                    that.search();
5144c6
+                    return false;
5144c6
+                }
5144c6
+            }
5144c6
+        }).appendTo(input_group);
5144c6
+
5144c6
+        var input_group_btn = $('
', {
5144c6
+            'class': 'input-group-btn'
5144c6
+        }).appendTo(input_group);
5144c6
+
5144c6
+        that.find_button = IPA.button({
5144c6
+            name: 'find',
5144c6
+            label: '@i18n:buttons.filter',
5144c6
+            click: function() {
5144c6
+                that.search();
5144c6
+                return false;
5144c6
+            }
5144c6
+        }).appendTo(input_group_btn);
5144c6
+
5144c6
+        return filter_field;
5144c6
+    };
5144c6
+
5144c6
     /**
5144c6
      * Clear rows in available table
5144c6
      */
5144c6
diff --git a/install/ui/src/freeipa/group.js b/install/ui/src/freeipa/group.js
5144c6
index e46d8c7e3..2984bd4b2 100644
5144c6
--- a/install/ui/src/freeipa/group.js
5144c6
+++ b/install/ui/src/freeipa/group.js
5144c6
@@ -205,6 +205,20 @@ return {
5144c6
             add_title: '@i18n:objects.group.add_into_sudo',
5144c6
             remove_method: 'remove_user',
5144c6
             remove_title: '@i18n:objects.group.remove_from_sudo'
5144c6
+        },
5144c6
+        {
5144c6
+            $type: 'association',
5144c6
+            name: 'member_idoverrideuser',
5144c6
+            associator: IPA.serial_associator,
5144c6
+            add_title: '@i18n:objects.group.add_idoverride_user',
5144c6
+            remove_title: '@i18n:objects.group.remove_idoverride_users',
5144c6
+            columns: [
5144c6
+                {
5144c6
+                    name: 'ipaanchoruuid',
5144c6
+                    label: '@i18n:objects.idoverrideuser.anchor_label',
5144c6
+                    link: false
5144c6
+                }
5144c6
+            ]
5144c6
         }
5144c6
     ],
5144c6
     standard_association_facets: true,
5144c6
diff --git a/install/ui/src/freeipa/idviews.js b/install/ui/src/freeipa/idviews.js
5144c6
index 35dc998c8..a4fca6205 100644
5144c6
--- a/install/ui/src/freeipa/idviews.js
5144c6
+++ b/install/ui/src/freeipa/idviews.js
5144c6
@@ -966,6 +966,58 @@ idviews.unapply_action = function(spec) {
5144c6
     return that;
5144c6
 };
5144c6
 
5144c6
+idviews.idoverrideuser_adder_dialog = function(spec) {
5144c6
+
5144c6
+    spec = spec || {};
5144c6
+
5144c6
+    var that = IPA.association_adder_dialog(spec);
5144c6
+
5144c6
+    that.base_search = that.search;
5144c6
+
5144c6
+    that.search = function() {
5144c6
+        // Search for users only in case a ID view is selected
5144c6
+        if (that.get_filter()) {
5144c6
+            that.base_search();
5144c6
+        }
5144c6
+    };
5144c6
+
5144c6
+    /**
5144c6
+     * Replace default text filter with a select box for filtering by ID view
5144c6
+     */
5144c6
+    that.get_filter_field = function(input_group) {
5144c6
+
5144c6
+        var filter_field = $('<select/>', {
5144c6
+            name: 'filter',
5144c6
+            'class': 'form-control',
5144c6
+            change: function(event) {
5144c6
+                that.search();
5144c6
+            }
5144c6
+        }).appendTo(input_group);
5144c6
+
5144c6
+        rpc.command({
5144c6
+            entity: 'idview',
5144c6
+            method: 'find',
5144c6
+            on_success: function(data) {
5144c6
+                var results = data.result;
5144c6
+
5144c6
+                for (var i=0; i
5144c6
+                    var result = results.result[i];
5144c6
+                    $('<option/>', {
5144c6
+                        text: result.cn[0],
5144c6
+                        value: result.cn[0]
5144c6
+                    }).appendTo(filter_field);
5144c6
+                }
5144c6
+
5144c6
+                that.search();
5144c6
+            }
5144c6
+        }).execute();
5144c6
+
5144c6
+        return filter_field;
5144c6
+    };
5144c6
+
5144c6
+    return that;
5144c6
+};
5144c6
+
5144c6
 /**
5144c6
  * ID View entity specification object
5144c6
  * @member idviews
5144c6
@@ -993,6 +1045,7 @@ idviews.register = function() {
5144c6
     var f = reg.facet;
5144c6
     var a = reg.action;
5144c6
     var w = reg.widget;
5144c6
+    var ad = reg.association_adder_dialog;
5144c6
 
5144c6
     e.register({type: 'idview', spec: idviews.spec});
5144c6
     e.register({
5144c6
@@ -1012,6 +1065,11 @@ idviews.register = function() {
5144c6
 
5144c6
     w.register('idviews_certs', idviews.idviews_certs_widget);
5144c6
     w.register('cert_textarea', idviews.cert_textarea_widget);
5144c6
+
5144c6
+    ad.register({
5144c6
+        type: 'idoverrideuser',
5144c6
+        factory: idviews.idoverrideuser_adder_dialog
5144c6
+    });
5144c6
 };
5144c6
 
5144c6
 phases.on('registration', idviews.register);
5144c6
diff --git a/ipaserver/plugins/internal.py b/ipaserver/plugins/internal.py
5144c6
index 5f2b1fdc2..7622e65dc 100644
5144c6
--- a/ipaserver/plugins/internal.py
5144c6
+++ b/ipaserver/plugins/internal.py
5144c6
@@ -835,6 +835,9 @@ class i18n_messages(Command):
5144c6
                     "Remove users from member managers for user group "
5144c6
                     "'${primary_key}'"
5144c6
                 ),
5144c6
+                "add_idoverride_user": _(
5144c6
+                    "Add user ID override into user group '${primary_key}'"
5144c6
+                ),
5144c6
                 "details": _("Group Settings"),
5144c6
                 "external": _("External"),
5144c6
                 "groups": _("Groups"),
5144c6
@@ -868,6 +871,9 @@ class i18n_messages(Command):
5144c6
                 "remove_users": _(
5144c6
                     "Remove users from user group '${primary_key}'"
5144c6
                 ),
5144c6
+                "remove_idoverride_users": _(
5144c6
+                    "Remove user ID overrides from user group '${primary_key}'"
5144c6
+                ),
5144c6
                 "type": _("Group Type"),
5144c6
                 "user_groups": _("User Groups"),
5144c6
             },
5144c6
-- 
5144c6
2.26.2
5144c6
5144c6
From f6c460aee8542d4d81cd9970d71051c240156973 Mon Sep 17 00:00:00 2001
5144c6
From: Serhii Tsymbaliuk <stsymbal@redhat.com>
5144c6
Date: Thu, 16 Jul 2020 18:52:24 +0200
5144c6
Subject: [PATCH] WebUI: Fix error "unknown command
5144c6
 'idoverrideuser_add_member'"
5144c6
5144c6
There was wrong IPA.associator class used for 'Groups' -> 'User ID overrides' association,
5144c6
as a result a wrong command was sent to the server.
5144c6
5144c6
Ticket: https://pagure.io/freeipa/issue/8416
5144c6
5144c6
Signed-off-by: Serhii Tsymbaliuk <stsymbal@redhat.com>
5144c6
Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
5144c6
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
5144c6
---
5144c6
 install/ui/src/freeipa/group.js | 1 -
5144c6
 1 file changed, 1 deletion(-)
5144c6
5144c6
diff --git a/install/ui/src/freeipa/group.js b/install/ui/src/freeipa/group.js
5144c6
index 2984bd4b2..61c19a82f 100644
5144c6
--- a/install/ui/src/freeipa/group.js
5144c6
+++ b/install/ui/src/freeipa/group.js
5144c6
@@ -209,7 +209,6 @@ return {
5144c6
         {
5144c6
             $type: 'association',
5144c6
             name: 'member_idoverrideuser',
5144c6
-            associator: IPA.serial_associator,
5144c6
             add_title: '@i18n:objects.group.add_idoverride_user',
5144c6
             remove_title: '@i18n:objects.group.remove_idoverride_users',
5144c6
             columns: [
5144c6
-- 
5144c6
2.26.2
5144c6
5144c6
From e35739b7e9f6bb016b37abbd92bdaee71a59a288 Mon Sep 17 00:00:00 2001
5144c6
From: Serhii Tsymbaliuk <stsymbal@redhat.com>
5144c6
Date: Wed, 29 Jul 2020 09:41:36 +0200
5144c6
Subject: [PATCH] WebUI tests: Add test case to cover user ID override feature
5144c6
5144c6
The test case includes adding an user ID override to Default Trust View
5144c6
and adding the ID override to some IPA group.
5144c6
5144c6
Ticket: https://pagure.io/freeipa/issue/8416
5144c6
5144c6
Signed-off-by: Serhii Tsymbaliuk <stsymbal@redhat.com>
5144c6
Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
5144c6
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
5144c6
---
5144c6
 ipatests/test_webui/test_trust.py | 41 +++++++++++++++++++++++++++++++
5144c6
 1 file changed, 41 insertions(+)
5144c6
5144c6
diff --git a/ipatests/test_webui/test_trust.py b/ipatests/test_webui/test_trust.py
5144c6
index c04c2fcd8..605f8a2a7 100644
5144c6
--- a/ipatests/test_webui/test_trust.py
5144c6
+++ b/ipatests/test_webui/test_trust.py
5144c6
@@ -21,6 +21,8 @@
5144c6
 Trust tests
5144c6
 """
5144c6
 
5144c6
+import ipatests.test_webui.data_group as group
5144c6
+import ipatests.test_webui.data_idviews as idview
5144c6
 from ipatests.test_webui.ui_driver import UI_driver
5144c6
 from ipatests.test_webui.ui_driver import screenshot
5144c6
 from ipatests.test_webui.task_range import range_tasks
5144c6
@@ -29,6 +31,8 @@ import pytest
5144c6
 ENTITY = 'trust'
5144c6
 CONFIG_ENTITY = 'trustconfig'
5144c6
 
5144c6
+DEFAULT_TRUST_VIEW = 'Default Trust View'
5144c6
+
5144c6
 CONFIG_DATA = {
5144c6
     'mod': [
5144c6
         ['combobox', 'ipantfallbackprimarygroup', 'admins'],
5144c6
@@ -164,3 +168,40 @@ class test_trust(trust_tasks):
5144c6
 
5144c6
         self.mod_record(CONFIG_ENTITY, CONFIG_DATA)
5144c6
         self.mod_record(CONFIG_ENTITY, CONFIG_DATA2)
5144c6
+
5144c6
+    @screenshot
5144c6
+    def test_group_member_idoverrideuser(self):
5144c6
+
5144c6
+        self.init_app()
5144c6
+
5144c6
+        # Create new trust
5144c6
+        data = self.get_data()
5144c6
+        self.add_record(ENTITY, data)
5144c6
+
5144c6
+        # Create an user ID override
5144c6
+        ad_domain = self.config.get('ad_domain')
5144c6
+        ad_admin = self.config.get('ad_admin')
5144c6
+        idoverrideuser_pkey = '{}@{}'.format(ad_admin, ad_domain).lower()
5144c6
+
5144c6
+        self.navigate_to_record(DEFAULT_TRUST_VIEW, entity=idview.ENTITY)
5144c6
+        self.add_record(idview.ENTITY, {
5144c6
+            'pkey': idoverrideuser_pkey,
5144c6
+            'add': [
5144c6
+                ('textbox', 'ipaanchoruuid_default', idoverrideuser_pkey),
5144c6
+            ],
5144c6
+        }, facet='idoverrideuser')
5144c6
+
5144c6
+        # Create new group and add the user ID override there
5144c6
+        self.navigate_to_entity(group.ENTITY)
5144c6
+        self.add_record(group.ENTITY, group.DATA)
5144c6
+        self.navigate_to_record(group.PKEY)
5144c6
+        self.add_associations([idoverrideuser_pkey],
5144c6
+                              facet='member_idoverrideuser', delete=True)
5144c6
+
5144c6
+        # Clean up data
5144c6
+        self.navigate_to_entity(group.ENTITY)
5144c6
+        self.delete_record(group.PKEY)
5144c6
+        self.navigate_to_record(DEFAULT_TRUST_VIEW, entity=idview.ENTITY)
5144c6
+        self.delete_record(idoverrideuser_pkey)
5144c6
+        self.navigate_to_entity(ENTITY)
5144c6
+        self.delete_record(ad_domain)
5144c6
-- 
5144c6
2.26.2
5144c6