Mercurial > p > roundup > code
diff roundup/rest.py @ 5668:a4bb88a1a643
A fix for https://issues.roundup-tracker.org/issue2551034
REST etag ordering.
Sort the items before performing the MD5 checksum. This puts the items
in the same order every time. I was able to restart the roundup-server
and get the same etag value on every restart after this patch.
Also the etag calculated using python2 and python3 are now the same.
I added a disabled test to try to validate that the etag is always the
same value. However there is no way to set the creation and activity
dates, so these fields are always different. This means the etag is
always different. If I can convince the database back end to use a
mocked date.Date.__init__ that returns the same date all the time I
can finish the test.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 23 Mar 2019 00:13:08 -0400 |
| parents | 5ceed592706e |
| children | 1e8f17090a33 |
line wrap: on
line diff
--- a/roundup/rest.py Sat Mar 23 00:02:03 2019 -0400 +++ b/roundup/rest.py Sat Mar 23 00:13:08 2019 -0400 @@ -132,7 +132,7 @@ ''' items = node.items(protected=True) # include every item - etag = md5(bs2b(repr(items))).hexdigest() + etag = md5(bs2b(repr(sorted(items)))).hexdigest() logger.debug("object=%s%s; tag=%s; repr=%s", classname, id, etag, repr(node.items(protected=True))) return etag @@ -1336,7 +1336,7 @@ summary.setdefault(status_name, []).append(issue_object) messages.append((num, issue_object)) - messages.sort(reverse=True) + sorted(messages, key=lambda tup: tup[0], reverse=True) result = { 'created': created,
