summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas ROCHE <nroche@entrouvert.com>2020-03-18 08:05:14 (GMT)
committerNicolas ROCHE <nroche@entrouvert.com>2020-03-18 09:28:11 (GMT)
commit5e731e5b593141dd98952e013a6d6eff0e995abc (patch)
tree4179562ac7498aeb2683181f7c146a582028ff9a
parent8b939a281edd7b334771fbc398655f05d3affa48 (diff)
downloadwelco-5e731e5b593141dd98952e013a6d6eff0e995abc.zip
welco-5e731e5b593141dd98952e013a6d6eff0e995abc.tar.gz
welco-5e731e5b593141dd98952e013a6d6eff0e995abc.tar.bz2
templates: add a login template (#40802)
-rw-r--r--tests/test_manager.py48
-rw-r--r--welco/templates/welco/login.html10
-rw-r--r--welco/views.py2
3 files changed, 59 insertions, 1 deletions
diff --git a/tests/test_manager.py b/tests/test_manager.py
new file mode 100644
index 0000000..49db243
--- /dev/null
+++ b/tests/test_manager.py
@@ -0,0 +1,48 @@
+# welco - multichannel request processing
+# Copyright (C) 2020 Entr'ouvert
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+import pytest
+
+def login(app, username='toto', password='toto'):
+ login_page = app.get('/login/')
+ login_form = login_page.forms[0]
+ login_form['username'] = username
+ login_form['password'] = password
+ resp = login_form.submit()
+ assert resp.status_int == 302
+ return app
+
+
+@pytest.fixture
+def logged_app(app, user):
+ return login(app)
+
+
+def test_unlogged_access(app):
+ # connect while not being logged in
+ assert app.get('/', status=302).location.endswith('/login/?next=/')
+
+
+def test_access(logged_app, mail_group):
+ resp = logged_app.get('/', status=302)
+ assert resp.location == 'mail/'
+
+
+def test_logout(logged_app):
+ app = logged_app
+ app.get('/logout/')
+ assert app.get('/', status=302).location.endswith('/login/?next=/')
diff --git a/welco/templates/welco/login.html b/welco/templates/welco/login.html
new file mode 100644
index 0000000..9718ac1
--- /dev/null
+++ b/welco/templates/welco/login.html
@@ -0,0 +1,10 @@
+{% extends "welco/base.html" %}
+{% load i18n %}
+
+{% block content %}
+<form method="post">
+ {% csrf_token %}
+ {{ form }}
+ <button>{% trans 'Log in' %}</button>
+</form>
+{% endblock %}
diff --git a/welco/views.py b/welco/views.py
index 62768bc..db06010 100644
--- a/welco/views.py
+++ b/welco/views.py
@@ -53,7 +53,7 @@ def login(request, *args, **kwargs):
return HttpResponseRedirect(resolve_url('mellon_login'))
return HttpResponseRedirect(resolve_url('mellon_login') + '?next='
+ quote(request.GET.get('next')))
- return auth_views.login(request, *args, **kwargs)
+ return auth_views.login(request, template_name='welco/login.html')
def logout(request, next_page=None):
if any(get_idps()):