Exemple #1
0
 def test_password_old_password_wrong(self):
     person, form_data = self._valid_change()
     form_data['old'] = 'abc'
     form = forms.PasswordChangeForm(data=form_data, person=person)
     self.assertEqual(form.is_valid(), False)
     self.assertEqual(
         form.errors.items(),
         dict.items({'old': [six.u('Your old password was incorrect')]}))
Exemple #2
0
 def test_password_mismatch(self):
     person, form_data = self._valid_change()
     form_data['new2'] = '!invalid!'
     form = forms.PasswordChangeForm(data=form_data, person=person)
     self.assertEqual(form.is_valid(), False)
     self.assertEqual(
         form.errors.items(),
         dict.items(
             {'new2': [six.u('The two password fields didn\'t match.')]}))
Exemple #3
0
 def test_password_simple(self):
     person, form_data = self._valid_change()
     form_data['new1'] = 'qwerty'
     form_data['new2'] = 'qwerty'
     form = forms.PasswordChangeForm(data=form_data, person=person)
     self.assertEqual(form.is_valid(), False)
     self.assertEqual(
         form.errors.items(),
         dict.items({
             'new2': [six.u(
                 'Your password was found to be insecure: '
                 'it is based on a dictionary word.')]
         })
     )
Exemple #4
0
 def test_password_short(self):
     person, form_data = self._valid_change()
     form_data['new1'] = 'abc'
     form_data['new2'] = 'abc'
     form = forms.PasswordChangeForm(data=form_data, person=person)
     self.assertEqual(form.is_valid(), False)
     self.assertEqual(
         form.errors.items(),
         dict.items({
             'new2': [six.u(
                 'Your password was found to be insecure: '
                 'Password must be at least 6 characters long.')]
         })
     )
 def test_password_simple(self):
     person, form_data = self._valid_change()
     form_data['new1'] = 'qwerty'
     form_data['new2'] = 'qwerty'
     form = forms.PasswordChangeForm(data=form_data, person=person)
     self.assertEqual(form.is_valid(), False)
     self.assertEqual(
         form.errors.items(),
         dict.items({
             'new2': [six.u(
                 'Your password was found to be insecure: '
                 'it is based on a dictionary word. '
                 'A good password has a combination of '
                 'letters (uppercase, lowercase), numbers '
                 'and is at least 8 characters long.')]
         })
     )
 def test_valid_data(self):
     person, form_data = self._valid_change()
     form = forms.PasswordChangeForm(data=form_data, person=person)
     self.assertEqual(form.is_valid(), True, form.errors.items())
     self.assertEqual(form.cleaned_data['new1'], 'wai5bixa8Igohxa')
     self.assertEqual(form.cleaned_data['new2'], 'wai5bixa8Igohxa')