Fix MD5 hash formatting

This commit is contained in:
Simeon Warner 2017-03-20 17:08:44 -04:00
parent e0b9e24b6b
commit 941cba41b1
4 changed files with 9 additions and 8 deletions

View File

@ -6,11 +6,12 @@ core specification version. Versions 1.0.x implement the v1.0
ResourceSync specification which was standardized as ANSI/NISO Z39.99-2014
<http://www.openarchives.org/rs/1.0/toc>.
v1.0.6 2017-??-??
* ...
v1.0.6 2017-03-20
* Fixed md5 hash format (https://github.com/resync/resync/issues/25)
* Added support for sha-1 and sha-256 hashes
v1.0.5 2017-01-30
* Fix to support non-ASCII URIs/filenames (https://github.com/resync/resync/issues/22)
* Fixed to support non-ASCII URIs/filenames (https://github.com/resync/resync/issues/22)
* Added tests for Python 3.6
* Temporarily disabled tests for Python 2.6 due to problems with coverage (https://github.com/resync/resync/issues/23)

View File

@ -87,7 +87,7 @@ class Hashes(object):
"""Return MD5 hash calculated."""
if (self.md5_calc is None):
return None
return base64.b64encode(self.md5_calc.digest()).decode('utf-8')
return self.md5_calc.hexdigest()
@property
def sha1(self):

View File

@ -7,7 +7,7 @@ class TestUtill(unittest.TestCase):
def test01_md5_sha1_file(self):
h = resync.hashes.Hashes(['md5', 'sha-1'])
h.compute_for_file('tests/testdata/a')
self.assertEqual(h.md5, 'j912liHgA/48DCHpkptJHg==')
self.assertEqual(h.md5, '8fdd769621e003fe3c0c21e9929b491e')
self.assertEqual(h.sha1, '49844dd211aa33071a252d7cdc250a52cf39af33')
self.assertEqual(h.sha256, None)
h = resync.hashes.Hashes(['sha-256', 'sha-1'])

View File

@ -67,13 +67,13 @@ class TestResourceListBuilder(unittest.TestCase):
r = next(rli)
self.assertEqual(r.uri, 'http://example.org/t/file_a')
self.assertEqual(r.lastmod, '2012-07-25T17:13:46Z')
self.assertEqual(r.md5, 'a/Jv1mYBtSjS4LR+qoft/Q==')
self.assertEqual(r.md5, '6bf26fd66601b528d2e0b47eaa87edfd')
self.assertEqual(r.length, 20)
self.assertEqual(r.path, None)
r = next(rli)
self.assertEqual(r.uri, 'http://example.org/t/file_b')
self.assertEqual(r.lastmod, '2001-09-09T01:46:40Z')
self.assertEqual(r.md5, 'RS5Uva4WJqxdbnvoGzneIQ==')
self.assertEqual(r.md5, '452e54bdae1626ac5d6e7be81b39de21')
self.assertEqual(r.length, 45)
self.assertEqual(r.path, None)
@ -86,7 +86,7 @@ class TestResourceListBuilder(unittest.TestCase):
self.assertTrue(r is not None)
self.assertEqual(r.uri, 'http://example.org/t/file_a')
self.assertEqual(r.lastmod, '2012-07-25T17:13:46Z')
self.assertEqual(r.md5, 'a/Jv1mYBtSjS4LR+qoft/Q==')
self.assertEqual(r.md5, '6bf26fd66601b528d2e0b47eaa87edfd')
self.assertEqual(r.path, 'tests/testdata/dir1/file_a')
def test05_from_disk_paths(self):