web/test/windmill/test_connexion.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 12 Aug 2010 10:12:52 +0200
changeset 6102 27c47d239739
parent 6034 5e8076eb8ec7
child 6695 b714521ac66d
permissions -rw-r--r--
backport stable
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     1
from cubicweb.devtools import DEFAULT_SOURCES
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     2
LOGIN, PASSWORD = DEFAULT_SOURCES['admin'].values()
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     3
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     4
# Generated by the windmill services transformer
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     5
from windmill.authoring import WindmillTestClient
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     6
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     7
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     8
def test_connect():
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     9
    client = WindmillTestClient(__name__)
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    10
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    11
    client.open(url=u'/')
6034
5e8076eb8ec7 tests: use larger timeouts in windmill tests
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    12
    client.waits.forPageLoad(timeout=u'20000')
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    13
    client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    14
    client.type(text=LOGIN, id=u'__login')
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    15
    client.type(text=PASSWORD, id=u'__password')
6034
5e8076eb8ec7 tests: use larger timeouts in windmill tests
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    16
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    17
    client.execJS(js=u"$('#loginForm').submit()")
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    18
    client.waits.forPageLoad(timeout=u'20000')
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    19
    client.asserts.assertJS(js=u'$(\'.message\').text() == "welcome %s !"' % LOGIN)
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    20
    client.open(url=u'/logout')
6034
5e8076eb8ec7 tests: use larger timeouts in windmill tests
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    21
    client.waits.forPageLoad(timeout=u'20000')
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    22
    client.open(url=u'/')
6034
5e8076eb8ec7 tests: use larger timeouts in windmill tests
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    23
    client.waits.forPageLoad(timeout=u'20000')
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    24
    client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    25
6034
5e8076eb8ec7 tests: use larger timeouts in windmill tests
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    26
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    27
def test_wrong_connect():
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    28
    client = WindmillTestClient(__name__)
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    29
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    30
    client.open(url=u'/')
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    31
    # XXX windmill wants to use its proxy internally on 403 :-(
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    32
    #client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    33
    #client.type(text=LOGIN, id=u'__login')
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    34
    #client.type(text=u'novalidpassword', id=u'__password')
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    35
    #client.click(value=u'log in')
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    36
    client.open(url=u'/?__login=user&__password=nopassword')
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    37
    client.waits.forPageLoad(timeout=u'20000')
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    38
    client.asserts.assertTextIn(validator=u'authentication failure', id=u'loginBox')
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    39
    client.open(url=u'/')
6034
5e8076eb8ec7 tests: use larger timeouts in windmill tests
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    40
    client.waits.forPageLoad(timeout=u'20000')
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    41
    client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")