testfunc/test/windmill/test_connexion.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 25 May 2011 10:58:43 +0200
branchstable
changeset 7428 5338d895b891
parent 7363 2293c49b290a
child 8696 0bb18407c053
permissions -rw-r--r--
[web session] fix session handling so we get a chance to have for instance the 'forgotpwd' feature working on a site where anonymous are not allowed fix several pbs: * we need a session id and a session cookie anyway, else subsequent http queries are unrelated * this imply some changes in the session attribution workflow for session without a cnx * some views/selectors must be fixed for cases where session has no cnx On the way, avoid unnecessary Redirect on successful login. closes #750543

from cubicweb.devtools import DEFAULT_SOURCES
LOGIN, PASSWORD = DEFAULT_SOURCES['admin'].values()

# Generated by the windmill services transformer
from windmill.authoring import WindmillTestClient

def test_connect():
    client = WindmillTestClient(__name__)

    client.open(url=u'/')
    client.waits.forPageLoad(timeout=u'20000')
    client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")
    client.type(text=LOGIN, id=u'__login')
    client.type(text=PASSWORD, id=u'__password')

    client.execJS(js=u"$('#loginForm').submit()")
    client.waits.forPageLoad(timeout=u'20000')
    client.waits.sleep(milliseconds=u'5000')
    client.asserts.assertJS(js=u'$(\'.message\').text() == "welcome %s !"' % LOGIN)
    client.open(url=u'/logout')
    client.waits.forPageLoad(timeout=u'20000')
    client.open(url=u'/')
    client.waits.forPageLoad(timeout=u'20000')
    client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")


def test_wrong_connect():
    client = WindmillTestClient(__name__)

    client.open(url=u'/')
    # XXX windmill wants to use its proxy internally on 403 :-(
    #client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")
    #client.type(text=LOGIN, id=u'__login')
    #client.type(text=u'novalidpassword', id=u'__password')
    #client.click(value=u'log in')
    client.open(url=u'/?__login=user&__password=nopassword')
    client.waits.forPageLoad(timeout=u'20000')
    client.asserts.assertTextIn(validator=u'authentication failure', id=u'loginBox')
    client.open(url=u'/')
    client.waits.forPageLoad(timeout=u'20000')
    client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")