summaryrefslogtreecommitdiffstats
path: root/ipatests
diff options
context:
space:
mode:
Diffstat (limited to 'ipatests')
-rw-r--r--ipatests/test_webui/test_range.py68
-rw-r--r--ipatests/test_webui/ui_driver.py25
2 files changed, 79 insertions, 14 deletions
diff --git a/ipatests/test_webui/test_range.py b/ipatests/test_webui/test_range.py
index baa53cba..93e3e789 100644
--- a/ipatests/test_webui/test_range.py
+++ b/ipatests/test_webui/test_range.py
@@ -25,25 +25,65 @@ from ipatests.test_webui.ui_driver import UI_driver
ENTITY = 'idrange'
PKEY = 'itest-range'
-DATA = {
- 'pkey': PKEY,
- 'add': [
- ('textbox', 'cn', PKEY),
- ('textbox', 'ipabaseid', '900000'),
- ('textbox', 'ipaidrangesize', '99999'),
- ('textbox', 'ipabaserid', '10000'),
- ('textbox', 'ipasecondarybaserid', '200000'),
- ],
- 'mod': [
- ('textbox', 'ipaidrangesize', '100000'),
- ],
-}
class test_range(UI_driver):
+ def get_shifts(self, idranges=None):
+
+ if not idranges:
+ result = self.execute_api_from_ui('idrange_find', [], {})
+ idranges = result['result']['result']
+
+ id_shift = 0
+ rid_shift = 0
+
+ for idrange in idranges:
+ size = int(idrange['ipaidrangesize'][0])
+ base_id = int(idrange['ipabaseid'][0])
+
+ id_end = base_id + size
+ rid_end = 0
+
+ if 'ipabaserid' in idrange:
+ base_rid = int(idrange['ipabaserid'][0])
+ rid_end = base_rid + size
+
+ if 'ipasecondarybaserid' in idrange:
+ secondary_base_rid = int(idrange['ipasecondarybaserid'][0])
+ rid_end = max(base_rid, secondary_base_rid) + size
+
+ if id_shift < id_end:
+ id_shift = id_end + 1000000
+
+ if rid_shift < rid_end:
+ rid_shift = rid_end + 1000000
+
+ self.id_shift = id_shift
+ self.rid_shift = rid_shift
+ self.sec_rid_shift = rid_shift + 1000
+ self.shift = 0
+
+ def get_data(self, pkey, size=50, shift=100):
+ self.shift += shift
+ data = {
+ 'pkey': pkey,
+ 'add': [
+ ('textbox', 'cn', pkey),
+ ('textbox', 'ipabaseid', str(self.id_shift + self.shift)),
+ ('textbox', 'ipaidrangesize', str(size)),
+ ('textbox', 'ipabaserid', str(self.rid_shift + self.shift)),
+ ('textbox', 'ipasecondarybaserid', str(self.sec_rid_shift + self.shift)),
+ ],
+ 'mod': [
+ ('textbox', 'ipaidrangesize', str(size + 1)),
+ ],
+ }
+ return data
+
def test_crud(self):
"""
Basic CRUD: range
"""
self.init_app()
- self.basic_crud(ENTITY, DATA)
+ self.get_shifts()
+ self.basic_crud(ENTITY, self.get_data(PKEY))
diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py
index ef97a11f..508418b6 100644
--- a/ipatests/test_webui/ui_driver.py
+++ b/ipatests/test_webui/ui_driver.py
@@ -489,6 +489,31 @@ class UI_driver(object):
}
return info
+ def execute_api_from_ui(self, method, args, options, timeout=30):
+ """
+ Executes FreeIPA API command/method from Web UI
+ """
+ script = """
+ var method = arguments[0];
+ var args = arguments[1];
+ var options = arguments[2];
+ var callback = arguments[arguments.length - 1];
+ var IPA = require('freeipa/ipa');
+
+ var cmd = IPA.command({
+ method: method,
+ args: args,
+ options: options,
+ on_success: callback,
+ on_error: callback
+ });
+
+ cmd.execute();
+ """
+ self.driver.set_script_timeout(timeout)
+ result = self.driver.execute_async_script(script, *[method, args, options])
+ return result
+
def click_on_link(self, text, parent=None):
"""
Click on link with given text and parent.