Exemple #1
0
 def test_changes_one_password(self):
     username = factory.make_username()
     password = factory.make_string(size=16, spaces=True, prefix="password")
     user = factory.make_User(username=username, password=password)
     self.assertTrue(user.check_password(password))
     newpass = factory.make_string(size=16, spaces=True, prefix="newpass")
     stdin = io.StringIO("%s:%s" % (username, newpass))
     self.patch(changepasswords, "fileinput").return_value = stdin
     call_command("changepasswords")
     self.assertTrue(reload_object(user).check_password(newpass))
Exemple #2
0
 def test_changes_ten_passwords(self):
     users_passwords = []
     stringio = io.StringIO()
     for _ in range(10):
         username = factory.make_username()
         user = factory.make_User(username=username)
         newpass = factory.make_string(spaces=True, prefix="newpass")
         users_passwords.append((user, newpass))
         stringio.write("%s:%s\n" % (username, newpass))
     stringio.seek(0)
     self.patch(changepasswords, "fileinput").return_value = stringio
     call_command("changepasswords")
     for user, newpass in users_passwords:
         self.assertTrue(reload_object(user).check_password(newpass))