aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tests/test_auth.py
diff options
context:
space:
mode:
authorLoic Dachary <loic@dachary.org>2016-01-12 18:39:28 +0100
committerChristopher Allan Webber <cwebber@dustycloud.org>2016-01-21 11:56:41 -0800
commitbbe085565166059157957030feea9fefa2a0d835 (patch)
tree28d55f3b710a38b2b22673e4100506d530d36753 /mediagoblin/tests/test_auth.py
parent2fdc14a2424d7687358598441db8bcfd8fe9eb69 (diff)
downloadmediagoblin-bbe085565166059157957030feea9fefa2a0d835.tar.lz
mediagoblin-bbe085565166059157957030feea9fefa2a0d835.tar.xz
mediagoblin-bbe085565166059157957030feea9fefa2a0d835.zip
Fix #1096 - allow - in usernames
Signed-off-by: Loic Dachary <loic@dachary.org>
Diffstat (limited to 'mediagoblin/tests/test_auth.py')
-rw-r--r--mediagoblin/tests/test_auth.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/mediagoblin/tests/test_auth.py b/mediagoblin/tests/test_auth.py
index 62f77f74..cb971fdb 100644
--- a/mediagoblin/tests/test_auth.py
+++ b/mediagoblin/tests/test_auth.py
@@ -80,9 +80,31 @@ def test_register_views(test_app):
assert form.username.errors == [u'This field does not take email addresses.']
assert form.email.errors == [u'This field requires an email address.']
+ ## invalid characters
+ template.clear_test_template_context()
+ test_app.post(
+ '/auth/register/', {
+ 'username': 'ampersand&invalid',
+ 'email': 'easter@egg.com'})
+ context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/register.html']
+ form = context['register_form']
+
+ assert form.username.errors == [u'Invalid input.']
+
## At this point there should be no users in the database ;)
assert User.query.count() == 0
+ ## mixture of characters from all valid ranges
+ template.clear_test_template_context()
+ test_app.post(
+ '/auth/register/', {
+ 'username': 'Jean-Louis1_Le-Chat',
+ 'password': 'iamsohappy',
+ 'email': 'easter@egg.com'})
+
+ ## At this point there should on user in the database
+ assert User.query.count() == 1
+
# Successful register
# -------------------
template.clear_test_template_context()
@@ -115,7 +137,7 @@ def test_register_views(test_app):
assert request.session['user_id'] == six.text_type(new_user.id)
## Make sure we get email confirmation, and try verifying
- assert len(mail.EMAIL_TEST_INBOX) == 1
+ assert len(mail.EMAIL_TEST_INBOX) == 2
message = mail.EMAIL_TEST_INBOX.pop()
assert message['To'] == 'angrygrrl@example.org'
email_context = template.TEMPLATE_TEST_CONTEXT[
@@ -187,7 +209,7 @@ def test_register_views(test_app):
assert 'mediagoblin/auth/login.html' in template.TEMPLATE_TEST_CONTEXT
## Make sure link to change password is sent by email
- assert len(mail.EMAIL_TEST_INBOX) == 1
+ assert len(mail.EMAIL_TEST_INBOX) == 2
message = mail.EMAIL_TEST_INBOX.pop()
assert message['To'] == 'angrygrrl@example.org'
email_context = template.TEMPLATE_TEST_CONTEXT[