Revision b4adb15b
Adaptation au changement de comportement de webob/webchanges/webtest.
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@4267 b22e2e97-25c9-44ff-b637-2e5ceca36478
vigiboard/tests/__init__.py | ||
---|---|---|
30 | 30 |
class TestController(unittest.TestCase): |
31 | 31 |
""" |
32 | 32 |
Base functional test case for the controllers. |
33 |
|
|
34 |
The vigiboard application instance (``self.app``) set up in this test
|
|
33 |
|
|
34 |
The vigiboard application instance (``self.app``) set up in this test |
|
35 | 35 |
case (and descendants) has authentication disabled, so that developers can |
36 | 36 |
test the protected areas independently of the :mod:`repoze.who` plugins |
37 | 37 |
used initially. This way, authentication can be tested once and separately. |
38 |
|
|
38 |
|
|
39 | 39 |
Check vigiboard.tests.functional.test_authentication for the repoze.who |
40 | 40 |
integration tests. |
41 |
|
|
41 |
|
|
42 | 42 |
This is the officially supported way to test protected areas with |
43 | 43 |
repoze.who-testutil (http://code.gustavonarea.net/repoze.who-testutil/). |
44 |
|
|
44 |
|
|
45 | 45 |
""" |
46 |
|
|
46 |
|
|
47 | 47 |
application_under_test = 'main_without_authn' |
48 | 48 |
|
49 | 49 |
def setUp(self): |
... | ... | |
63 | 63 |
# Cleaning up the database: |
64 | 64 |
teardown_db() |
65 | 65 |
del self.app |
66 |
|
vigiboard/tests/functional/test_authentication.py | ||
---|---|---|
13 | 13 |
class TestAuthentication(TestController): |
14 | 14 |
""" |
15 | 15 |
Tests for the default authentication setup. |
16 |
|
|
16 |
|
|
17 | 17 |
By default in TurboGears 2, :mod:`repoze.who` is configured with the same |
18 | 18 |
plugins specified by repoze.what-quickstart (which are listed in |
19 | 19 |
http://code.gustavonarea.net/repoze.what-quickstart/#repoze.what.plugins.quickstart.setup_sql_auth). |
20 |
|
|
20 |
|
|
21 | 21 |
As the settings for those plugins change, or the plugins are replaced, |
22 | 22 |
these tests should be updated. |
23 |
|
|
23 |
|
|
24 | 24 |
""" |
25 |
|
|
25 |
|
|
26 | 26 |
application_under_test = 'main' |
27 | 27 |
|
28 | 28 |
def test_voluntary_login(self): |
... | ... | |
35 | 35 |
form['password'] = u'managepass' |
36 | 36 |
post_login = form.submit(status=302) |
37 | 37 |
# Being redirected to the home page: |
38 |
assert post_login.location.startswith('http://localhost/post_login')
|
|
38 |
assert post_login.location.startswith('/post_login') |
|
39 | 39 |
home_page = post_login.follow(status=302) |
40 | 40 |
assert 'authtkt' in home_page.request.cookies, \ |
41 | 41 |
'Session cookie was not defined: %s' % home_page.request.cookies |
42 |
assert home_page.location == 'http://localhost/'
|
|
42 |
assert home_page.location == '/' |
|
43 | 43 |
|
44 | 44 |
def test_logout(self): |
45 | 45 |
"""Logouts must work correctly""" |
... | ... | |
51 | 51 |
'Session cookie was not defined: %s' % resp.request.cookies |
52 | 52 |
# Logging out: |
53 | 53 |
resp = self.app.get('/logout_handler', status=302) |
54 |
assert resp.location.startswith('http://localhost/post_logout')
|
|
54 |
assert resp.location.startswith('/post_logout') |
|
55 | 55 |
# Finally, redirected to the home page: |
56 | 56 |
home_page = resp.follow(status=302) |
57 | 57 |
assert home_page.request.cookies.get('authtkt') == '', \ |
58 | 58 |
'Session cookie was not deleted: %s' % home_page.request.cookies |
59 |
assert home_page.location == 'http://localhost/', home_page.location |
|
60 |
|
|
59 |
assert home_page.location == '/', home_page.location |
Also available in: Unified diff