Example #1
0
 def test_password_mismatch(self):
     person, form_data = self._valid_change()
     form_data['new2'] = '!invalid!'
     form = forms.AdminPasswordChangeForm(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.')]}))
Example #2
0
 def test_password_simple(self):
     person, form_data = self._valid_change()
     form_data['new1'] = 'qwerty'
     form_data['new2'] = 'qwerty'
     form = forms.AdminPasswordChangeForm(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.')]
         })
     )
Example #3
0
 def test_password_short(self):
     person, form_data = self._valid_change()
     form_data['new1'] = 'abc'
     form_data['new2'] = 'abc'
     form = forms.AdminPasswordChangeForm(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.AdminPasswordChangeForm(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.AdminPasswordChangeForm(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')