UI tests for "ID Range": check adding range without primary and secondary RID bases

https://pagure.io/freeipa/issue/7709

Reviewed-By: Mohammad Rizwan Yusuf <myusuf@redhat.com>
Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
This commit is contained in:
Serhii Tsymbaliuk
2018-10-15 14:11:42 +02:00
parent e55d17d609
commit 369fb23ed9
3 changed files with 58 additions and 5 deletions
+11 -5
View File
@@ -100,13 +100,19 @@ class range_tasks(UI_driver):
base_id = kwargs.get('base_id', self.max_id + shift)
self.max_id = base_id + size
base_rid = self.max_rid + shift
self.max_rid = base_rid + size
if 'base_rid' in kwargs:
base_rid = kwargs['base_rid']
else:
base_rid = self.max_rid + shift
self.max_rid = base_rid + size
secondary_base_rid = None
if not domain:
secondary_base_rid = base_rid + size + shift
self.max_rid = secondary_base_rid + size
if 'secondary_base_rid' in kwargs:
secondary_base_rid = kwargs['secondary_base_rid']
else:
secondary_base_rid = self.max_rid + shift
self.max_rid = secondary_base_rid + size
return RangeAddFormData(
pkey, base_id, base_rid,
@@ -135,7 +141,7 @@ class RangeAddFormData(object):
Do not put any additional logic here!
"""
def __init__(self, cn, base_id, base_rid, secondary_base_rid=None,
def __init__(self, cn, base_id, base_rid=None, secondary_base_rid=None,
range_type=LOCAL_ID_RANGE, size=50, domain=None,
callback=None):
self.cn = cn
+35
View File
@@ -176,3 +176,38 @@ class test_range(range_tasks):
in dialog.text)
finally:
self.delete_record(pkey)
@screenshot
def test_add_range_without_rid(self):
"""
Test creating ID Range without giving rid-base or/and
secondary-rid-base values
"""
self.navigate_to_entity(ENTITY)
pkey = 'itest-range-without-rid'
# Without primary RID base
data = self.get_data(pkey, base_rid='')
self.add_record(ENTITY, data, navigate=False, negative=True)
try:
assert self.has_form_error('ipabaserid')
finally:
self.delete_record(pkey)
self.dialog_button_click('cancel')
# Without secondary RID base
data = self.get_data(pkey, secondary_base_rid='')
self.add_record(ENTITY, data, navigate=False, negative=True)
try:
assert self.has_form_error('ipasecondarybaserid')
finally:
self.delete_record(pkey)
self.dialog_button_click('cancel')
# Without primary and secondary RID bases
data = self.get_data(pkey, base_rid='', secondary_base_rid='')
self.add_record(ENTITY, data, navigate=False)
self.delete_record(pkey)
+12
View File
@@ -1904,6 +1904,18 @@ class UI_driver:
class_attr = el.get_attribute("class")
return bool(class_attr) and cls in class_attr.split()
def has_form_error(self, name):
"""
Check if form field has error
TODO: Move to some mixin class
"""
form_group = self.find(
'//input[@name="{}"]/ancestor'
'::div[contains(@class, "form-group")]'.format(name),
By.XPATH
)
return self.has_class(form_group, 'has-error')
def skip(self, reason):
"""
Skip tests