Integration test - Create and delete user
integration tests to create user under Identity->Users Closes-Bug: #1403741 Closes-Bug: #1409061 Partially implements blueprint: selenium-integration-testing Partially implements blueprint: multi-user-concurrent-test Change-Id: I3f96cc4f51d496e83ef947d51a722e8cf67b2779
This commit is contained in:
parent
7cd59d1331
commit
6f28ada3b8
@ -0,0 +1,82 @@
|
||||
# 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.regions import forms
|
||||
from openstack_dashboard.test.integration_tests.regions import tables
|
||||
|
||||
|
||||
class UsersPage(basepage.BaseNavigationPage):
|
||||
|
||||
_users_table_locator = (by.By.CSS_SELECTOR, 'table#users')
|
||||
|
||||
USERS_TABLE_NAME_COLUMN_INDEX = 0
|
||||
|
||||
USERS_TABLE_ACTIONS = ("create_user", "delete_users")
|
||||
|
||||
USERS_TABLE_ROW_ACTIONS = {
|
||||
tables.ComplexActionRowRegion.PRIMARY_ACTION: "edit_user",
|
||||
tables.ComplexActionRowRegion.SECONDARY_ACTIONS: ("disable_user",
|
||||
"delete_user")
|
||||
}
|
||||
|
||||
CREATE_USER_FORM_FIELDS = ("name", "email", "password",
|
||||
"confirm_password", "project", "role")
|
||||
|
||||
def __init__(self, driver, conf):
|
||||
super(UsersPage, self).__init__(driver, conf)
|
||||
self._page_title = "Users"
|
||||
|
||||
def _get_row_with_user_name(self, name):
|
||||
return self.users_table.get_row(
|
||||
self.USERS_TABLE_NAME_COLUMN_INDEX, name)
|
||||
|
||||
@property
|
||||
def users_table(self):
|
||||
src_elem = self._get_element(*self._users_table_locator)
|
||||
return tables.ComplexActionTableRegion(self.driver,
|
||||
self.conf, src_elem,
|
||||
self.USERS_TABLE_ACTIONS,
|
||||
self.USERS_TABLE_ROW_ACTIONS
|
||||
)
|
||||
|
||||
@property
|
||||
def create_user_form(self):
|
||||
return forms.FormRegion(self.driver, self.conf, None,
|
||||
self.CREATE_USER_FORM_FIELDS)
|
||||
|
||||
@property
|
||||
def confirm_delete_users_form(self):
|
||||
return forms.BaseFormRegion(self.driver, self.conf, None)
|
||||
|
||||
def create_user(self, name, password,
|
||||
project, role, email=None):
|
||||
self.users_table.create_user.click()
|
||||
self.create_user_form.name.text = name
|
||||
if email is not None:
|
||||
self.create_user_form.email.text = email
|
||||
self.create_user_form.password.text = password
|
||||
self.create_user_form.confirm_password.text = password
|
||||
self.create_user_form.project.text = project
|
||||
self.create_user_form.role.text = role
|
||||
self.create_user_form.submit.click()
|
||||
|
||||
def delete_user(self, name):
|
||||
row = self._get_row_with_user_name(name)
|
||||
row.mark()
|
||||
self.users_table.delete_users.click()
|
||||
self.confirm_delete_users_form.submit.click()
|
||||
|
||||
def is_user_present(self, name):
|
||||
return bool(self._get_row_with_user_name(name))
|
@ -124,6 +124,12 @@ class PasswordInputFormFieldRegion(BaseTextFormFieldRegion):
|
||||
_element_locator = (by.By.CSS_SELECTOR, 'div > input[type=password]')
|
||||
|
||||
|
||||
class EmailInputFormFieldRegion(BaseTextFormFieldRegion):
|
||||
"""Email text input box."""
|
||||
|
||||
_element_locator = (by.By.ID, 'id_email')
|
||||
|
||||
|
||||
class TextAreaFormFieldRegion(BaseTextFormFieldRegion):
|
||||
"""Multi-line text input box."""
|
||||
|
||||
|
@ -0,0 +1,28 @@
|
||||
# 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 uuid
|
||||
|
||||
from openstack_dashboard.test.integration_tests import helpers
|
||||
|
||||
|
||||
class TestUser(helpers.AdminTestCase):
|
||||
|
||||
USER_NAME = "user_" + str(uuid.uuid4())
|
||||
|
||||
def test_create_delete_user(self):
|
||||
users_page = self.home_pg.go_to_identity_userspage()
|
||||
password = self.conf.identity.password
|
||||
users_page.create_user(self.USER_NAME, password=password,
|
||||
project='admin', role='admin')
|
||||
self.assertTrue(users_page.is_user_present(self.USER_NAME))
|
||||
users_page.delete_user(self.USER_NAME)
|
||||
self.assertFalse(users_page.is_user_present(self.USER_NAME))
|
Loading…
x
Reference in New Issue
Block a user