mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Fix certificate revocation tests for Web UI
- correct revocation date before search - increase timeouts https://pagure.io/freeipa/issue/7834 Reviewed-By: Armando Neto <abiagion@redhat.com>
This commit is contained in:
parent
ed74b89878
commit
88795fb9a9
@ -44,26 +44,6 @@ def search_pkey(self, pkey):
|
||||
self.wait_for_request(n=2)
|
||||
|
||||
|
||||
def add_cert(self, principal, csr):
|
||||
self.facet_button_click('request_cert')
|
||||
self.fill_textbox('principal', principal)
|
||||
self.check_option('add', 'checked')
|
||||
self.fill_textarea('csr', csr)
|
||||
self.dialog_button_click('issue')
|
||||
self.assert_notification(assert_text='Certificate requested')
|
||||
self.navigate_to_entity(ENTITY)
|
||||
rows = self.get_rows()
|
||||
return rows[-1]
|
||||
|
||||
|
||||
def revoke_cert(self, record, reason):
|
||||
self.navigate_to_entity(ENTITY)
|
||||
self.navigate_to_row_record(record)
|
||||
self.action_list_action('revoke_cert', False)
|
||||
self.select('select[name=revocation_reason]', reason)
|
||||
self.dialog_button_click('ok')
|
||||
|
||||
|
||||
def check_option_negative(self, date, option):
|
||||
self.navigate_to_entity(ENTITY)
|
||||
self.select('select[name=search_option]', option)
|
||||
@ -109,6 +89,29 @@ class test_cert(UI_driver):
|
||||
if not self.has_ca():
|
||||
self.skip('CA not configured')
|
||||
|
||||
def _add_and_revoke_cert(self, reason='1'):
|
||||
hostname = self.config.get('ipa_server')
|
||||
csr = generate_csr(hostname)
|
||||
|
||||
self.navigate_to_entity(ENTITY)
|
||||
self.facet_button_click('request_cert')
|
||||
self.fill_textbox('principal', 'HTTP/{}'.format(hostname))
|
||||
self.check_option('add', 'checked')
|
||||
self.fill_textarea('csr', csr)
|
||||
self.dialog_button_click('issue')
|
||||
self.assert_notification(assert_text='Certificate requested')
|
||||
self.navigate_to_entity(ENTITY)
|
||||
rows = self.get_rows()
|
||||
cert = rows[-1]
|
||||
|
||||
self.navigate_to_row_record(cert)
|
||||
self.action_list_action('revoke_cert', False)
|
||||
self.select('select[name=revocation_reason]', reason)
|
||||
self.dialog_button_click('ok')
|
||||
self.navigate_to_entity(ENTITY)
|
||||
|
||||
return cert
|
||||
|
||||
@screenshot
|
||||
def test_read(self):
|
||||
"""
|
||||
@ -160,18 +163,11 @@ class test_cert(UI_driver):
|
||||
Try to search certificates by revocation reason
|
||||
"""
|
||||
self.init_app()
|
||||
self.navigate_to_entity(ENTITY)
|
||||
|
||||
# add a new cert
|
||||
hostname = self.config.get('ipa_server')
|
||||
csr = generate_csr(hostname)
|
||||
record = add_cert(self, 'HTTP/{}'.format(hostname), csr)
|
||||
|
||||
# revoke added cert
|
||||
revoke_cert(self, record, '1')
|
||||
# revoke new certificate
|
||||
self._add_and_revoke_cert()
|
||||
|
||||
# search cert by revocation reason
|
||||
self.navigate_to_entity(ENTITY)
|
||||
self.select('select[name=search_option]', 'revocation_reason')
|
||||
search_pkey(self, '1')
|
||||
rows = self.get_rows()
|
||||
@ -248,7 +244,10 @@ class test_cert(UI_driver):
|
||||
"""
|
||||
today = date.today()
|
||||
self.init_app()
|
||||
self.navigate_to_entity(ENTITY)
|
||||
|
||||
# revoke new certificate
|
||||
self._add_and_revoke_cert()
|
||||
|
||||
self.select('select[name=search_option]', 'validnotafter_from')
|
||||
search_pkey(self, str(today))
|
||||
rows = self.get_rows()
|
||||
@ -284,7 +283,10 @@ class test_cert(UI_driver):
|
||||
"""
|
||||
today = date.today()
|
||||
self.init_app()
|
||||
self.navigate_to_entity(ENTITY)
|
||||
|
||||
# revoke new certificate
|
||||
self._add_and_revoke_cert()
|
||||
|
||||
self.select('select[name=search_option]', 'validnotafter_to')
|
||||
search_pkey(self, str(today + timedelta(weeks=52 * 30)))
|
||||
rows = self.get_rows()
|
||||
@ -320,7 +322,10 @@ class test_cert(UI_driver):
|
||||
"""
|
||||
today = date.today()
|
||||
self.init_app()
|
||||
self.navigate_to_entity(ENTITY)
|
||||
|
||||
# revoke new certificate
|
||||
self._add_and_revoke_cert()
|
||||
|
||||
self.select('select[name=search_option]', 'validnotbefore_from')
|
||||
search_pkey(self, str(today))
|
||||
rows = self.get_rows()
|
||||
@ -356,7 +361,10 @@ class test_cert(UI_driver):
|
||||
"""
|
||||
today = date.today()
|
||||
self.init_app()
|
||||
self.navigate_to_entity(ENTITY)
|
||||
|
||||
# revoke new certificate
|
||||
self._add_and_revoke_cert()
|
||||
|
||||
self.select('select[name=search_option]', 'validnotbefore_to')
|
||||
search_pkey(self, str(today + timedelta(weeks=52 * 30)))
|
||||
rows = self.get_rows()
|
||||
@ -392,7 +400,10 @@ class test_cert(UI_driver):
|
||||
"""
|
||||
today = date.today()
|
||||
self.init_app()
|
||||
self.navigate_to_entity(ENTITY)
|
||||
|
||||
# revoke new certificate
|
||||
self._add_and_revoke_cert()
|
||||
|
||||
self.select('select[name=search_option]', 'issuedon_from')
|
||||
search_pkey(self, str(today))
|
||||
rows = self.get_rows()
|
||||
@ -424,7 +435,10 @@ class test_cert(UI_driver):
|
||||
"""
|
||||
today = date.today()
|
||||
self.init_app()
|
||||
self.navigate_to_entity(ENTITY)
|
||||
|
||||
# revoke new certificate
|
||||
self._add_and_revoke_cert()
|
||||
|
||||
self.select('select[name=search_option]', 'issuedon_to')
|
||||
search_pkey(self, str(today))
|
||||
rows = self.get_rows()
|
||||
@ -456,7 +470,10 @@ class test_cert(UI_driver):
|
||||
"""
|
||||
today = date.today()
|
||||
self.init_app()
|
||||
self.navigate_to_entity(ENTITY)
|
||||
|
||||
# revoke new certificate
|
||||
self._add_and_revoke_cert()
|
||||
|
||||
self.select('select[name=search_option]', 'revokedon_from')
|
||||
search_pkey(self, str(today))
|
||||
rows = self.get_rows()
|
||||
@ -488,7 +505,10 @@ class test_cert(UI_driver):
|
||||
"""
|
||||
today = date.today()
|
||||
self.init_app()
|
||||
self.navigate_to_entity(ENTITY)
|
||||
|
||||
# revoke new certificate
|
||||
self._add_and_revoke_cert()
|
||||
|
||||
self.select('select[name=search_option]', 'revokedon_to')
|
||||
search_pkey(self, str(today))
|
||||
rows = self.get_rows()
|
||||
|
@ -182,6 +182,8 @@ class test_host(host_tasks):
|
||||
self.wait_for_request(n=2, d=3)
|
||||
self.assert_visible(cert_widget_sel)
|
||||
|
||||
widget = self.find(cert_widget_sel, By.CSS_SELECTOR)
|
||||
|
||||
# cert view
|
||||
self.action_list_action('view', confirm=False,
|
||||
parents_css_sel=cert_widget_sel)
|
||||
@ -216,7 +218,8 @@ class test_host(host_tasks):
|
||||
self.wait()
|
||||
self.select('select', '6')
|
||||
self.dialog_button_click('ok')
|
||||
self.wait_for_request(n=2, d=3)
|
||||
self.wait_while_working(widget)
|
||||
|
||||
self.assert_visible(cert_widget_sel + " div.watermark")
|
||||
|
||||
# check that revoke action is not enabled
|
||||
@ -234,7 +237,7 @@ class test_host(host_tasks):
|
||||
parents_css_sel=cert_widget_sel)
|
||||
self.wait()
|
||||
self.dialog_button_click('ok')
|
||||
self.wait_for_request(n=2)
|
||||
self.wait_while_working(widget)
|
||||
|
||||
# check that revoke action is enabled
|
||||
self.assert_action_list_action('revoke',
|
||||
|
@ -178,6 +178,8 @@ class test_service(sevice_tasks):
|
||||
self.wait_for_request(n=2, d=3)
|
||||
self.assert_visible(cert_widget_sel)
|
||||
|
||||
widget = self.find(cert_widget_sel, By.CSS_SELECTOR)
|
||||
|
||||
# cert view
|
||||
self.action_list_action('view', confirm=False,
|
||||
parents_css_sel=cert_widget_sel)
|
||||
@ -218,7 +220,8 @@ class test_service(sevice_tasks):
|
||||
self.wait()
|
||||
self.select('select', '6')
|
||||
self.dialog_button_click('ok')
|
||||
self.wait_for_request(n=2, d=3)
|
||||
self.wait_while_working(widget)
|
||||
|
||||
self.assert_visible(cert_widget_sel + " div.watermark")
|
||||
|
||||
# check that revoke action is not enabled
|
||||
@ -241,7 +244,7 @@ class test_service(sevice_tasks):
|
||||
parents_css_sel=cert_widget_sel)
|
||||
self.wait()
|
||||
self.dialog_button_click('ok')
|
||||
self.wait_for_request(n=2)
|
||||
self.wait_while_working(widget)
|
||||
|
||||
# check that revoke action is enabled
|
||||
self.assert_action_list_action('revoke',
|
||||
@ -267,6 +270,7 @@ class test_service(sevice_tasks):
|
||||
self.select('select', '1')
|
||||
self.dialog_button_click('ok')
|
||||
self.close_notifications()
|
||||
self.wait_while_working(widget)
|
||||
|
||||
# check that revoke action is not enabled
|
||||
self.assert_action_list_action('revoke', enabled=False,
|
||||
|
@ -362,6 +362,19 @@ class UI_driver:
|
||||
self.wait()
|
||||
self.wait(d)
|
||||
|
||||
def wait_while_working(self, widget, implicit=0.2):
|
||||
"""
|
||||
Wait while working widget active
|
||||
"""
|
||||
|
||||
working_widget = self.find('.working-widget', By.CSS_SELECTOR, widget)
|
||||
|
||||
self.wait(implicit)
|
||||
WebDriverWait(self.driver, self.request_timeout).until_not(
|
||||
lambda d: working_widget.is_displayed()
|
||||
)
|
||||
self.wait(0.5)
|
||||
|
||||
def xpath_has_val(self, attr, val):
|
||||
"""
|
||||
Create xpath expression for matching a presence of item in attribute
|
||||
|
Loading…
Reference in New Issue
Block a user