﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
13725	assertRedirects not taking url scheme into account	rvdrijst	Unai Zalakain	"The {{{assertRedirects}}} method of {{{TestCase}}} doesn't work correctly with https redirects. There are actually two problems here.

Take the following scenario. You access a view with test client mimicking https by passing in {{{**{'wsgi.url_scheme':'https'}}}}. This view then redirects to a relative url which is converted by fix_location_header to an absolute url with https since the request {{{is_secure()}}}. So far so good.

But {{{assertRedirects}}} will blatantly ignore the scheme, checking the redirect url ''without'' the scheme. Since I have views that will redirect to https if not called with https, this will fail because the redirect check will again be redirected because the scheme was ignored.

This first problem can be fixed by adding  {{{**{'wsgi.url_scheme':scheme}}}} to the redirect check and also taking the scheme into account when matching the url with expected, but this creates another problem. The fix_location_header response fix will build the absolute url using {{{request.get_host()}}}, which for the test client will return {{{testserver:80}}}. The port part is not expected by {{{assertRedirects}}}, which again fails, trying to match the expected {{{https://testserver/some/path}}} with {{{https://testserver:80/some/path}}}.
"	Bug	closed	Testing framework	dev	Normal	fixed	test client assertRedirects https scheme	rvdrijst	Ready for checkin	1	0	0	0	0	0
