From 3547cfff12884369660315ae3e730e19ec2289ab Mon Sep 17 00:00:00 2001 From: Hayk Hovsepyan Date: Wed, 24 Mar 2021 18:33:10 +0100 Subject: [PATCH] Adjusted Istio Config Creation Wizard. --- kiali_qe/components/__init__.py | 52 +++++++++++------------ kiali_qe/tests/__init__.py | 4 +- kiali_qe/tests/test_istio_objects_crud.py | 5 ++- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/kiali_qe/components/__init__.py b/kiali_qe/components/__init__.py index 1d83b5fb..e2007d1b 100644 --- a/kiali_qe/components/__init__.py +++ b/kiali_qe/components/__init__.py @@ -1269,16 +1269,18 @@ class ConfigActions(Actions): PORT_MTLS_MODE = '//div[contains(@class, "pf-c-form__group")]' +\ '//table//select[@name="addPortMtlsMode"]' ADD_VALUE = '//div[contains(@class, "pf-c-form__group")]//input[@id="addNewValues"]' - ADD_PORT = '//div[contains(@class, "pf-c-form__group")]//input[@id="addPortNumber"]' + ADD_PORT_NUMBER = '//div[contains(@class, "pf-c-form__group")]//input[@id="addPortNumber"]' + ADD_PORT_NAME = '//div[contains(@class, "pf-c-form__group")]//input[@id="addPortName"]' ADD_VALUE_BUTTON = '//div[contains(@class, "pf-c-form__group")]' +\ '//table//button[contains(@class, "pf-m-link")]' ADD_RULE_BUTTON = '//div[contains(@class, "pf-c-form__group")]' +\ '/div/button[contains(@class, "pf-m-link")]' CONFIG_CREATE_ROOT = '//*[contains(@class, "pf-c-form")]' - CREATE_ISTIO_CONFIG = 'Create New Istio Config' - ADD_SERVER_BUTTON = './/button[text()="Add Server"]' - ADD_PORT_MTLS_BUTTON = './/button[text()="Add Port MTLS"]' - ADD_EGRESS_HOST_BUTTON = './/button[text()="Add Egress Host"]' + ADD_SERVER_BUTTON = './/button//span[contains(@class, "pf-c-button__text")' +\ + ' and text()="Add Server to Server List"]' + ADD_PORT_MTLS_BUTTON = './/button[@id="addServerBtn"]' + ADD_EGRESS_HOST_BUTTON = './/td[contains(@data-label, "Egress Host")]/..//' +\ + 'button[contains(@class, "pf-m-link")]' def __init__(self, parent, locator=None, logger=None): Actions.__init__(self, parent, logger=logger) @@ -1286,15 +1288,13 @@ def __init__(self, parent, locator=None, logger=None): self.locator = locator else: self.locator = self.ROOT - self._istio_resource = SelectDropDown( - parent=self, locator=self.ISTIO_RESOURCE, select_button='') self._name = TextInput(parent=self, locator='//input[@id="name"]') - self._hosts = TextInput(parent=self, locator='//input[@id="addHosts"]') + self._hosts = TextInput(parent=self, locator='//input[@id="hosts"]') self._egress_host = TextInput(parent=self, locator='//input[@id="addEgressHost"]') - self._workloadselector_switch = ButtonSwitch(parent=self, label="Add Workload Selector") - self._jwtrules_switch = ButtonSwitch(parent=self, label="Add JWT Rules") - self._portmtls_switch = ButtonSwitch(parent=self, label="Add Port MTLS") + self._workloadselector_switch = ButtonSwitch(parent=self, label="Workload Selector") + self._jwtrules_switch = ButtonSwitch(parent=self, label="JWT Rules") + self._portmtls_switch = ButtonSwitch(parent=self, label="Port Mutual TLS") self._labels = TextInput(parent=self, locator='//input[@id="gwHosts"]') self._policy = SelectDropDown(parent=self, locator=self.POLICY, select_button='') self._policy_action = SelectDropDown(parent=self, @@ -1305,14 +1305,16 @@ def __init__(self, parent, locator=None, logger=None): locator=self.PORT_MTLS_MODE, select_button='') self._add_value = TextInput(parent=self, locator=self.ADD_VALUE) - self._add_port = TextInput(parent=self, locator=self.ADD_PORT) + self._add_port_number = TextInput(parent=self, locator=self.ADD_PORT_NUMBER) + self._add_port_name = TextInput(parent=self, locator=self.ADD_PORT_NAME) - def create_istio_config_gateway(self, name, hosts): + def create_istio_config_gateway(self, name, hosts, port_name, port_number): wait_to_spinner_disappear(self.browser) - self.select(self.CREATE_ISTIO_CONFIG) - self._istio_resource.select(IstioConfigObjectType.GATEWAY.text) + self.select(IstioConfigObjectType.GATEWAY.text) self._name.fill(name) self._hosts.fill(hosts) + self._add_port_number.fill(port_number) + self._add_port_name.fill(port_name) add_server_button = self.browser.element( parent=self.CONFIG_CREATE_ROOT, locator=(self.ADD_SERVER_BUTTON)) @@ -1328,8 +1330,7 @@ def create_istio_config_gateway(self, name, hosts): return True def create_istio_config_sidecar(self, name, egress_host, labels=None): - self.select(self.CREATE_ISTIO_CONFIG) - self._istio_resource.select(IstioConfigObjectType.SIDECAR.text) + self.select(IstioConfigObjectType.SIDECAR.text) self._name.fill(name) self._egress_host.fill(egress_host) self._add_workload_selector(labels) @@ -1348,9 +1349,8 @@ def create_istio_config_sidecar(self, name, egress_host, labels=None): return True def create_istio_config_authpolicy(self, name, policy, labels=None, policy_action=None): - self.select(self.CREATE_ISTIO_CONFIG) - wait_displayed(self._istio_resource) - self._istio_resource.select(IstioConfigObjectType.AUTHORIZATION_POLICY.text) + self.select(IstioConfigObjectType.AUTHORIZATION_POLICY.text) + wait_displayed(self._name) self._name.fill(name) self._policy.select(policy) self._add_workload_selector(labels) @@ -1369,16 +1369,15 @@ def create_istio_config_authpolicy(self, name, policy, labels=None, policy_actio def create_istio_config_peerauth(self, name, labels=None, mtls_mode=MutualTLSMode.UNSET, mtls_ports={}): - self.select(self.CREATE_ISTIO_CONFIG) - wait_displayed(self._istio_resource) - self._istio_resource.select(IstioConfigObjectType.PEER_AUTHENTICATION.text) + self.select(IstioConfigObjectType.PEER_AUTHENTICATION.text) + wait_displayed(self._name) self._name.fill(name) self._mtls_mode.select(mtls_mode) self._add_workload_selector(labels) if mtls_ports: self._portmtls_switch.on() for _key, _value in mtls_ports.items(): - self._add_port.fill(_key) + self._add_port_number.fill(_key) self._port_mtls_mode.select(_value) add_value_button = self.browser.element( parent=self.CONFIG_CREATE_ROOT, @@ -1396,9 +1395,8 @@ def create_istio_config_peerauth(self, name, labels=None, return True def create_istio_config_requestauth(self, name, labels=None, jwt_rules={}): - self.select(self.CREATE_ISTIO_CONFIG) - wait_displayed(self._istio_resource) - self._istio_resource.select(IstioConfigObjectType.REQUEST_AUTHENTICATION.text) + self.select(IstioConfigObjectType.REQUEST_AUTHENTICATION.text) + wait_displayed(self._name) self._name.fill(name) self._add_workload_selector(labels) if jwt_rules: diff --git a/kiali_qe/tests/__init__.py b/kiali_qe/tests/__init__.py index 8bbc408a..06668c64 100644 --- a/kiali_qe/tests/__init__.py +++ b/kiali_qe/tests/__init__.py @@ -2235,14 +2235,14 @@ def _is_skip_key(self, key): or 'managedFields' in key \ or 'creationTimestamp' in key - def test_gateway_create(self, name, hosts, namespaces): + def test_gateway_create(self, name, hosts, port_name, port_number, namespaces): logger.debug('Creating Gateway: {}, from namespaces: {}'.format(name, namespaces)) # load the page first self.page.load(force_load=True) # apply namespace self.apply_namespaces(namespaces=namespaces) wait_to_spinner_disappear(self.browser) - self.page.actions.create_istio_config_gateway(name, hosts) + self.page.actions.create_istio_config_gateway(name, hosts, port_name, port_number) for namespace in namespaces: self.assert_details(name, IstioConfigObjectType.GATEWAY.text, namespace) diff --git a/kiali_qe/tests/test_istio_objects_crud.py b/kiali_qe/tests/test_istio_objects_crud.py index c8f2aaa1..9b6e55fe 100644 --- a/kiali_qe/tests/test_istio_objects_crud.py +++ b/kiali_qe/tests/test_istio_objects_crud.py @@ -385,7 +385,8 @@ def test_gateway_create(kiali_client, openshift_client, browser, pick_namespace) _delete_gateways(openshift_client, gateway_name, namespaces) tests = IstioConfigPageTest( kiali_client=kiali_client, openshift_client=openshift_client, browser=browser) - tests.test_gateway_create(gateway_name, 'www.google.com', namespaces=namespaces) + tests.test_gateway_create(gateway_name, 'www.google.com', 'http', '8080', + namespaces=namespaces) finally: _delete_gateways(openshift_client, gateway_name, namespaces) @@ -400,7 +401,7 @@ def test_sidecar_create(kiali_client, openshift_client, browser, pick_namespace) _delete_sidecars(openshift_client, sidecar_name, namespaces) tests = IstioConfigPageTest( kiali_client=kiali_client, openshift_client=openshift_client, browser=browser) - tests.test_sidecar_create(name=sidecar_name, egress_host='bookinfo/details', + tests.test_sidecar_create(name=sidecar_name, egress_host='bookinfo/*', labels='=', namespaces=namespaces) finally: _delete_sidecars(openshift_client, sidecar_name, namespaces)