summaryrefslogtreecommitdiff
path: root/tests/test_hashsums.py
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2014-11-06 21:21:44 +0100
committerMichael Vogt <mvo@ubuntu.com>2014-11-06 21:21:44 +0100
commitb066cf677e2cbd480bd2e74b48147bfd226ae463 (patch)
treea1fbb341f7ce2da1aba509bfd1e093db32a13f3f /tests/test_hashsums.py
parentf619b8891b5ee052cc15913729ef081cf0e2f913 (diff)
downloadpython-apt-b066cf677e2cbd480bd2e74b48147bfd226ae463.tar.gz
add apt_pkg.sha512sum()
Diffstat (limited to 'tests/test_hashsums.py')
-rw-r--r--tests/test_hashsums.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_hashsums.py b/tests/test_hashsums.py
index 1819e343..bd2dba91 100644
--- a/tests/test_hashsums.py
+++ b/tests/test_hashsums.py
@@ -66,5 +66,30 @@ class testHashes(unittest.TestCase):
with open(self.DATA_WITH_ZERO_PATH) as fobj:
self.assertEqual(apt_pkg.sha256sum(fobj), s_hash)
+ def testSHA512(self):
+ # simple
+ s = b"foo"
+ s_hash = \
+ "f7fbba6e0636f890e56fbbf3283e524c6fa3204ae298382d624741d" \
+ "0dc6638326e282c41be5e4254d8820772c5518a2c5a8c0c7f7eda19" \
+ "594a7eb539453e1ed7"
+ res = apt_pkg.sha512sum(s)
+ self.assertEqual(res, s_hash)
+ # file
+ with open(self.DATA_PATH) as fobj:
+ self.assertEqual(apt_pkg.sha512sum(fobj), s_hash)
+ # with zero (\0) in the string
+ s = b"foo\0bar"
+ s_hash = \
+ "8c5e791db8f6bfb40eba884f70c9ac52231f01a393e4e55b4576d45" \
+ "9a827f34f77e41e7fac806724517b9e96bb42387c5f9bbf325d2f99" \
+ "ed52a4aa6abebc3350"
+ res = apt_pkg.sha512sum(s)
+ self.assertEqual(res, s_hash)
+ # file
+ with open(self.DATA_WITH_ZERO_PATH) as fobj:
+ self.assertEqual(apt_pkg.sha512sum(fobj), s_hash)
+
+
if __name__ == "__main__":
unittest.main()