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

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