{{{#!diff
diff --git a/tests/test_client_regress/tests.py
b/tests/test_client_regress/tests.py
index aaf25e2ec4..53cdc3bf07 100644
--- a/tests/test_client_regress/tests.py
+++ b/tests/test_client_regress/tests.py
@@ -613,6 +613,18 @@ class AssertRedirectsTests(SimpleTestCase):
status_code=302,
target_status_code=302,
)
+ response = req_method(
+ "/redirect_based_on_extra_headers_1/",
+ follow=False,
+ headers={"redirect": "val"},
+ )
+ self.assertRedirects(
+ response,
+ "/redirect_based_on_extra_headers_2/",
+ fetch_redirect_response=True,
+ status_code=302,
+ target_status_code=302,
+ )
@override_settings(ROOT_URLCONF="test_client_regress.urls")
}}}
Bug in 67da22f08e05018ea968fcacbac9ac37ea925d85.
--
Ticket URL: <https://code.djangoproject.com/ticket/34240>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Carlton Gibson):
I think the regression test here isn't quite right. It fails at
b181cae2e3697b2e53b5b67ac67e59f3b05a6f0d (i.e. 67da22f0^) and
`stable/4.1.x` too. 🤔
--
Ticket URL: <https://code.djangoproject.com/ticket/34240#comment:1>
* stage: Unreviewed => Accepted
Comment:
I'll provisionally accept anyhow, assuming you're correct about the
regression.
--
Ticket URL: <https://code.djangoproject.com/ticket/34240#comment:2>
Comment (by Mariusz Felisiak):
Replying to [comment:1 Carlton Gibson]:
> I think the regression test here isn't quite right. It fails at
b181cae2e3697b2e53b5b67ac67e59f3b05a6f0d (i.e. `67da22f0^`) and
`stable/4.1.x` too. 🤔
Support for `headers` was added in
67da22f08e05018ea968fcacbac9ac37ea925d85, so it's a bug in the new
feature. Previously, `headers` went to `**extra` and was not interpreted
as HTTP headers.
After 67da22f08e05018ea968fcacbac9ac37ea925d85 `headers={"redirect":
"val"}` should work the same as `HTTP_REDIRECT="val"` and is not in
`assertRedirects()`.
--
Ticket URL: <https://code.djangoproject.com/ticket/34240#comment:3>
Old description:
New description:
Similar to the #28337, HTTP headers can be passed in the `headers`
argument and should be preserved in `assertRedirects()`.
@override_settings(ROOT_URLCONF="test_client_regress.urls")
}}}
Bug in 67da22f08e05018ea968fcacbac9ac37ea925d85.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/34240#comment:4>
Comment (by Carlton Gibson):
OK, that makes sense 😅
☕️
--
Ticket URL: <https://code.djangoproject.com/ticket/34240#comment:5>
* owner: nobody => rajdesai24
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/34240#comment:6>
* cc: Adam Johnson (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/34240#comment:7>
Comment (by rajdesai24):
hey Mariusz Felisiak can you help me with reproducing the bug. Is it just
writing test cases using assertRedirects and putting headers in the
dictionary
--
Ticket URL: <https://code.djangoproject.com/ticket/34240#comment:8>
Comment (by Mariusz Felisiak):
Replying to [comment:8 rajdesai24]:
> hey Mariusz Felisiak can you help me with reproducing the bug. Is it
just writing test cases using assertRedirects and putting headers in the
dictionary
This is an issue in `assertRedirects()`. I've already attached a
regression test in the ticket description.
--
Ticket URL: <https://code.djangoproject.com/ticket/34240#comment:9>
* owner: rajdesai24 => Mariusz Felisiak
Comment:
rajdesai24 thanks for your efforts, however, I will assign it to myself as
the Django 4.2 feature freeze is on Monday (January, 16th).
--
Ticket URL: <https://code.djangoproject.com/ticket/34240#comment:10>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/16447 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/34240#comment:11>
Comment (by rajdesai24):
Sorry, Mariuz for the delay and good I understood how you solved it.
Thanks, I will find some new bugs for myself
--
Ticket URL: <https://code.djangoproject.com/ticket/34240#comment:12>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"c2118d72d61746f2462fca695dbf3adf44ebf8f7" c2118d72]:
{{{
#!CommitTicketReference repository=""
revision="c2118d72d61746f2462fca695dbf3adf44ebf8f7"
Fixed #34240 -- Preserved headers of requests made with django.test.Client
in assertRedirects().
Bug in 67da22f08e05018ea968fcacbac9ac37ea925d85.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34240#comment:13>