This PR aimed to alleviate the need to manually format and maintain log strings for numerous verify_token calls within routes, and to instead allow Starlette's Request class to handle the heavy lifting.
The build_route_log_string method does exactly what it sounds like- it accepts a Request object along with a list of strings that you would like to not show up in the logs (tokens, anyone?), and generates a string for the logs. The output will be something similar to as follows:
The *** portion of the string is a substring that was elected to be censored.
This will allow us to keep the log formatting synchronized across all routes and make it a breeze to adjust it as necessary.
Other Changes
I've added a conftest.py file to the Pytest test folder and have placed within it a Pytest fixture that provides a Starlette TestClient to any test that requires it. Any fixtures that are defined within conftest.py can be provided as parameters to tests without the need to import conftest.py into that test's file.
I went through all existing tests and set anything needing a TestClient to use the test_client fixture.
Replace Hard-coded Route Logging Strings
Fixes #446
Description:
This PR aimed to alleviate the need to manually format and maintain log strings for numerous
verify_token
calls within routes, and to instead allow Starlette's Request class to handle the heavy lifting.The
build_route_log_string
method does exactly what it sounds like- it accepts aRequest
object along with a list of strings that you would like to not show up in the logs (tokens, anyone?), and generates a string for the logs. The output will be something similar to as follows:The
***
portion of the string is a substring that was elected to be censored.This will allow us to keep the log formatting synchronized across all routes and make it a breeze to adjust it as necessary.
Other Changes
test
folder and have placed within it a Pytest fixture that provides a Starlette TestClient to any test that requires it. Any fixtures that are defined within conftest.py can be provided as parameters to tests without the need to import conftest.py into that test's file.test_client
fixture.