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

Reviewed-By: Pavel Vomacka <pvomacka@redhat.com>
This commit is contained in:
Lenka Doudova 2016-02-25 15:00:49 +01:00 committed by Martin Basti
parent 70fd78928c
commit 6468a39850
4 changed files with 90 additions and 13 deletions

View File

@ -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'),
]
}

View File

@ -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'),
]
}

View File

@ -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])

View File

@ -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)