From 8a3d8aeca3bec741f8c23652848075c298bea5f1 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Wed, 17 Jul 2013 10:47:57 +0200 Subject: 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 --- ipatests/test_webui/test_range.py | 68 +++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 14 deletions(-) (limited to 'ipatests/test_webui/test_range.py') 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)) -- cgit