comparison test/rest_common.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 d26d2590cd8c
children 6b6bc8d31caf
comparison
equal deleted inserted replaced
5667:5ad31de777a8 5668:a4bb88a1a643
339 # FIXME add tests for out of range once we decide what response 339 # FIXME add tests for out of range once we decide what response
340 # is needed to: 340 # is needed to:
341 # page_size < 0 341 # page_size < 0
342 # page_index < 0 342 # page_index < 0
343 343
344 def notestEtagGeneration(self):
345 ''' Make sure etag generation is stable
346
347 FIXME need to mock somehow date.Date() when creating
348 the target to be mocked. The differening dates makes
349 this test impossible.
350 '''
351 newuser = self.db.user.create(
352 username='john',
353 password=password.Password('random1'),
354 address='random1@home.org',
355 realname='JohnRandom',
356 roles='User,Admin'
357 )
358
359 node = self.db.user.getnode(self.joeid)
360 etag = calculate_etag(node)
361 items = node.items(protected=True) # include every item
362 print(repr(items))
363 print(etag)
364 self.assertEqual(etag, "6adf97f83acf6453d4a6a4b1070f3754")
365
366 etag = calculate_etag(self.db.issue.getnode("1"))
367 print(etag)
368 self.assertEqual(etag, "6adf97f83acf6453d4a6a4b1070f3754")
369
344 def testEtagProcessing(self): 370 def testEtagProcessing(self):
345 ''' 371 '''
346 Etags can come from two places: 372 Etags can come from two places:
347 ETag http header 373 ETag http header
348 @etags value posted in the form 374 @etags value posted in the form

Roundup Issue Tracker: http://roundup-tracker.org/