#37025: RemoteUserMiddleware.header does not correspond to request.META in the
async path
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Jacob
| Walls
Type: Bug | Status: assigned
Component: contrib.auth | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
RemoteUserMiddleware |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Mykhailo Havelia):
Replying to [comment:3 Sarah Boyce]:
> Thank you for the ticket
>
> From reviewing the PR that implemented this, I would say our approach
was to get test parity by async-ifying the sync tests. This was then
required for the tests to pass and, therefore, seemed required. I am now
under the impression that our logic as to how we wrote the async tests
must be off. Have you looked into what changes may be required there? I
think that will help identify why we got this wrong
>
> This is a partial duplicate of #36443 and #36300
I don't think we can improve our test tooling to prevent something like
this in the future. But we do have experience supporting sync/async
middlewares with separate tests (like in the PR), and I can say with
certainty that it's a bad approach for long-term maintenance 😌. At first
it works fine, you just copy the sync tests, swap in the async
equivalents, and you're done. But over time it becomes hard to maintain,
and having separate tests doesn't actually guarantee that the sync and
async paths behave the same way.
`RemoteUserMiddleware` is the first and only pure async middleware in
Django, so we can experiment with testing tooling and approaches here, and
then apply what we learn to future pure async middlewares.
Just a thought, if it makes sense 😌
--
Ticket URL: <
https://code.djangoproject.com/ticket/37025#comment:14>