Merge "Adds keypair create,delete integration tests"
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
# Copyright 2014 Hewlett-Packard Development Company, L.P
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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 selenium.webdriver.common import by
|
||||||
|
|
||||||
|
from openstack_dashboard.test.integration_tests.pages import basepage
|
||||||
|
from openstack_dashboard.test.integration_tests.pages import keypairpage
|
||||||
|
|
||||||
|
|
||||||
|
class AccessSecurityPage(basepage.BasePage):
|
||||||
|
|
||||||
|
_keypair_link_locator = (
|
||||||
|
by.By.CSS_SELECTOR,
|
||||||
|
'a[href*="?tab=access_security_tabs__keypairs_tab"]')
|
||||||
|
|
||||||
|
def __init__(self, driver, conf):
|
||||||
|
super(AccessSecurityPage, self).__init__(driver, conf)
|
||||||
|
self._page_title = "Access & Security"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def keypair_link(self):
|
||||||
|
return self.get_element(*self._keypair_link_locator)
|
||||||
|
|
||||||
|
def _click_on_keypair_link(self):
|
||||||
|
self.keypair_link.click()
|
||||||
|
|
||||||
|
def go_to_keypair_page(self):
|
||||||
|
self._click_on_keypair_link()
|
||||||
|
return keypairpage.KeypairPage(self.driver, self.conf)
|
@@ -32,6 +32,10 @@ class BasePage(pageobject.PageObject):
|
|||||||
def is_logged_in(self):
|
def is_logged_in(self):
|
||||||
return self.topbar.is_logged_in
|
return self.topbar.is_logged_in
|
||||||
|
|
||||||
|
@property
|
||||||
|
def navaccordion(self):
|
||||||
|
return BasePage.NavigationAccordionRegion(self.driver, self.conf)
|
||||||
|
|
||||||
def go_to_login_page(self):
|
def go_to_login_page(self):
|
||||||
self.driver.get(self.login_url)
|
self.driver.get(self.login_url)
|
||||||
|
|
||||||
@@ -92,3 +96,26 @@ class BasePage(pageobject.PageObject):
|
|||||||
@property
|
@property
|
||||||
def is_logged_in(self):
|
def is_logged_in(self):
|
||||||
return self.is_element_visible(*self._user_indicator_locator)
|
return self.is_element_visible(*self._user_indicator_locator)
|
||||||
|
|
||||||
|
class NavigationAccordionRegion(pageobject.PageObject):
|
||||||
|
# TODO(sunlim): change Xpath to CSS
|
||||||
|
_project_bar_locator = (
|
||||||
|
by.By.XPATH,
|
||||||
|
".//*[@id='main_content']//div[contains(text(),'Project')]")
|
||||||
|
|
||||||
|
_project_access_security_locator = (
|
||||||
|
by.By.CSS_SELECTOR, 'a[href*="/project/access_and_security/"]')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def project_bar(self):
|
||||||
|
return self.get_element(*self._project_bar_locator)
|
||||||
|
|
||||||
|
def _click_on_project_bar(self):
|
||||||
|
self.project_bar.click()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def access_security(self):
|
||||||
|
return self.get_element(*self._project_access_security_locator)
|
||||||
|
|
||||||
|
def _click_on_access_security(self):
|
||||||
|
self.access_security.click()
|
||||||
|
@@ -0,0 +1,77 @@
|
|||||||
|
# Copyright 2014 Hewlett-Packard Development Company, L.P
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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 selenium.webdriver.common import by
|
||||||
|
|
||||||
|
from openstack_dashboard.test.integration_tests.pages import basepage
|
||||||
|
|
||||||
|
|
||||||
|
class KeypairPage(basepage.BasePage):
|
||||||
|
|
||||||
|
_keypair_create_button_locator = (by.By.CSS_SELECTOR,
|
||||||
|
'#keypairs__action_create')
|
||||||
|
_keypair_name_field_locator = (by.By.CSS_SELECTOR, '#id_name')
|
||||||
|
_keypair_submit_button_locator = (by.By.CSS_SELECTOR,
|
||||||
|
'.btn.btn-primary.pull-right')
|
||||||
|
_keypair_delete_cnf_button_locator = (by.By.CSS_SELECTOR,
|
||||||
|
'.btn.btn-primary')
|
||||||
|
|
||||||
|
def __init__(self, driver, conf):
|
||||||
|
super(KeypairPage, self).__init__(driver, conf)
|
||||||
|
self._page_title = "Access & Security"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def keypair_create(self):
|
||||||
|
return self.get_element(*self._keypair_create_button_locator)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def keypair_name_field(self):
|
||||||
|
return self.get_element(*self._keypair_name_field_locator)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def keypair_submit_button(self):
|
||||||
|
return self.get_element(*self._keypair_submit_button_locator)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def keypair_delete_cnf_button(self):
|
||||||
|
return self.get_element(*self._keypair_delete_cnf_button_locator)
|
||||||
|
|
||||||
|
def _click_on_keypair_create(self):
|
||||||
|
self.keypair_create.click()
|
||||||
|
|
||||||
|
def _click_on_keypair_submit_button(self):
|
||||||
|
self.keypair_submit_button.click()
|
||||||
|
|
||||||
|
def _click_on_keypair_delete_cnf_button(self):
|
||||||
|
self.keypair_delete_cnf_button.click()
|
||||||
|
|
||||||
|
def get_keypair_status(self, keypair_name):
|
||||||
|
keypair_locator = (by.By.CSS_SELECTOR,
|
||||||
|
'#keypairs__row__%s' % keypair_name)
|
||||||
|
keypair_status = self.is_element_present(*keypair_locator)
|
||||||
|
return keypair_status
|
||||||
|
|
||||||
|
def create_keypair(self, keypair_name):
|
||||||
|
self._click_on_keypair_create()
|
||||||
|
self.keypair_name_field.send_keys(keypair_name)
|
||||||
|
self._click_on_keypair_submit_button()
|
||||||
|
|
||||||
|
def delete_keypair(self, keypair_name):
|
||||||
|
keypair_delete_check_locator = (
|
||||||
|
by.By.CSS_SELECTOR,
|
||||||
|
"#keypairs__row_%s__action_delete" % keypair_name)
|
||||||
|
self.driver.find_element(
|
||||||
|
*keypair_delete_check_locator).click()
|
||||||
|
self._click_on_keypair_delete_cnf_button()
|
@@ -10,6 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from openstack_dashboard.test.integration_tests.pages import accesssecuritypage
|
||||||
from openstack_dashboard.test.integration_tests.pages import basepage
|
from openstack_dashboard.test.integration_tests.pages import basepage
|
||||||
from openstack_dashboard.test.integration_tests.pages import settingspage
|
from openstack_dashboard.test.integration_tests.pages import settingspage
|
||||||
|
|
||||||
@@ -23,3 +24,12 @@ class ProjectPage(basepage.BasePage):
|
|||||||
self.topbar.user_dropdown_menu.click()
|
self.topbar.user_dropdown_menu.click()
|
||||||
self.topbar.settings_link.click()
|
self.topbar.settings_link.click()
|
||||||
return settingspage.SettingsPage(self.driver, self.conf)
|
return settingspage.SettingsPage(self.driver, self.conf)
|
||||||
|
|
||||||
|
def go_to_accesssecurity_page(self):
|
||||||
|
access_security_locator_flag = self.is_element_visible(
|
||||||
|
self.navaccordion._project_access_security_locator)
|
||||||
|
if not access_security_locator_flag:
|
||||||
|
self.navaccordion.project_bar.click()
|
||||||
|
self.navaccordion.access_security.click()
|
||||||
|
return accesssecuritypage.AccessSecurityPage(
|
||||||
|
self.driver, self.conf)
|
||||||
|
@@ -0,0 +1,35 @@
|
|||||||
|
# Copyright 2014 Hewlett-Packard Development Company, L.P
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
import random
|
||||||
|
|
||||||
|
from openstack_dashboard.test.integration_tests import helpers
|
||||||
|
|
||||||
|
|
||||||
|
class TestKeypair(helpers.TestCase):
|
||||||
|
"""Checks that the user is able to create/delete keypair."""
|
||||||
|
KEYPAIR_NAME = 'horizonkeypair' + str(random.randint(0, 1000))
|
||||||
|
|
||||||
|
def test_keypair(self):
|
||||||
|
accesssecurity_page = self.home_pg.go_to_accesssecurity_page()
|
||||||
|
keypair_page = accesssecurity_page.go_to_keypair_page()
|
||||||
|
|
||||||
|
keypair_page.create_keypair(self.KEYPAIR_NAME)
|
||||||
|
accesssecurity_page = self.home_pg.go_to_accesssecurity_page()
|
||||||
|
keypair_page = accesssecurity_page.go_to_keypair_page()
|
||||||
|
self.assertTrue(keypair_page.get_keypair_status(self.KEYPAIR_NAME))
|
||||||
|
|
||||||
|
keypair_page.delete_keypair(self.KEYPAIR_NAME)
|
||||||
|
self.assertFalse(keypair_page.get_keypair_status(self.KEYPAIR_NAME))
|
Reference in New Issue
Block a user