示例#1
0
 def test_bad_username(self):
     #  Simple match.
     form = RegisterForm({'username': '******',
                          'password': '******',
                          'password2': 'adssadfsadf1',
                          'email': '*****@*****.**'})
     assert not form.is_valid()
     # Simple obfuscation.
     form = RegisterForm({'username': '******',
                          'password': '******',
                          'password2': 'adssadfsadf1',
                          'email': '*****@*****.**'})
     assert not form.is_valid()
     # Partial match.
     form = RegisterForm({'username': '******',
                          'password': '******',
                          'password2': 'adssadfsadf1',
                          'email': '*****@*****.**'})
     assert not form.is_valid()
     # Plus sign
     form = RegisterForm({'username': '******',
                          'password': '******',
                          'password2': 'adssadfsadf1',
                          'email': '*****@*****.**'})
     assert not form.is_valid()
     # No match.
     form = RegisterForm({'username': '******',
                          'password': '******',
                          'password2': 'adssadfsadf1',
                          'email': '*****@*****.**'})
     assert form.is_valid()
示例#2
0
def handle_register(request, text_template=None, html_template=None,
                    subject=None, email_data=None, *args, **kwargs):
    """Handle to help registration."""
    if request.method == 'POST':
        form = RegisterForm(request.POST)
        if form.is_valid():
            form = try_send_email_with_form(
                RegistrationProfile.objects.create_inactive_user,
                form, 'email',
                form.cleaned_data['username'],
                form.cleaned_data['password'],
                form.cleaned_data['email'],
                locale=request.LANGUAGE_CODE,
                text_template=text_template,
                html_template=html_template,
                subject=subject,
                email_data=email_data,
                volunteer_interest=form.cleaned_data['interested'],
                *args, **kwargs)
            if not form.is_valid():
                # Delete user if form is not valid, i.e. email was not sent.
                # This is in a POST request and so always pinned to master,
                # so there is no race condition.
                User.objects.filter(email=form.instance.email).delete()
            else:
                statsd.incr('user.register')
        return form
    return RegisterForm()
示例#3
0
 def test_bad_username(self):
     #  Simple match.
     form = RegisterForm(
         {"username": "******", "password": "******", "password2": "adssadfsadf1", "email": "*****@*****.**"}
     )
     assert not form.is_valid()
     # Simple obfuscation.
     form = RegisterForm(
         {
             "username": "******",
             "password": "******",
             "password2": "adssadfsadf1",
             "email": "*****@*****.**",
         }
     )
     assert not form.is_valid()
     # Partial match.
     form = RegisterForm(
         {
             "username": "******",
             "password": "******",
             "password2": "adssadfsadf1",
             "email": "*****@*****.**",
         }
     )
     assert not form.is_valid()
     # No match.
     form = RegisterForm(
         {
             "username": "******",
             "password": "******",
             "password2": "adssadfsadf1",
             "email": "*****@*****.**",
         }
     )
     assert form.is_valid()
示例#4
0
 def test_strong_password(self):
     form = RegisterForm({'username': '******',
                          'password': '******',
                          'password2': 'fksjvaj1',
                          'email': '*****@*****.**'})
     assert form.is_valid()
示例#5
0
 def test_common_password(self):
     form = RegisterForm({'username': '******',
                          'password': '******',
                          'password2': 'password',
                          'email': '*****@*****.**'})
     assert not form.is_valid()
示例#6
0
 def test_strong_password(self):
     form = RegisterForm(
         {"username": "******", "password": "******", "password2": "fksjvaj1", "email": "*****@*****.**"}
     )
     assert form.is_valid()
示例#7
0
 def test_common_password(self):
     form = RegisterForm(
         {"username": "******", "password": "******", "password2": "password", "email": "*****@*****.**"}
     )
     assert not form.is_valid()