aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin
diff options
context:
space:
mode:
authorJonathan Sandoval <jsandoval@utp.edu.co>2016-04-07 16:29:15 -0500
committerJonathan Sandoval <jsandoval@utp.edu.co>2016-04-07 16:29:15 -0500
commitbf2f121a83bc646f43fe1214e4aab038b8487eda (patch)
tree4709a098316eb1e495e8dd5ec124385db67387f3 /mediagoblin
parentd75620654193858abb346bbb10cd23a81b47219d (diff)
downloadmediagoblin-bf2f121a83bc646f43fe1214e4aab038b8487eda.tar.lz
mediagoblin-bf2f121a83bc646f43fe1214e4aab038b8487eda.tar.xz
mediagoblin-bf2f121a83bc646f43fe1214e4aab038b8487eda.zip
Tests for short and long usernames.
Diffstat (limited to 'mediagoblin')
-rw-r--r--mediagoblin/tests/test_auth.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/mediagoblin/tests/test_auth.py b/mediagoblin/tests/test_auth.py
index 544cf4e0..618d02b6 100644
--- a/mediagoblin/tests/test_auth.py
+++ b/mediagoblin/tests/test_auth.py
@@ -373,7 +373,7 @@ def test_authentication_views(test_app):
assert form.username.data == u'andrew'
# Successful login with short user
- # ----------------
+ # --------------------------------
short_user = fixture_add_user(username=u'me', password=u'sho')
template.clear_test_template_context()
response = test_app.post(
@@ -381,11 +381,9 @@ def test_authentication_views(test_app):
'username': u'me',
'password': 'sho'})
- context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/login.html']
- form = context['login_form']
# User should be redirected
- print('errors are', form.username.errors)
response.follow()
+
assert urlparse.urlsplit(response.location)[2] == '/'
assert 'mediagoblin/root.html' in template.TEMPLATE_TEST_CONTEXT
@@ -394,6 +392,10 @@ def test_authentication_views(test_app):
session = context['request'].session
assert session['user_id'] == six.text_type(short_user.id)
+ # Must logout
+ template.clear_test_template_context()
+ response = test_app.get('/auth/logout/')
+
# Successful login with long user
# ----------------
long_user = fixture_add_user(
@@ -401,13 +403,10 @@ def test_authentication_views(test_app):
template.clear_test_template_context()
response = test_app.post(
'/auth/login/', {
- 'username': u'me',
+ 'username': u'realllylonguser@reallylongdomain.com.co',
'password': 'sho'})
- context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/login.html']
- form = context['login_form']
# User should be redirected
- print('errors are', form.username.errors)
response.follow()
assert urlparse.urlsplit(response.location)[2] == '/'
assert 'mediagoblin/root.html' in template.TEMPLATE_TEST_CONTEXT
@@ -415,7 +414,10 @@ def test_authentication_views(test_app):
# Make sure user is in the session
context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/root.html']
session = context['request'].session
- assert session['user_id'] == six.text_type(short_user.id)
+ assert session['user_id'] == six.text_type(long_user.id)
+
+ template.clear_test_template_context()
+ response = test_app.get('/auth/logout/')
@pytest.fixture()
def authentication_disabled_app(request):