Testing the password form
=========================

This is about the 'change_password' form. This test will try to login as a Plone
user, change the password, logout and login with the new password.

    >>> view_name = '@@change-password'

Viewing this form should not be possible for anonymous users:

    >>> self.browser.open('http://nohost/plone/' + view_name)
    >>> 'Login Name' in self.browser.contents
    True


So let's login as Plone user:
    >>> self.browser.open('http://nohost/plone/')
    >>> self.browser.getLink('Log in').click()
    >>> self.browser.getControl('Login Name').value = 'test_user_1_'
    >>> self.browser.getControl('Password').value = 'secret'
    >>> self.browser.getControl('Log in').click()

Now we should be able to access the change password form:

    >>> self.browser.open('http://nohost/plone/' + view_name)
    >>> 'Login Name' in self.browser.contents
    False
    >>> self.browser.url.endswith(view_name)
    True

Let's try to change the password:

    >>> self.browser.getControl(name='form.current_password').value = 'secret'
    >>> self.browser.getControl(name='form.new_password').value = 'super-secret'
    >>> self.browser.getControl(name='form.new_password_ctl').value = 'super-secret'
    >>> self.browser.getControl(name="form.actions.reset_passwd").click()
    >>> 'Password changed' in self.browser.contents
    True

Okay the password has been changed, let's logout and login again with the new password.

    >>> self.browser.open('http://nohost/plone/logout')
    >>> self.browser.open('http://nohost/plone/')
    >>> self.browser.getLink('Log in').click()
    >>> self.browser.getControl('Login Name').value = 'test_user_1_'
    >>> self.browser.getControl('Password').value = 'super-secret'
    >>> self.browser.getControl('Log in').click()

If we are logged in the change password form is available

    >>> self.browser.open('http://nohost/plone/' + view_name)
    >>> 'Please log in' in self.browser.contents
    False