Integration test for showing logout message (password change)

This replaces the unit test that had to be disabled.

Change-Id: I0921bd1164a10d0d33a8f00e522ae47ebdf4887e
Closes-Bug: #1333144
This commit is contained in:
Julie Pichon 2014-06-24 16:19:22 +01:00
parent d7a13e90dd
commit 11c21626c0
4 changed files with 34 additions and 26 deletions

View File

@ -19,7 +19,7 @@
</div>
{% endif %}
{% if request.COOKIES.logout_reason %}
<div class="form-group clearfix error">
<div class="form-group clearfix error" id="logout_reason">
<span class="help-block alert alert-danger"><p>{{ request.COOKIES.logout_reason }}</p></span>
</div>
{% endif %}

View File

@ -55,24 +55,6 @@ class ChangePasswordTests(test.TestCase):
self.assertFormError(res, "form", None, ['Passwords do not match.'])
# TODO(jpichon): Temporarily disabled, see bug #1333144
@unittest.skip("Temporarily disabled, see bug #1333144")
@test.create_stubs({api.keystone: ('user_update_own_password', )})
def test_change_password_shows_message_on_login_page(self):
api.keystone.user_update_own_password(IsA(http.HttpRequest),
'oldpwd',
'normalpwd').AndReturn(None)
self.mox.ReplayAll()
formData = {'method': 'PasswordForm',
'current_password': 'oldpwd',
'new_password': 'normalpwd',
'confirm_password': 'normalpwd'}
res = self.client.post(INDEX_URL, formData, follow=True)
info_msg = "Password changed. Please log in again to continue."
self.assertContains(res, info_msg)
@unittest.skipUnless(django.VERSION[0] >= 1 and django.VERSION[1] >= 6,
"'HttpResponseRedirect' object has no attribute "
"'url' prior to Django 1.6")

View File

@ -25,6 +25,7 @@ class LoginPage(pageobject.PageObject):
_login_password_field_locator = (by.By.CSS_SELECTOR, '#id_password')
_login_submit_button_locator = (by.By.CSS_SELECTOR,
'div.modal-footer button.btn')
_login_logout_reason_locator = (by.By.CSS_SELECTOR, '#logout_reason')
def __init__(self, driver, conf):
super(LoginPage, self).__init__(driver, conf)
@ -52,6 +53,9 @@ class LoginPage(pageobject.PageObject):
def _press_enter_on_login_button(self):
self.login_button.send_keys(keys.Keys.RETURN)
def is_logout_reason_displayed(self):
return self._get_element(*self._login_logout_reason_locator)
def login(self, user=None, password=None):
return self.login_with_mouse_click(user, password)

View File

@ -17,6 +17,15 @@ NEW_PASSWORD = "123"
class TestPasswordChange(helpers.TestCase):
def _reset_password(self):
passwordchange_page = self.home_pg.go_to_settings_changepasswordpage()
passwordchange_page.reset_to_default_password(NEW_PASSWORD)
def _login(self):
self.login_pg.login()
self.assertTrue(self.home_pg.is_logged_in,
"Failed to login with default password")
def test_password_change(self):
"""Changes the password, verifies it was indeed changed and resets to
default password.
@ -31,11 +40,24 @@ class TestPasswordChange(helpers.TestCase):
user=self.conf.identity.username, password=NEW_PASSWORD)
self.assertTrue(self.home_pg.is_logged_in,
"Failed to login with new password")
settings_page = self.home_pg.go_to_settings_usersettingspage()
passwordchange_page = settings_page.\
go_to_settings_changepasswordpage()
finally:
passwordchange_page.reset_to_default_password(NEW_PASSWORD)
self.login_pg.login()
self.assertTrue(self.home_pg.is_logged_in,
"Failed to login with default password")
self._reset_password()
self._login()
def test_show_message_after_logout(self):
"""Ensure an informational message is shown on the login page after the
user is logged out.
"""
passwordchange_page = self.home_pg.go_to_settings_changepasswordpage()
try:
passwordchange_page.change_password(self.conf.identity.password,
NEW_PASSWORD)
self.assertTrue(
self.login_pg.is_logout_reason_displayed(),
"The logout reason message was not found on the login page")
finally:
self.login_pg.login(user=self.conf.identity.username,
password=NEW_PASSWORD)
self._reset_password()
self._login()