Browse Source

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
changes/78/276678/7
Timur Sufiev 5 years ago
parent
commit
0419b0e2e6
6 changed files with 26 additions and 6 deletions
  1. +7
    -0
      openstack_dashboard/test/integration_tests/config.py
  2. +8
    -0
      openstack_dashboard/test/integration_tests/helpers.py
  3. +6
    -0
      openstack_dashboard/test/integration_tests/horizon.conf
  4. +3
    -2
      openstack_dashboard/test/integration_tests/regions/bars.py
  5. +2
    -2
      openstack_dashboard/test/integration_tests/regions/menus.py
  6. +0
    -2
      openstack_dashboard/test/integration_tests/tests/test_instances.py

+ 7
- 0
openstack_dashboard/test/integration_tests/config.py View File

@ -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 = [


+ 8
- 0
openstack_dashboard/test/integration_tests/helpers.py View File

@ -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

+ 6
- 0
openstack_dashboard/test/integration_tests/horizon.conf View File

@ -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


+ 3
- 2
openstack_dashboard/test/integration_tests/regions/bars.py View File

@ -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):


+ 2
- 2
openstack_dashboard/test/integration_tests/regions/menus.py View File

@ -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:


+ 0
- 2
openstack_dashboard/test/integration_tests/tests/test_instances.py View File

@ -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


Loading…
Cancel
Save