Bläddra i källkod

Fix failing tests with new crypto_engine

oz123 10 år sedan
förälder
incheckning
0f5ac04ffb
2 ändrade filer med 5 tillägg och 6 borttagningar
  1. 0 1
      pwman/tests/db_tests.py
  2. 5 5
      pwman/util/crypto_engine.py

+ 0 - 1
pwman/tests/db_tests.py

@@ -107,7 +107,6 @@ class DBTests(unittest.TestCase):
         password = u'Password'
         url = u'example.org'
         notes = u'some notes'
-        # node = NewNode(username, password, url, notes)
         node = NewNode()
         node.username = username
         node.password = password

+ 5 - 5
pwman/util/crypto_engine.py

@@ -212,7 +212,7 @@ class CryptoEngine(object):  # pagma: no cover
         finish the execution an return the password and salt which
         are read from the file.
         """
-        salt, digest = get_digest_from_file('passwords.txt')
+        salt, digest = self._salt, self._digest
         tries = 0
         while tries < 5:
             password = self._getsecret("Please type in your master password:"
@@ -222,7 +222,6 @@ class CryptoEngine(object):  # pagma: no cover
 
             print("You entered a wrong password...")
             tries += 1
-
         raise CryptoException("You entered wrong password 5 times..")
 
     def encrypt(self, text):
@@ -236,7 +235,7 @@ class CryptoEngine(object):  # pagma: no cover
 
     def decrypt(self, cipher_text):
         if not self._is_authenticated():
-            p, s = cli_auth(self._reader)
+            p, s = self._auth()
             cipher = get_cipher(p, s)
             del(p)
             return DecodeAES(cipher, prepare_data(cipher_text, AES.block_size))
@@ -307,13 +306,14 @@ class CryptoEngine(object):  # pagma: no cover
         # TODO: rename this method!
         salt, digest = key.split('$6$')
         self._digest = digest.encode('utf-8')
-        self._salt = salt.encode('utf-8'),
+        self._salt = salt.encode('utf-8')
+
     def get_cryptedkey(self):
         # TODO: rename this method!
         """
         return _keycrypted
         """
-        return self._keycrypted
+        return self._salt + '$6$' + self._digest
 
 
 if __name__ == '__main__':  # pragma: no cover