On 04/04/2016 06:54 PM, Martin Basti wrote:


On 01.04.2016 14:34, Pavel Vomacka wrote:


On 03/31/2016 04:16 PM, Lenka Doudova wrote:


On 03/31/2016 12:42 PM, Pavel Vomacka wrote:


On 03/18/2016 11:24 AM, Lenka Doudova wrote:


On 03/10/2016 06:58 PM, Petr Vobornik wrote:
On 03/08/2016 01:17 PM, Lenka Doudova wrote:


On 03/08/2016 12:59 PM, Petr Vobornik wrote:
On 03/07/2016 04:29 PM, Pavel Vomacka wrote:


On 02/25/2016 03:08 PM, Lenka Doudova wrote:
Hi,

here's a patch for webUI tests that provides test for creating user
without private group.
Related to ticket https://fedorahosted.org/freeipa/ticket/4986

Since the option to specify GID when creating a user is not available https://fedorahosted.org/freeipa/ticket/5505 the test creates a new posix group, makes it a default user group instead of 'ipausers' and
then attemps to create the user without private group. Returning
default user group value to 'ipausers' is provided even for cases when
the test fails so it would not block other tests from performing
properly.

Lenka


Hi,

ACK, works well.

Pavel^3 Vomacka


NACK, don't use naked except, specify at least 'Exception'
  +        except:


Thanks, patch fixed according to Petr's review attached.

Lenka

Ticket 5505 was pushed. So the workaround can be removed. Do you prefer to do it in this patch?

Also, maybe it would be good to test both cases and check if the error is actually the right one.

Hi,

attaching patch fixed according to recently pushed changes.

Lenka
Hi,

NACK,

1) The data definition for user3 (user.DATA3) is not used anywhere. And the definition is actually the same as definition of user4. So, I think that it could be removed.

2) This is just a detail, but I would rather use 'combobox_input' or 'combobox_textbox' as parameter name because the parameter actually doesn't represent the value of combobox.

Otherwise it works as expected.

--
Pavel^3 Vomacka

Hi,

thanks for comments, updated patch attached.

Lenka


Thank you, ACK.

--
Pavel^3 Vomacka



Ticket is in closed milestone, this patch cannot be attached to closed milestone, please create a new ticket/or post the proper ticket.


Hi,

new ticket has been created for this issue. Patch with modified commit message to refer to the new ticket attached.
Lenka
From 42be921e6d9651e38cbd4e2a536972f205219c0e Mon Sep 17 00:00:00 2001
From: Lenka Doudova <ldoud...@redhat.com>
Date: Thu, 25 Feb 2016 15:00:49 +0100
Subject: [PATCH] WebUI: Test creating user without private group

Test for option to create a user without private group in web UI.

Covers ticket https://fedorahosted.org/freeipa/ticket/5804
---
 ipatests/test_webui/data_group.py | 10 ++++++++++
 ipatests/test_webui/data_user.py  | 24 +++++++++++++++++++++++-
 ipatests/test_webui/test_user.py  | 38 ++++++++++++++++++++++++++++++++++++++
 ipatests/test_webui/ui_driver.py  | 31 +++++++++++++++++++------------
 4 files changed, 90 insertions(+), 13 deletions(-)

diff --git a/ipatests/test_webui/data_group.py b/ipatests/test_webui/data_group.py
index 2b32b2f32983c78a002a06888b8f82b38b608d1a..9d79d18a1348e6b90bb0867261bf30706134db22 100644
--- a/ipatests/test_webui/data_group.py
+++ b/ipatests/test_webui/data_group.py
@@ -68,3 +68,13 @@ DATA5 = {
         ('textarea', 'description', 'test-group5 desc'),
     ]
 }
+
+PKEY6 = 'itest-group6'
+DATA6 = {
+    'pkey': PKEY6,
+    'add': [
+        ('textbox', 'cn', PKEY6),
+        ('textarea', 'description', 'test-group6 desc'),
+        ('textbox', 'gidnumber', '77777'),
+    ]
+}
diff --git a/ipatests/test_webui/data_user.py b/ipatests/test_webui/data_user.py
index 79a53898035a2723c1e79c459ba4aef3ffa67723..c5ed796c7bfe9f56d6ab1e179b2f7343bd05d73b 100644
--- a/ipatests/test_webui/data_user.py
+++ b/ipatests/test_webui/data_user.py
@@ -17,7 +17,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-
 ENTITY = 'user'
 
 PKEY = 'itest-user'
@@ -63,3 +62,26 @@ DATA2 = {
         ('textbox', 'sn', 'OtherSurname2'),
     ],
 }
+
+PKEY3 = 'itest-user3'
+DATA3 = {
+    'pkey': PKEY3,
+    'add': [
+        ('textbox', 'uid', PKEY3),
+        ('textbox', 'givenname', 'Name3'),
+        ('textbox', 'sn', 'Surname3'),
+        ('checkbox', 'noprivate', None),
+    ]
+}
+
+PKEY4 = 'itest-user4'
+DATA4 = {
+    'pkey': PKEY4,
+    'add': [
+        ('textbox', 'uid', PKEY4),
+        ('textbox', 'givenname', 'Name4'),
+        ('textbox', 'sn', 'Surname4'),
+        ('checkbox', 'noprivate', None),
+        ('combobox', 'gidnumber', '77777'),
+    ]
+}
diff --git a/ipatests/test_webui/test_user.py b/ipatests/test_webui/test_user.py
index b216125b226230ab268de3f86ec7ac6f785c6e16..5b509d18ca9a0738af1595678fd56ba57d405079 100644
--- a/ipatests/test_webui/test_user.py
+++ b/ipatests/test_webui/test_user.py
@@ -261,3 +261,41 @@ class test_user(UI_driver):
         self.dialog_button_click('confirm')
         self.wait_for_request(n=3)
         self.assert_no_error_dialog()
+
+
+@pytest.mark.tier1
+class test_user_no_private_group(UI_driver):
+
+    @screenshot
+    def test_noprivate_nonposix(self):
+        """
+        User without private group and without specified GID
+        """
+        self.init_app()
+
+        with pytest.raises(AssertionError) as e:
+            self.add_record(user.ENTITY, user.DATA3)
+        assert e.value.message == u'Unexpected error: Default group for new users is not POSIX'
+
+    @screenshot
+    def test_noprivate_posix(self):
+        """
+        User without private group and specified existing posix GID
+        """
+        self.init_app()
+        self.add_record(group.ENTITY, group.DATA6)
+
+        self.add_record(user.ENTITY, user.DATA4)
+        self.delete(user.ENTITY, [user.DATA4])
+
+        self.delete(group.ENTITY, [group.DATA6])
+
+    @screenshot
+    def test_noprivate_gidnumber(self):
+        """
+        User without private group and specified unused GID
+        """
+        self.init_app()
+
+        self.add_record(user.ENTITY, user.DATA4, combobox_input='gidnumber')
+        self.delete(user.ENTITY, [user.DATA4])
diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py
index 8611ad3ca0ca3f9447157f66789785da9b1fe907..40cdad3c794a98f5f1648d3338b917084db2e3ed 100644
--- a/ipatests/test_webui/ui_driver.py
+++ b/ipatests/test_webui/ui_driver.py
@@ -778,7 +778,7 @@ class UI_driver(object):
         assert label is not None, "Option not found: %s" % name
         label.click()
 
-    def select_combobox(self, name, value, parent=None):
+    def select_combobox(self, name, value, parent=None, combobox_input=None):
         """
         Select value in a combobox. Search if not found.
         """
@@ -795,15 +795,20 @@ class UI_driver(object):
         search_btn = self.find('a[name=search] i', By.CSS_SELECTOR, cb, strict=True)
         opt_s = "select[name=list] option[value='%s']" % value
         option = self.find(opt_s, By.CSS_SELECTOR, cb)
-        if not option:
-            # try to search
-            self.fill_textbox('filter', value, cb)
 
-            search_btn.click()
-            self.wait_for_request()
-            option = self.find(opt_s, By.CSS_SELECTOR, cb, strict=True)
+        if combobox_input:
+            if not option:
+                self.fill_textbox(combobox_input, value, cb)
+        else:
+            if not option:
+                # try to search
+                self.fill_textbox('filter', value, cb)
 
-        option.click()
+                search_btn.click()
+                self.wait_for_request()
+                option = self.find(opt_s, By.CSS_SELECTOR, cb, strict=True)
+
+            option.click()
 
         # Chrome does not close search area on click
         if list_cnt.is_displayed():
@@ -1025,7 +1030,8 @@ class UI_driver(object):
             fields = data.get('del')
             self.delete_record(pkey, fields)
 
-    def fill_fields(self, fields, parent=None, undo=False):
+    def fill_fields(
+            self, fields, parent=None, undo=False, combobox_input=None):
         """
         Fill dialog or facet inputs with give data.
 
@@ -1060,7 +1066,8 @@ class UI_driver(object):
             elif widget_type == 'selectbox':
                 self.select('select[name=%s]' % key, val, parent)
             elif widget_type == 'combobox':
-                self.select_combobox(key, val, parent)
+                self.select_combobox(
+                    key, val, parent, combobox_input=combobox_input)
             elif widget_type == 'add_table_record':
                 self.add_table_record(key, val, parent)
             elif widget_type == 'add_table_association':
@@ -1149,7 +1156,7 @@ class UI_driver(object):
 
     def add_record(self, entity, data, facet='search', facet_btn='add',
                    dialog_btn='add', delete=False, pre_delete=True,
-                   dialog_name='add', navigate=True):
+                   dialog_name='add', navigate=True, combobox_input=None):
         """
         Add records.
 
@@ -1184,7 +1191,7 @@ class UI_driver(object):
         self.assert_dialog(dialog_name)
 
         # fill dialog
-        self.fill_fields(data['add'])
+        self.fill_fields(data['add'], combobox_input=combobox_input)
 
         # confirm dialog
         self.dialog_button_click(dialog_btn)
-- 
2.5.0

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to