def test_should_not_raise_exception_when_password_meets_requirement(self):
        password = '******'
        password_checker = UserPasswordChecker(password)

        with self.assertRaisesRegexp(Exception, self.EXCEPTION_NOT_THROWN):
            password_checker.check()
            self.fail(self.EXCEPTION_NOT_THROWN)
Example #2
0
    def test_should_not_raise_exception_when_password_meets_requirement(self):
        password = "******"
        password_checker = UserPasswordChecker(password)

        with self.assertRaisesRegexp(Exception, self.EXCEPTION_NOT_THROWN):
            password_checker.check()
            self.fail(self.EXCEPTION_NOT_THROWN)
    def test_should_raise_exception_when_password_is_too_short(self):
        short_password = '******'
        password_checker = UserPasswordChecker(short_password)

        with self.assertRaisesRegexp(forms.ValidationError,
                                     UserPasswordChecker.PASSWORD_TOO_SHORT):
            password_checker.check()
    def test_should_raise_exception_when_password_does_not_have_any_character(
            self):
        password_without_character = '12345678'
        password_checker = UserPasswordChecker(password_without_character)

        with self.assertRaisesRegexp(
                forms.ValidationError,
                UserPasswordChecker.PASSWORD_WITHOUT_CHARACTER):
            password_checker.check()
    def test_should_raise_exception_when_password_does_not_have_any_number(
            self):
        password_without_number = 'abcdefghi'
        password_checker = UserPasswordChecker(password_without_number)

        with self.assertRaisesRegexp(
                forms.ValidationError,
                UserPasswordChecker.PASSWORD_WITHOUT_NUMBER):
            password_checker.check()
Example #6
0
    def test_should_raise_exception_when_password_does_not_have_any_character(self):
        password_without_character = "12345678"
        password_checker = UserPasswordChecker(password_without_character)

        with self.assertRaisesRegexp(forms.ValidationError, UserPasswordChecker.PASSWORD_WITHOUT_CHARACTER):
            password_checker.check()
Example #7
0
    def test_should_raise_exception_when_password_does_not_have_any_number(self):
        password_without_number = "abcdefghi"
        password_checker = UserPasswordChecker(password_without_number)

        with self.assertRaisesRegexp(forms.ValidationError, UserPasswordChecker.PASSWORD_WITHOUT_NUMBER):
            password_checker.check()
Example #8
0
    def test_should_raise_exception_when_password_is_too_short(self):
        short_password = "******"
        password_checker = UserPasswordChecker(short_password)

        with self.assertRaisesRegexp(forms.ValidationError, UserPasswordChecker.PASSWORD_TOO_SHORT):
            password_checker.check()
Example #9
0
 def clean_new_password1(self):
     password = self.cleaned_data.get('new_password1')
     UserPasswordChecker(password).check()
     return password