Ejemplo n.º 1
0
    def test_LoginForm_no_captcha_username_too_long(self):
        login_data = {'username': self.username_151, 'password': '******'}

        with self.settings(ENABLE_CAPTCHA=False):
            reload(tp_forms)
            login_form = tp_forms.LoginForm(login_data)
            self.assertFalse(login_form.is_valid())
Ejemplo n.º 2
0
    def test_LoginForm_no_captcha(self):

        login_data = {'username': '******', 'password': '******'}

        with self.settings(ENABLE_CAPTCHA=False):
            reload(tp_forms)
            login_form = tp_forms.LoginForm(login_data)
            self.assertTrue(login_form.is_valid())
Ejemplo n.º 3
0
 def test_LoginForm_invalid_password(self):
     login_data = {
         'username': '******',
         'password': '',
         'captcha_0': self.hashkey,
         'captcha_1': self.response
     }
     login_form = tp_forms.LoginForm(login_data)
     self.assertFalse(login_form.is_valid())
Ejemplo n.º 4
0
 def test_LoginForm_invalid_username(self):
     login_data = {
         'username': '******',
         'password': '******',
         'captcha_0': self.hashkey,
         'captcha_1': self.response
     }
     login_form = tp_forms.LoginForm(login_data)
     err_msg = "This value may contain only letters, numbers and @/./+/-/_ characters."
     self.assertEqual(login_form.errors['username'], [err_msg])
     self.assertFalse(login_form.is_valid())
Ejemplo n.º 5
0
 def test_LoginForm_invalid(self):
     login_invalid_data = {
         'username': '******',
         'password': '******',
         'captcha_0': self.hashkey,
         'captcha_1': ''
     }
     with self.settings(ENABLE_CAPTCHA=True):
         reload(tp_forms)
         login_form = tp_forms.LoginForm(login_invalid_data)
         self.assertFalse(login_form.is_valid())
Ejemplo n.º 6
0
    def test_LoginForm_recaptcha(self):
        os.environ['RECAPTCHA_DISABLE'] = 'True'
        login_data = {'username': '******', 'password': '******'}

        with self.settings(ENABLE_CAPTCHA=True,
                           RECAPTCHA_PRIVATE_KEY='my-fake-private-key',
                           RECAPTCHA_PUBLIC_KEY='my-fake-public-key'):
            reload(tp_forms)
            login_form = tp_forms.LoginForm(login_data)
            self.assertTrue(login_form.is_valid())

        del os.environ['RECAPTCHA_DISABLE']
Ejemplo n.º 7
0
    def test_LoginForm_simple_captcha(self):

        login_data = {
            'username': '******',
            'password': '******',
            'captcha_0': self.hashkey,
            'captcha_1': self.response
        }
        with self.settings(ENABLE_CAPTCHA=True,
                           RECAPTCHA_PRIVATE_KEY='',
                           RECAPTCHA_PUBLIC_KEY=''):
            reload(tp_forms)
            login_form = tp_forms.LoginForm(login_data)
            self.assertTrue(login_form.is_valid())