Files
horizon/openstack_dashboard/test/integration_tests/pages/project/apiaccesspage.py
panneer.smn 15574cad5c Integration test fixes
* fixed 37 tests in total
* restructured and renamed test modules as per horizon
* fixed page navigation & updated method calls
* fixed css selector and xpaths as per horizon
* Removed decorators.skip for working tests
* included decorators.skip for non - working tests
* updated description for tests as per horizon navigation
* removed *update flavor info* and *update flavor access* test, as feature unavailable on horizon
* updated table column name references in page modules
* updated bind table action names as per horizon
* included help page navigation checkpoint
* fixed rc file download drop down selection
* updated page titles in test modules
* included calls as required for spinner disappearance
* updated form fields as per test needs
* updated default ipv4 and subnet for router interfaces
* included string conversion as required for comparisons
* updated cirros image name in horizon.conf

Change-Id: I9fdc810b37443b616bbb82956d1c90a0fa5ebd6b
2018-06-21 10:59:31 +03:00

82 lines
3.1 KiB
Python

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from os import listdir
from os.path import isfile
from os.path import join
from re import search
from openstack_dashboard.test.integration_tests.pages import basepage
from openstack_dashboard.test.integration_tests.regions import tables
class ApiAccessTable(tables.TableRegion):
name = "endpoints"
dropdown = 'Download OpenStack'
def download_rcfile_dropdown(self):
self.driver.find_element_by_partial_link_text(
self.dropdown).click()
@tables.bind_table_action('download_openrc_v2')
def download_openstack_rc_v2(self, download_button):
self.download_rcfile_dropdown()
download_button.click()
@tables.bind_table_action('download_openrc')
def download_openstack_rc_v3(self, download_button):
self.download_rcfile_dropdown()
download_button.click()
class ApiaccessPage(basepage.BaseNavigationPage):
def __init__(self, driver, conf):
super(ApiaccessPage, self).__init__(driver, conf)
self._page_title = "API Access"
@property
def apiaccess_table(self):
return ApiAccessTable(self.driver, self.conf)
def download_openstack_rc_file(self, version, directory, template):
if version == 2:
self.apiaccess_table.download_openstack_rc_v2()
elif version == 3:
self.apiaccess_table.download_openstack_rc_v3()
def list_of_files(self, directory, template):
return [f for f in listdir(directory)
if (isfile(join(directory, f)) and
f.endswith(template))]
def get_credentials_from_file(self, version, directory, template):
self._wait_until(
lambda _: len(self.list_of_files(directory, template)) > 0)
file_name = self.list_of_files(directory, template)[0]
with open(join(directory, file_name)) as cred_file:
content = cred_file.read()
username_re = r'export OS_USERNAME="([^"]+)"'
if version == 2:
tenant_name_re = r'export OS_TENANT_NAME="([^"]+)"'
tenant_id_re = r'export OS_TENANT_ID=(.+)'
elif version == 3:
tenant_name_re = r'export OS_PROJECT_NAME="([^"]+)"'
tenant_id_re = r'export OS_PROJECT_ID=(.+)'
username = search(username_re, content).group(1)
tenant_name = search(tenant_name_re, content).group(1)
tenant_id = search(tenant_id_re, content).group(1)
cred_dict = {'OS_USERNAME': username,
'OS_TENANT_NAME': tenant_name,
'OS_TENANT_ID': tenant_id}
return cred_dict