Force login
===========

This tests forcing a login when a custom header is added.  The admin
header checked for is X_FORCE_LOGIN by default.  This can be useful
for example to only allow access to a preview site for known users
before making it available to the general public.  For how to add a
custom header, see ploneadmin_header.txt

First, some standard setup again.

    >>> from Products.Five.testbrowser import Browser
    >>> portal_url = portal.absolute_url()
    >>> browser = Browser()
    >>> browser.handleErrors = False
    >>> self.portal.error_log._ignored_exceptions = ()

And we make sure we are logged out:

   >>> browser.open(portal_url + '/logout')
 
You might already be logged in via LDAP or Single Sign On, otherwise
you will get redirected to the login form.  In the tests this
apparently does not function transparantly, as it just raises the
Unauthorized exception:

    >>> browser.open(portal_url + '?X_FORCE_LOGIN=on')
    Traceback (most recent call last):
    ...
    Unauthorized...
    >>> portal.getCurrentSkinName()
    'Monty Python Skin'

That is fine.  Now we login and try again:

    >>> from Products.PloneTestCase.setup import portal_owner, default_password
    >>> browser.open(portal_url + '/login_form')
    >>> browser.getControl(name='__ac_name').value = portal_owner
    >>> browser.getControl(name='__ac_password').value = default_password
    >>> browser.getControl(name='submit').click()
    >>> browser.open(portal_url + '?X_FORCE_LOGIN=on')
    >>> browser.url
    'http://nohost/plone?X_FORCE_LOGIN=on'
    >>> portal.getCurrentSkinName()
    'Monty Python Skin'
    >>> browser.open(portal_url + '/logout')
