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
From 3f8f4f3d1485b27adfcdcb72fc382db72a1a44a1 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/4986
---
 ipatests/test_webui/data_group.py | 10 ++++++++++
 ipatests/test_webui/data_user.py  | 35 ++++++++++++++++++++++++++++++++++-
 ipatests/test_webui/test_user.py  | 38 ++++++++++++++++++++++++++++++++++++++
 ipatests/test_webui/ui_driver.py  | 31 +++++++++++++++++++------------
 4 files changed, 101 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..e0d7f7b209291eca1adccf5771c63a7d96a20d44 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,37 @@ 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),
+    ]
+}
+
+PKEY5 = 'itest-user5'
+DATA5 = {
+    'pkey': PKEY5,
+    'add': [
+        ('textbox', 'uid', PKEY5),
+        ('textbox', 'givenname', 'Name5'),
+        ('textbox', 'sn', 'Surname5'),
+        ('checkbox', 'noprivate', None),
+        ('combobox', 'gidnumber', '77777'),
+    ]
+}
diff --git a/ipatests/test_webui/test_user.py b/ipatests/test_webui/test_user.py
index b216125b226230ab268de3f86ec7ac6f785c6e16..1598d6e4de18ed9261fee1b7fa533a7701216fa8 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.DATA4)
+        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.DATA5)
+        self.delete(user.ENTITY, [user.DATA5])
+
+        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.DATA5, combobox_value='gidnumber')
+        self.delete(user.ENTITY, [user.DATA5])
diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py
index 8611ad3ca0ca3f9447157f66789785da9b1fe907..67059d9446f37d49bcdad9bbaed4dcfd624d4e34 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_value=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_value:
+            if not option:
+                self.fill_textbox(combobox_value, 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_value=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_value=combobox_value)
             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_value=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_value=combobox_value)
 
         # 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