mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
WebUI test: ID views
Provides missing test coverage for ID views web UI. Reviewed-By: Pavel Vomacka <pvomacka@redhat.com>
This commit is contained in:
committed by
Martin Basti
parent
67b806e5d9
commit
904db149e9
20
ipatests/test_webui/data_idviews.py
Normal file
20
ipatests/test_webui/data_idviews.py
Normal file
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# Copyright (C) 2015 FreeIPA Contributors see COPYING for license
|
||||
#
|
||||
|
||||
ENTITY = 'idview'
|
||||
USER_FACET = 'idoverrideuser'
|
||||
GROUP_FACET = 'idoverridegroup'
|
||||
HOST_FACET = 'appliedtohosts'
|
||||
|
||||
PKEY = 'itest-view'
|
||||
DATA = {
|
||||
'pkey': PKEY,
|
||||
'add': [
|
||||
('textbox', 'cn', PKEY),
|
||||
('textarea', 'description', 'Description of ID view'),
|
||||
],
|
||||
'mod': [
|
||||
('textarea', 'description', 'Different description'),
|
||||
],
|
||||
}
|
127
ipatests/test_webui/test_idviews.py
Normal file
127
ipatests/test_webui/test_idviews.py
Normal file
@@ -0,0 +1,127 @@
|
||||
#
|
||||
# Copyright (C) 2015 FreeIPA Contributors see COPYING for license
|
||||
#
|
||||
|
||||
from ipatests.test_webui.ui_driver import UI_driver
|
||||
from ipatests.test_webui.ui_driver import screenshot
|
||||
import ipatests.test_webui.data_idviews as idview
|
||||
import ipatests.test_webui.data_user as user
|
||||
import ipatests.test_webui.data_group as group
|
||||
import ipatests.test_webui.data_hostgroup as hostgroup
|
||||
from ipatests.test_webui.test_host import host_tasks, ENTITY as HOST_ENTITY
|
||||
import pytest
|
||||
|
||||
DATA_USER = {
|
||||
'pkey': user.PKEY,
|
||||
'add': [
|
||||
('combobox', 'ipaanchoruuid', user.PKEY),
|
||||
('textbox', 'uid', 'iduser'),
|
||||
('textbox', 'gecos', 'id user'),
|
||||
('textbox', 'uidnumber', 1),
|
||||
('textbox', 'gidnumber', 1),
|
||||
('textbox', 'loginshell', 'shell'),
|
||||
('textbox', 'homedirectory', 'home'),
|
||||
('textarea', 'description', 'desc'),
|
||||
],
|
||||
'mod': [
|
||||
('textbox', 'uid', 'moduser'),
|
||||
('textbox', 'uidnumber', 3),
|
||||
],
|
||||
}
|
||||
|
||||
DATA_GROUP = {
|
||||
'pkey': group.PKEY,
|
||||
'add': [
|
||||
('combobox', 'ipaanchoruuid', group.PKEY),
|
||||
('textbox', 'cn', 'idgroup'),
|
||||
('textbox', 'gidnumber', 2),
|
||||
('textarea', 'description', 'desc'),
|
||||
],
|
||||
'mod': [
|
||||
('textbox', 'cn', 'modgroup'),
|
||||
('textbox', 'gidnumber', 3),
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.tier1
|
||||
class test_idviews(UI_driver):
|
||||
|
||||
@screenshot
|
||||
def test_crud(self):
|
||||
"""
|
||||
Basic CRUD: ID view
|
||||
"""
|
||||
self.init_app()
|
||||
self.basic_crud(
|
||||
idview.ENTITY, idview.DATA, default_facet=idview.USER_FACET)
|
||||
|
||||
@screenshot
|
||||
def test_overrides(self):
|
||||
"""
|
||||
User and group overrides
|
||||
"""
|
||||
self.init_app()
|
||||
|
||||
self.add_record(user.ENTITY, user.DATA, navigate=False)
|
||||
self.add_record(group.ENTITY, group.DATA)
|
||||
self.add_record(idview.ENTITY, idview.DATA)
|
||||
|
||||
self.navigate_to_record(idview.PKEY)
|
||||
parent_entity = 'idview'
|
||||
|
||||
# user override
|
||||
self.add_record(parent_entity, DATA_USER, facet=idview.USER_FACET)
|
||||
self.navigate_to_record(user.PKEY)
|
||||
self.mod_record(idview.USER_FACET, DATA_USER)
|
||||
self.delete_action(idview.ENTITY, user.PKEY)
|
||||
|
||||
# group override
|
||||
self.navigate_to_record(idview.PKEY)
|
||||
self.switch_to_facet(idview.GROUP_FACET)
|
||||
self.add_record(parent_entity, DATA_GROUP, facet=idview.GROUP_FACET)
|
||||
self.navigate_to_record(group.PKEY)
|
||||
self.mod_record(idview.GROUP_FACET, DATA_GROUP)
|
||||
self.delete_action(idview.ENTITY, group.PKEY)
|
||||
|
||||
# cleanup
|
||||
self.delete(idview.ENTITY, [idview.DATA])
|
||||
self.delete(user.ENTITY, [user.DATA])
|
||||
self.delete(group.ENTITY, [group.DATA])
|
||||
|
||||
@screenshot
|
||||
def test_hosts(self):
|
||||
"""
|
||||
Apply to hosts and host groups
|
||||
"""
|
||||
self.init_app()
|
||||
host = host_tasks()
|
||||
host.setup(self.driver, self.config)
|
||||
|
||||
self.add_record(HOST_ENTITY, host.data)
|
||||
self.add_record(hostgroup.ENTITY, hostgroup.DATA)
|
||||
self.navigate_to_record(hostgroup.PKEY)
|
||||
self.add_associations([host.pkey])
|
||||
self.add_record(idview.ENTITY, idview.DATA)
|
||||
|
||||
self.navigate_to_record(idview.PKEY)
|
||||
self.switch_to_facet(idview.HOST_FACET)
|
||||
parent_entity = 'idview'
|
||||
|
||||
# apply to host
|
||||
self.add_associations(
|
||||
[host.pkey], facet='appliedtohosts', facet_btn='idview_apply')
|
||||
self.delete_record([host.pkey], facet_btn='idview_unapply')
|
||||
|
||||
# apply to hostgroup
|
||||
self.add_associations(
|
||||
[hostgroup.PKEY], facet_btn='idview_apply_hostgroups',
|
||||
member_pkeys=[host.pkey])
|
||||
self.delete_associations(
|
||||
[hostgroup.PKEY], facet_btn='idview_unapply_hostgroups',
|
||||
member_pkeys=[host.pkey])
|
||||
|
||||
# cleanup
|
||||
self.delete(idview.ENTITY, [idview.DATA])
|
||||
self.delete(hostgroup.ENTITY, [hostgroup.DATA])
|
||||
self.delete(HOST_ENTITY, [host.data])
|
@@ -983,7 +983,9 @@ class UI_driver(object):
|
||||
link.click()
|
||||
self.wait_for_request()
|
||||
|
||||
def delete_record(self, pkeys, fields=None, parent=None, table_name=None):
|
||||
def delete_record(
|
||||
self, pkeys, fields=None, parent=None, table_name=None,
|
||||
facet_btn='remove'):
|
||||
"""
|
||||
Delete records with given pkeys in currently opened search table.
|
||||
"""
|
||||
@@ -1003,9 +1005,9 @@ class UI_driver(object):
|
||||
if table_name and parent:
|
||||
s = self.get_table_selector(table_name)
|
||||
table = self.find(s, By.CSS_SELECTOR, parent, strict=True)
|
||||
self.button_click('remove', table)
|
||||
self.button_click(facet_btn, table)
|
||||
else:
|
||||
self.facet_button_click('remove')
|
||||
self.facet_button_click(facet_btn)
|
||||
if fields:
|
||||
self.fill_fields(fields)
|
||||
self.dialog_button_click('ok')
|
||||
@@ -1323,14 +1325,15 @@ class UI_driver(object):
|
||||
self.dialog_button_click('add')
|
||||
self.wait_for_request()
|
||||
|
||||
def add_associations(self, pkeys, facet=None, delete=False):
|
||||
def prepare_associations(
|
||||
self, pkeys, facet=None, facet_btn='add', member_pkeys=None):
|
||||
"""
|
||||
Add associations
|
||||
Helper function for add_associations and delete_associations
|
||||
"""
|
||||
if facet:
|
||||
self.switch_to_facet(facet)
|
||||
|
||||
self.facet_button_click('add')
|
||||
self.facet_button_click(facet_btn)
|
||||
self.wait()
|
||||
self.wait_for_request()
|
||||
|
||||
@@ -1341,12 +1344,39 @@ class UI_driver(object):
|
||||
self.dialog_button_click('add')
|
||||
self.wait_for_request()
|
||||
|
||||
for key in pkeys:
|
||||
if member_pkeys:
|
||||
check_pkeys = member_pkeys
|
||||
else:
|
||||
check_pkeys = pkeys
|
||||
|
||||
return check_pkeys
|
||||
|
||||
def add_associations(
|
||||
self, pkeys, facet=None, delete=False, facet_btn='add',
|
||||
member_pkeys=None):
|
||||
"""
|
||||
Add associations
|
||||
"""
|
||||
check_pkeys = self.prepare_associations(
|
||||
pkeys, facet, facet_btn, member_pkeys)
|
||||
|
||||
for key in check_pkeys:
|
||||
self.assert_record(key)
|
||||
if delete:
|
||||
self.delete_record(key)
|
||||
self.assert_record(key, negative=True)
|
||||
|
||||
def delete_associations(
|
||||
self, pkeys, facet=None, facet_btn='remove', member_pkeys=None):
|
||||
"""
|
||||
Remove associations
|
||||
"""
|
||||
check_pkeys = self.prepare_associations(
|
||||
pkeys, facet, facet_btn, member_pkeys)
|
||||
|
||||
for key in check_pkeys:
|
||||
self.assert_record(key, negative=True)
|
||||
|
||||
def add_table_associations(self, table_name, pkeys, parent=False, delete=False):
|
||||
"""
|
||||
Add value to table (association|rule|...)
|
||||
|
Reference in New Issue
Block a user