Imported Upstream version 4.0.5

This commit is contained in:
Mario Fetka
2021-07-25 07:50:50 +02:00
parent 8ff3be4216
commit 3bfaa6e020
2049 changed files with 317193 additions and 1632423 deletions

View File

@@ -28,16 +28,14 @@ import ipatests.test_webui.data_netgroup as netgroup
import ipatests.test_webui.data_hbac as hbac
import ipatests.test_webui.test_rbac as rbac
import ipatests.test_webui.data_sudo as sudo
import pytest
ENTITY = 'host'
@pytest.mark.tier1
class host_tasks(UI_driver):
def setup(self, *args, **kwargs):
super(host_tasks, self).setup(*args, **kwargs)
def __init__(self, *args, **kwargs):
super(host_tasks, self).__init__(args, kwargs)
self.prep_data()
self.prep_data2()
@@ -98,13 +96,13 @@ class host_tasks(UI_driver):
ip.append(str(last + 1))
return '.'.join(ip)
def load_file(self, path):
with open(path, 'r') as file_d:
content = file_d.read()
return content
def load_csr(self, path):
# ENHANCEMENT: generate csr dynamically
with open(path, 'r') as csr_file:
csr = csr_file.read()
return csr
@pytest.mark.tier1
class test_host(host_tasks):
@screenshot
@@ -132,147 +130,49 @@ class test_host(host_tasks):
self.skip('CSR file is not configured')
self.init_app()
# ENHANCEMENT: generate csr dynamically
csr = self.load_file(csr_path)
cert_widget_sel = "div.certificate-widget"
csr = self.load_csr(csr_path)
panel = 'cert_actions'
realm = self.config.get('ipa_realm')
self.add_record(ENTITY, self.data)
self.navigate_to_record(self.pkey)
self.assert_visible("div[name='certificate-missing']")
# cert request
self.action_list_action('request_cert', confirm=False)
self.assert_dialog()
self.fill_text("textarea[name='csr']", csr)
self.fill_text('textarea.certificate', csr)
self.dialog_button_click('issue')
self.wait_for_request(n=2, d=3)
self.assert_visible(cert_widget_sel)
self.wait_for_request(n=2, d=0.5)
self.assert_visible("div[name='certificate-valid']")
# cert view
self.action_list_action('view', confirm=False,
parents_css_sel=cert_widget_sel)
self.assert_dialog()
self.action_list_action('view_cert', confirm=False)
self.wait()
self.assert_text("tbody tr:nth-child(2) td:nth-child(2)", self.pkey)
self.assert_text("tbody tr:nth-child(3) td:nth-child(2)", realm)
self.dialog_button_click('close')
# cert get
self.action_list_action('get', confirm=False,
parents_css_sel=cert_widget_sel)
self.assert_dialog()
# check that the textarea is not empty
self.assert_empty_value('textarea.certificate', negative=True)
self.action_list_action('get_cert', confirm=False)
self.wait()
# We don't know the cert text, so at least open and close the dialog
self.dialog_button_click('close')
# cert download - we can only try to click the download action
self.action_list_action('download', confirm=False,
parents_css_sel=cert_widget_sel)
# check that revoke action is enabled
self.assert_action_list_action('revoke',
parents_css_sel=cert_widget_sel,
facet_actions=False)
# check that remove_hold action is not enabled
self.assert_action_list_action('remove_hold', enabled=False,
parents_css_sel=cert_widget_sel,
facet_actions=False)
# cert revoke
self.action_list_action('revoke', confirm=False,
parents_css_sel=cert_widget_sel)
self.action_list_action('revoke_cert', confirm=False)
self.wait()
self.select('select', '6')
self.dialog_button_click('ok')
self.wait_for_request(n=2, d=3)
self.assert_visible(cert_widget_sel + " div.watermark")
self.wait_for_request(n=2)
self.assert_visible("div[name='certificate-revoked']")
# check that revoke action is not enabled
self.assert_action_list_action('revoke', enabled=False,
parents_css_sel=cert_widget_sel,
facet_actions=False)
# check that remove_hold action is enabled
self.assert_action_list_action('remove_hold',
parents_css_sel=cert_widget_sel,
facet_actions=False)
# cert remove hold
self.action_list_action('remove_hold', confirm=False,
parents_css_sel=cert_widget_sel)
# cert restore
self.action_list_action('restore_cert', confirm=False)
self.wait()
self.dialog_button_click('ok')
self.wait_for_request(n=2)
# check that revoke action is enabled
self.assert_action_list_action('revoke',
parents_css_sel=cert_widget_sel,
facet_actions=False)
# check that remove_hold action is not enabled
self.assert_action_list_action('remove_hold', enabled=False,
parents_css_sel=cert_widget_sel,
facet_actions=False)
# cleanup
self.navigate_to_entity(ENTITY, 'search')
self.delete_record(self.pkey, self.data.get('del'))
@screenshot
def test_arbitrary_certificates(self):
"""
Test managing host arbitrary certificate.
Requires to have 'arbitrary_cert_path' configuration set.
"""
cert_path = self.config.get('arbitrary_cert_path')
if not cert_path:
self.skip('Arbitrary certificate file is not configured')
self.init_app()
cert = self.load_file(cert_path)
self.add_record(ENTITY, self.data)
self.navigate_to_record(self.pkey)
# check whether certificate section is present
self.assert_visible("div[name='certificate']")
# add certificate
self.button_click('add', parents_css_sel="div[name='certificate']")
self.assert_dialog()
self.fill_textarea('new_cert', cert)
self.dialog_button_click('add')
self.assert_visible("div.certificate-widget")
# cert view
self.action_list_action('view', confirm=False,
parents_css_sel="div.certificate-widget")
self.assert_dialog()
self.dialog_button_click('close')
# cert get
self.action_list_action('get', confirm=False,
parents_css_sel="div.certificate-widget")
self.assert_dialog()
# check that the textarea is not empty
self.assert_empty_value('textarea.certificate', negative=True)
self.dialog_button_click('close')
# cert download - we can only try to click the download action
self.action_list_action('download', confirm=False,
parents_css_sel="div.certificate-widget")
# check that revoke action is not enabled
self.assert_action_list_action(
'revoke', enabled=False,
parents_css_sel="div.certificate-widget",
facet_actions=False)
# check that remove_hold action is not enabled
self.assert_action_list_action(
'remove_hold', enabled=False,
parents_css_sel="div.certificate-widget",
facet_actions=False)
self.assert_visible("div[name='certificate-valid']")
# cleanup
self.navigate_to_entity(ENTITY, 'search')
@@ -292,6 +192,11 @@ class test_host(host_tasks):
self.navigate_to_record(self.pkey)
self.assert_action_list_action('request_cert', visible=False)
self.assert_action_list_action('revoke_cert', visible=False)
self.assert_action_list_action('restore_cert', visible=False)
self.assert_action_list_action('view_cert', enabled=False)
self.assert_action_list_action('get_cert', enabled=False)
self.navigate_by_breadcrumb('Hosts')
self.delete_record(self.pkey, self.data.get('del'))