view test/pg_service.conf @ 8177:2967f37e73e4

refactor: issue2551289. invalid REST Accept header stops request Sending a POST, PUT (maybe PATCH) with an accept header that is not application/json or xml (if enabled) used to complete the request before throwing a 406 error. This was wrong. Now it reports an error without dispatching/processing the requested transaction. This is the first of a series of refactors of the dispatch method to make it faster and more readable by using return early pattern and extracting methods from the code. changes: The following now return 406 errors not 400 errors invalid version specified with @apiver in URL. invalid version specified with @apiver in payload body invalid version specified in accept headers as application/vnd.roundup.test-vz+json or version property Parsing the accept header returns a 400 when presented with a parameter without an = sign or other parse error. They used to return a 406 which is wrong since the header is malformed rather than having a value I can't respond to. Some error messages were made clearer. Results in the case of an error are proper json error object rather than text/plain strings. New test added for testdetermine_output_formatBadAccept that test the new method using the same test cases as for testDispatchBadAccept. I intend to extend the test coverage for determine_output_format to cover more cases. This should be a faster unit test than for dispatch. Removed .lower() calls for accept_mime_type as the input values are taken from the values in the __accepted_content_type dict which only has lower case values.
author John Rouillard <rouilj@ieee.org>
date Sun, 08 Dec 2024 01:09:34 -0500
parents 8147f6deac9f
children
line wrap: on
line source

[roundup_test_db]
host=127.0.0.1
port=5432
user=rounduptest
password=rounduptest
dbname=rounduptest

[roundup_test_schema]
host=127.0.0.1
port=5432
user=rounduptest_schema
password=rounduptest
dbname=rounduptest_schema
options=-c search_path=roundup_service_dev

[roundup_test_schema_bad]
host=127.0.0.1
port=5432
user=rounduptest_schema
password=rounduptest
dbname=rounduptest_schema
options=-c search_path= 


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