|
1 |
# welco - multichannel request processing
|
|
2 |
# Copyright (C) 2020 Entr'ouvert
|
|
3 |
#
|
|
4 |
# This program is free software: you can redistribute it and/or modify it
|
|
5 |
# under the terms of the GNU Affero General Public License as published
|
|
6 |
# by the Free Software Foundation, either version 3 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU Affero General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU Affero General Public License
|
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16 |
|
|
17 |
|
|
18 |
import pytest
|
|
19 |
|
|
20 |
def login(app, username='toto', password='toto'):
|
|
21 |
login_page = app.get('/login/')
|
|
22 |
login_form = login_page.forms[0]
|
|
23 |
login_form['username'] = username
|
|
24 |
login_form['password'] = password
|
|
25 |
resp = login_form.submit()
|
|
26 |
assert resp.status_int == 302
|
|
27 |
return app
|
|
28 |
|
|
29 |
|
|
30 |
@pytest.fixture
|
|
31 |
def logged_app(app, user):
|
|
32 |
return login(app)
|
|
33 |
|
|
34 |
|
|
35 |
def test_unlogged_access(app):
|
|
36 |
# connect while not being logged in
|
|
37 |
assert app.get('/', status=302).location.endswith('/login/?next=/')
|
|
38 |
|
|
39 |
|
|
40 |
def test_access(logged_app, mail_group):
|
|
41 |
resp = logged_app.get('/', status=302)
|
|
42 |
assert resp.location == 'mail/'
|
|
43 |
|
|
44 |
|
|
45 |
def test_logout(logged_app):
|
|
46 |
app = logged_app
|
|
47 |
app.get('/logout/')
|
|
48 |
assert app.get('/', status=302).location.endswith('/login/?next=/')
|