It would be nice to have an auth pattern. I'm writing an app using a Basic auth protected API and I want to test the calls. Right now, I need to do this:
respx.post(
"https://example.com/",
headers={"Authorization": "Basic " + b64encode(b"rimmer:Gazpacho!").decode()},
).mock(...)
This works, but is quite ugly and I'd prefer to have a direct auth pattern:
respx.post(
"https://example.com/",
auth=("rimmer", "Gazpacho!"),
).mock(...)
This would mimick the auth argument of httpx.request(), similarly to json and similar patterns.
Note: httpx also supports Digest authentication, so respx should probably also cover that usecase, if implemented.
It would be nice to have an
authpattern. I'm writing an app using a Basic auth protected API and I want to test the calls. Right now, I need to do this:This works, but is quite ugly and I'd prefer to have a direct
authpattern:This would mimick the
authargument ofhttpx.request(), similarly tojsonand similar patterns.Note:
httpxalso supports Digest authentication, sorespxshould probably also cover that usecase, if implemented.