Added a regression test for strings generated by the old crypt() implementation

This commit is contained in:
Dominik
2016-03-03 22:06:08 +01:00
parent 82e924811e
commit c8f27768a4

View File

@@ -31,6 +31,8 @@ class TestCryptoUtils(unittest.TestCase):
# printable characters only but that would break backwards # printable characters only but that would break backwards
# compatibility with the (buggy) legacy implementation # compatibility with the (buggy) legacy implementation
self.protectedTestString = "2470356b322424504f63775949487224ffa330e33b2d76b82e91a4c88ff722414d3522bcbdb8a4a45cd7c61963b52825e1361354d5b5efbcfeabfb66fa3f97dfecd5e57617b8e0172017785f4001e9653366363763323639363965313261386363623738326435326639653563633339".decode('hex') self.protectedTestString = "2470356b322424504f63775949487224ffa330e33b2d76b82e91a4c88ff722414d3522bcbdb8a4a45cd7c61963b52825e1361354d5b5efbcfeabfb66fa3f97dfecd5e57617b8e0172017785f4001e9653366363763323639363965313261386363623738326435326639653563633339".decode('hex')
self.salt = "POcwYIHr"
self.cryptedWord = "2470356b322424504f63775949487224993c1d36e308d941d0fa240d18f4097ce8d0995226f04800".decode('hex')
def test_padding(self): def test_padding(self):
padded = append_padding(16, self.teststring) padded = append_padding(16, self.teststring)
@@ -46,5 +48,9 @@ class TestCryptoUtils(unittest.TestCase):
unprotectedString = read_protected_string(self.protectedTestString, self.testpass) unprotectedString = read_protected_string(self.protectedTestString, self.testpass)
self.assertEqual(unprotectedString, self.teststring) self.assertEqual(unprotectedString, self.teststring)
def test_crypt(self):
cryptedWord = crypt(self.teststring, self.salt, 400)
self.assertEqual(cryptedWord, self.cryptedWord)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()