* [#387] Do not escape the "timeout" parameter. When the "timeout" parameter is escaped and turned into a string, it does not pass validation checks. This PR ensures that timeout is passed through as-is, just like "request_timeout". There's no explicit test for this parameter, but I included it on some existing tests just to ensure that the code is exercised. Without the fix in place, one of the tests as modified will not pass. Signed-off-by: Charles Greer <[email protected]> * Unit test for timeout parameter Revert original test modifications. Signed-off-by: Charles Greer <[email protected]> * Extend test and linter Signed-off-by: Charles Greer <[email protected]> --------- Signed-off-by: Charles Greer <[email protected]>
This commit is contained in:
@@ -85,6 +85,31 @@ class TestQueryParams(TestCase):
|
||||
self.func_to_wrap(headers={"X": "y"})
|
||||
self.assertEqual(self.calls[-1], ((), {"params": {}, "headers": {"x": "y"}}))
|
||||
|
||||
def test_non_escaping_params(self):
|
||||
# the query_params decorator doesn't validate "timeout" it simply avoids escaping as it did
|
||||
self.func_to_wrap(simple_param="x", timeout="4s")
|
||||
self.assertEqual(
|
||||
self.calls[-1],
|
||||
((), {"params": {"simple_param": b"x", "timeout": "4s"}, "headers": {}}),
|
||||
)
|
||||
|
||||
self.func_to_wrap(simple_param="x", timeout=4, ignore=5, request_timeout=6)
|
||||
self.assertEqual(
|
||||
self.calls[-1],
|
||||
(
|
||||
(),
|
||||
{
|
||||
"params": {
|
||||
"simple_param": b"x",
|
||||
"timeout": 4,
|
||||
"ignore": 5,
|
||||
"request_timeout": 6,
|
||||
},
|
||||
"headers": {},
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
def test_per_call_authentication(self):
|
||||
self.func_to_wrap(api_key=("name", "key"))
|
||||
self.assertEqual(
|
||||
|
||||
Reference in New Issue
Block a user