Opened 10 years ago

Closed 10 years ago

#21341 closed New feature (fixed)

Clean way of making https requests with test client

Reported by: Unai Zalakain Owned by: Unai Zalakain
Component: Testing framework Version: dev
Severity: Normal Keywords: testing, client, https, secure
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This is the current way of making an https request with the testing client:

from django.test import Client

client = Client()
client.get('/', {'wsgi.url_scheme': 'https'})

This is quite obscure and undocumented, something like client.get('/', secure=True) would be far cleaner. The way django.test.client.Client and django.test.client.RequestFactory are build, we would need to modify each request method in both of them.

Change History (10)

comment:1 by Unai Zalakain, 10 years ago

Summary: Add a secure kwarg to testing client request methodsClean way for making https request with test client

comment:2 by Unai Zalakain, 10 years ago

Summary: Clean way for making https request with test clientClean way of making https request with test client

comment:3 by Unai Zalakain, 10 years ago

Summary: Clean way of making https request with test clientClean way of making https requests with test client

comment:4 by Claude Paroz, 10 years ago

Triage Stage: UnreviewedAccepted

comment:5 by Unai Zalakain, 10 years ago

Has patch: set

PR sent: https://github.com/django/django/pull/1820

All the request methods of django.test.client.Client receive a secure
argument that defaults to False indicating wether or not to make the
request through https.

comment:6 by Unai Zalakain, 10 years ago

This would make #13725 easier too.

comment:7 by Unai Zalakain, 10 years ago

Status: newassigned

comment:8 by Aymeric Augustin, 10 years ago

Triage Stage: AcceptedReady for checkin

This looks pretty good to me. I left a few comments on the pull request. I'm marking as RFC anyway because these comments are minor and could be made by the committer.

comment:9 by Unai Zalakain, 10 years ago

Thanks for the review, suggestions applied!

comment:10 by Claude Paroz, 10 years ago

Resolution: fixed
Status: assignedclosed

In: 99b681e227b5b7880d6edd0d8dd670034d431859

Fixed #21341 -- Eased https requests with the test client

Note: See TracTickets for help on using tickets.
Back to Top