Exemple #1
0
    def test_check_old_password(self):
        """ Test login with old password """

        email = "*****@*****.**"
        password = "******"
        nonce = "450f3b902c1eeff97c97669339dd7c8a"

        user = User(username=email, email=email, password="******")
        user.save()

        models.OldPassword(user=user, old_password=old_pw_crypt(password, nonce), old_nonce=nonce).save()

        user = User.objects.get(username=email)

        try:
            old_password = models.OldPassword.objects.get(user=user)
        except:
            self.fail()

        """ Test simple db workings """
        self.failUnless(old_password.old_password == old_pw_crypt(password, old_password.old_nonce))

        auth_user = authenticate(username=email, password=password)

        """ Test for real! """
        self.failUnless(type(auth_user) == User)

        self.failUnless(auth_user.email == user.email)
Exemple #2
0
    def test_old_pw_crypt(self):
        """ Test old pw crypt function """
        pw = "Qwerty01"
        nonce = "d591d28621d98abe08124e4f42783943"
        end_hash = "789bedc01376ba0cbc1e5011b4f7d7e41981f1691808b663c877f43bad4a502b4cc1820a3d722e147f4dfdd9c78b61634dd33fc7517a595287fb6a3d46719f27"

        test_hash = old_pw_crypt(pw, nonce)
        #print test_hash

        self.failUnless(test_hash == end_hash)