summaryrefslogtreecommitdiffstats
path: root/ipatests/test_webui/test_range.py
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2013-07-17 10:47:57 +0200
committerPetr Vobornik <pvoborni@redhat.com>2013-07-26 13:35:12 +0200
commit8a3d8aeca3bec741f8c23652848075c298bea5f1 (patch)
tree080ff69c532231a0162615472e9562993c78a974 /ipatests/test_webui/test_range.py
parenta3567cef981c0cd6883debcd000651a8b12dd247 (diff)
downloadfreeipa.git-8a3d8aeca3bec741f8c23652848075c298bea5f1.tar.gz
freeipa.git-8a3d8aeca3bec741f8c23652848075c298bea5f1.tar.xz
freeipa.git-8a3d8aeca3bec741f8c23652848075c298bea5f1.zip
Web UI integration tests: Compute range sizes to avoid overlaps
Heavily inspired by code from xmlrpc tests. To obtain ranges, this patch also adds method to execute FreeIPA command through Web UI. It uses Web UI instead of ipalib so it doesn't need to care about authentication on a test-runner machine. https://fedorahosted.org/freeipa/ticket/3744
Diffstat (limited to 'ipatests/test_webui/test_range.py')
-rw-r--r--ipatests/test_webui/test_range.py68
1 files changed, 54 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))