comparison test/test_liveserver.py @ 8268:05d8806b25ad

fix: issue2551387 - TypeError: not indexable. Fix crash due to uninitialized list element on a (Mini)FieldStorage when unexpected input is posted via wsgi. This doesn't happen when running roundup-server. It might happen under other front ends. Moved the code that sets '.list = [] if .list == None' to the main flow. Added an exception hander that logs the value of self.form if self.form.list raises an AttributeError. This exception should never happen if I understand the code correctly (but I probably don't). Fixed a number of test cases that were broken because I was calling Client and passing '[]' rather than a cgi.formStorage object. Added test cases: create a FileStorage (self.form) with .list = None. check AttributeError exception and verify logging. Problem reported and debugged by Christof Meerwald.
author John Rouillard <rouilj@ieee.org>
date Sun, 12 Jan 2025 12:34:52 -0500
parents 35beff316883
children c70ffbc2a003
comparison
equal deleted inserted replaced
8267:7f0c7966d204 8268:05d8806b25ad
331 self.assertEqual(cookie.name, 'roundup_session_Roundupissuetracker') 331 self.assertEqual(cookie.name, 'roundup_session_Roundupissuetracker')
332 self.assertEqual(cookie.expires, None) # session cookie 332 self.assertEqual(cookie.expires, None) # session cookie
333 self.assertEqual(cookie._rest['HttpOnly'], None) # flag is present 333 self.assertEqual(cookie._rest['HttpOnly'], None) # flag is present
334 self.assertEqual(cookie._rest['SameSite'], 'Lax') 334 self.assertEqual(cookie._rest['SameSite'], 'Lax')
335 335
336 def test_bad_post_data(self):
337 """issue2551387 - bad post data causes TypeError: not indexable
338 """
339 session, _response = self.create_login_session()
340
341 h = {"Content-Type": "text/plain"}
342 response = session.post(self.url_base()+'/', headers=h, data="test")
343 print(response.status_code)
344 print(response.headers)
345 print(response.text)
346 self.assertEqual(response.status_code, 200)
347
336 def test_query(self): 348 def test_query(self):
337 current_user_query = ( 349 current_user_query = (
338 "@columns=title,id,activity,status,assignedto&" 350 "@columns=title,id,activity,status,assignedto&"
339 "@sort=activity&@group=priority&@filter=creator&" 351 "@sort=activity&@group=priority&@filter=creator&"
340 "@pagesize=50&@startwith=0&creator=%40current_user&" 352 "@pagesize=50&@startwith=0&creator=%40current_user&"

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