ipa/0043-webuitests-adapt-to-Random-Serial-Numbers.patch
Florence Blanc-Renaud 1e38d43370 ipa-4.12.2-8
- Resolves: RHEL-69300 Support GSSAPI in Cockpit on IPA servers
- Resolves: RHEL-68447 ipa trust-add fails in FIPS mode with an internal error has occurred
- Resolves: RHEL-57674 Use RSNv3 and enable cert pruning by default in RHEL 10.0

Signed-off-by: Florence Blanc-Renaud <flo@redhat.com>
2024-11-27 19:43:17 +01:00

96 lines
3.7 KiB
Diff

From c8befc9f46b43aec748ede33236ca4f77b2356c6 Mon Sep 17 00:00:00 2001
From: Florence Blanc-Renaud <flo@redhat.com>
Date: Tue, 26 Nov 2024 09:40:53 +0100
Subject: [PATCH] webuitests: adapt to Random Serial Numbers
The webui tests were written for sequential serial numbers
and expect the certs to be issued with low serial numbers.
Adapt to Random Serial Numbers.
Fixes:https://pagure.io/freeipa/issue/9707
Signed-off-by: Florence Blanc-Renaud <flo@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
---
ipatests/test_webui/test_cert.py | 39 +++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
diff --git a/ipatests/test_webui/test_cert.py b/ipatests/test_webui/test_cert.py
index 7a8ffde917c75f4578b1d8f9a1cdcdbb4ba4a1ae..0dc276555b26a2ac4a0d79695f3cd74a3ccd55ec 100644
--- a/ipatests/test_webui/test_cert.py
+++ b/ipatests/test_webui/test_cert.py
@@ -93,6 +93,14 @@ class test_cert(UI_driver):
csr = generate_csr(hostname)
self.navigate_to_entity(ENTITY)
+
+ # Save the existing cert serials before the new one is added
+ # the test will compare before/after in order to find the serial
+ # of the newly generated certificate
+ result = self.execute_api_from_ui('cert_find', [], {})
+ certs = result['result']['result']
+ before = [cert["serial_number"] for cert in certs]
+
self.facet_button_click('request_cert')
self.fill_textbox('principal', 'HTTP/{}'.format(hostname))
self.check_option('add', 'checked')
@@ -100,8 +108,17 @@ class test_cert(UI_driver):
self.dialog_button_click('issue')
self.assert_notification(assert_text='Certificate requested')
self.navigate_to_entity(ENTITY)
+
+ # Save the existing cert serials after the new one is added
+ result = self.execute_api_from_ui('cert_find', [], {})
+ certs = result['result']['result']
+ after = [cert["serial_number"] for cert in certs]
+ new_serial = [serial for serial in after if serial not in before]
+ # Find the cert that was jsut generated
+ index = after.index(new_serial[0])
+
rows = self.get_rows()
- cert = rows[-1]
+ cert = rows[index]
self.navigate_to_row_record(cert)
self.action_list_action('revoke_cert', False)
@@ -212,10 +229,18 @@ class test_cert(UI_driver):
# try searching using -1
check_minimum_serial(self, '-1', 'min_serial_number')
+ # Find the highest serial number and add 1 to be sure there is no
+ # cert with a higher serial number
+ result = self.execute_api_from_ui('cert_find', [], {})
+ certs = result['result']['result']
+ serials = [int(cert["serial_number_hex"], 0) for cert in certs]
+ serials.sort()
+ highest_serial = str(serials[-1] + 1)
+
# try using higher value than no. of certs present
self.navigate_to_entity(ENTITY)
self.select('select[name=search_option]', 'min_serial_number')
- search_pkey(self, '99')
+ search_pkey(self, highest_serial)
rows = self.get_rows()
assert len(rows) == 0
@@ -226,8 +251,16 @@ class test_cert(UI_driver):
"""
self.init_app()
self.navigate_to_entity(ENTITY)
+
+ # Find the second lowest serial number
+ result = self.execute_api_from_ui('cert_find', [], {})
+ certs = result['result']['result']
+ serials = [int(cert["serial_number_hex"], 0) for cert in certs]
+ serials.sort()
+ second_serial = str(serials[1])
+
self.select('select[name=search_option]', 'max_serial_number')
- search_pkey(self, '2')
+ search_pkey(self, second_serial)
rows = self.get_rows()
assert len(rows) == 2
--
2.47.0