From dde4d19f7b40bfd96720945f374cbc18eb8b484b Mon Sep 17 00:00:00 2001 From: Serhii Tsymbaliuk Date: Wed, 26 Sep 2018 09:12:52 +0200 Subject: [PATCH] UI tests for "ID Range": check adding range with overlapping of existing local range https://pagure.io/freeipa/issue/7709 Reviewed-By: Mohammad Rizwan Yusuf Reviewed-By: Petr Vobornik --- ipatests/test_webui/task_range.py | 10 ++++++++ ipatests/test_webui/test_range.py | 39 ++++++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/ipatests/test_webui/task_range.py b/ipatests/test_webui/task_range.py index ef6d131f1..ef38c4688 100644 --- a/ipatests/test_webui/task_range.py +++ b/ipatests/test_webui/task_range.py @@ -31,6 +31,16 @@ TRUSTED_ID_RANGE = 'ipa-ad-trust' class range_tasks(UI_driver): + BASE_RANGE_OVERLAPS_ERROR = ( + 'Constraint violation: ' + 'New base range overlaps with existing base range.' + ) + + PRIMARY_RID_RANGE_OVERLAPS_ERROR = ( + 'Constraint violation: ' + 'New primary rid range overlaps with existing primary rid range.' + ) + def get_shifts(self): result = self.execute_api_from_ui('idrange_find', [], {}) idranges = result['result']['result'] diff --git a/ipatests/test_webui/test_range.py b/ipatests/test_webui/test_range.py index 7cd3fdbd4..3de1f16b4 100644 --- a/ipatests/test_webui/test_range.py +++ b/ipatests/test_webui/test_range.py @@ -171,9 +171,38 @@ class test_range(range_tasks): dialog = self.get_last_error_dialog() try: - assert ('Constraint violation: ' - 'New base range overlaps with existing base range.' - in dialog.text) + assert self.BASE_RANGE_OVERLAPS_ERROR in dialog.text + finally: + self.delete_record(pkey) + + @screenshot + def test_add_range_overlaps_with_existing(self): + """ + Test creating ID Range with overlapping of existing range + """ + self.navigate_to_entity(ENTITY) + + for range_type in self.range_types: + pkey = 'itest-range' + pkey_overlaps = 'itest-range-overlaps' + + form_data = self.get_add_form_data(pkey) + data = self.get_data(pkey, form_data=form_data) + form_data_overlaps = self.get_add_form_data( + pkey_overlaps, + base_id=form_data.base_id + form_data.size - 1, + range_type=range_type + ) + data_overlaps = self.get_data(form_data=form_data_overlaps) + + self.add_record(ENTITY, data, navigate=False) + self.add_record(ENTITY, data_overlaps, navigate=False, + negative=True, pre_delete=False) + + dialog = self.get_last_error_dialog() + + try: + assert self.BASE_RANGE_OVERLAPS_ERROR in dialog.text finally: self.delete_record(pkey) @@ -197,9 +226,7 @@ class test_range(range_tasks): dialog = self.get_last_error_dialog() try: - assert ('Constraint violation: ' - 'New primary rid range overlaps with existing primary rid range.' - in dialog.text) + assert self.PRIMARY_RID_RANGE_OVERLAPS_ERROR in dialog.text finally: self.delete_record(pkey)