From 0419b0e2e6a276b7dc08c99375617b795c5989af Mon Sep 17 00:00:00 2001 From: Timur Sufiev Date: Fri, 5 Feb 2016 13:23:21 +0300 Subject: [PATCH] Ensure that integration tests are being run in proper project Admin users run tests in an admin project, regular users run them in a demo project. That should prevent situations when tests don't have an access to a resources created in a project different from the current one. Closes-Bug: #1542211 Change-Id: I497648ce5126e187744b5795bd524b7aba22c7a6 --- openstack_dashboard/test/integration_tests/config.py | 7 +++++++ openstack_dashboard/test/integration_tests/helpers.py | 8 ++++++++ openstack_dashboard/test/integration_tests/horizon.conf | 6 ++++++ .../test/integration_tests/regions/bars.py | 5 +++-- .../test/integration_tests/regions/menus.py | 4 ++-- .../test/integration_tests/tests/test_instances.py | 2 -- 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/openstack_dashboard/test/integration_tests/config.py b/openstack_dashboard/test/integration_tests/config.py index a88abec08b..a0662c4e0b 100644 --- a/openstack_dashboard/test/integration_tests/config.py +++ b/openstack_dashboard/test/integration_tests/config.py @@ -32,6 +32,10 @@ IdentityGroup = [ default='secretadmin', help="API key to use when authenticating.", secret=True), + cfg.StrOpt('home_project', + default='demo', + help="Project to keep all objects belonging to a regular user." + ), cfg.StrOpt('admin_username', default='admin', help="Administrative Username to use for admin API " @@ -40,6 +44,9 @@ IdentityGroup = [ default='secretadmin', help="API key to use when authenticating as admin.", secret=True), + cfg.StrOpt('admin_home_project', + default='admin', + help="Project to keep all objects belonging to an admin user."), ] ImageGroup = [ diff --git a/openstack_dashboard/test/integration_tests/helpers.py b/openstack_dashboard/test/integration_tests/helpers.py index f627632a32..95ecd82181 100644 --- a/openstack_dashboard/test/integration_tests/helpers.py +++ b/openstack_dashboard/test/integration_tests/helpers.py @@ -26,6 +26,7 @@ import xvfbwrapper from horizon.test import webdriver from openstack_dashboard.test.integration_tests import config from openstack_dashboard.test.integration_tests.pages import loginpage +from openstack_dashboard.test.integration_tests.regions import messages ROOT_PATH = os.path.dirname(os.path.abspath(config.__file__)) @@ -181,6 +182,7 @@ class TestCase(BaseTestCase): TEST_USER_NAME = BaseTestCase.CONFIG.identity.username TEST_PASSWORD = BaseTestCase.CONFIG.identity.password + HOME_PROJECT = BaseTestCase.CONFIG.identity.home_project def setUp(self): super(TestCase, self).setUp() @@ -189,6 +191,11 @@ class TestCase(BaseTestCase): self.zoom_out() self.home_pg = self.login_pg.login(self.TEST_USER_NAME, self.TEST_PASSWORD) + self.home_pg.change_project(self.HOME_PROJECT) + self.assertTrue( + self.home_pg.find_message_and_dismiss(messages.SUCCESS)) + self.assertFalse( + self.home_pg.find_message_and_dismiss(messages.ERROR)) def tearDown(self): try: @@ -203,3 +210,4 @@ class AdminTestCase(TestCase): TEST_USER_NAME = TestCase.CONFIG.identity.admin_username TEST_PASSWORD = TestCase.CONFIG.identity.admin_password + HOME_PROJECT = BaseTestCase.CONFIG.identity.admin_home_project diff --git a/openstack_dashboard/test/integration_tests/horizon.conf b/openstack_dashboard/test/integration_tests/horizon.conf index 9c3dc996f1..1da8357de7 100644 --- a/openstack_dashboard/test/integration_tests/horizon.conf +++ b/openstack_dashboard/test/integration_tests/horizon.conf @@ -43,6 +43,9 @@ username=demo # API key to use when authenticating. (string value) password=secretadmin +# Project in which a regular user creates everything by default +home_project=demo + # Administrative Username to use for admin API requests. # (string value) admin_username=admin @@ -50,6 +53,9 @@ admin_username=admin # API key to use when authenticating as admin. (string value) admin_password=secretadmin +# Project in which an admin user creates everything by default +admin_home_project=admin + [network] # The cidr block to allocate tenant ipv4 subnets from (string value) tenant_network_cidr=10.100.0.0/16 diff --git a/openstack_dashboard/test/integration_tests/regions/bars.py b/openstack_dashboard/test/integration_tests/regions/bars.py index 4bde621e35..b95fb74e4c 100644 --- a/openstack_dashboard/test/integration_tests/regions/bars.py +++ b/openstack_dashboard/test/integration_tests/regions/bars.py @@ -21,8 +21,9 @@ class TopBarRegion(baseregion.BaseRegion): '.nav.navbar-nav.navbar-right li.dropdown') _openstack_brand_locator = (by.By.CSS_SELECTOR, 'a[href*="/home/"]') - _user_dropdown_project_locator = (by.By.CSS_SELECTOR, - 'li.dropdown.context-selection') + _user_dropdown_project_locator = ( + by.By.CSS_SELECTOR, + '.navbar-collapse > ul.navbar-nav:first-child li.dropdown') @property def user(self): diff --git a/openstack_dashboard/test/integration_tests/regions/menus.py b/openstack_dashboard/test/integration_tests/regions/menus.py index 1d94813711..8029444762 100644 --- a/openstack_dashboard/test/integration_tests/regions/menus.py +++ b/openstack_dashboard/test/integration_tests/regions/menus.py @@ -248,8 +248,8 @@ class TabbedMenuRegion(baseregion.BaseRegion): class ProjectDropDownRegion(DropDownMenuRegion): _menu_first_child_locator = (by.By.CSS_SELECTOR, '*') - _menu_items_locator = (by.By.CSS_SELECTOR, - 'div.context-lists a') + _menu_items_locator = ( + by.By.CSS_SELECTOR, 'ul.context-selection li > a') def click_on_project(self, name): for item in self.menu_items: diff --git a/openstack_dashboard/test/integration_tests/tests/test_instances.py b/openstack_dashboard/test/integration_tests/tests/test_instances.py index f16e3ce4e3..2f19c88c56 100644 --- a/openstack_dashboard/test/integration_tests/tests/test_instances.py +++ b/openstack_dashboard/test/integration_tests/tests/test_instances.py @@ -9,7 +9,6 @@ # 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 openstack_dashboard.test.integration_tests import decorators from openstack_dashboard.test.integration_tests import helpers from openstack_dashboard.test.integration_tests.regions import messages @@ -17,7 +16,6 @@ INSTANCES_NAME = helpers.gen_random_resource_name('instance', timestamp=False) -@decorators.skip_because(bugs=["1542211"]) class TestInstances(helpers.AdminTestCase): """This is a basic scenario to test: * Create Instance and Delete Instance