Skip to content

Feature request: Add auth pattern #245

@stinovlas

Description

@stinovlas

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions