#21341 closed New feature (fixed)

Clean way of making https requests with test client

Reported by: unaizalakain Owned by: unaizalakain
Component: Testing framework Version: master
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 Changed 16 months ago by unaizalakain

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from Add a secure kwarg to testing client request methods to Clean way for making https request with test client

comment:2 Changed 16 months ago by unaizalakain

  • Summary changed from Clean way for making https request with test client to Clean way of making https request with test client

comment:3 Changed 16 months ago by unaizalakain

  • Summary changed from Clean way of making https request with test client to Clean way of making https requests with test client

comment:4 Changed 16 months ago by claudep

  • Triage Stage changed from Unreviewed to Accepted

comment:5 Changed 16 months ago by unaizalakain

  • 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 Changed 16 months ago by unaizalakain

This would make #13725 easier too.

comment:7 Changed 16 months ago by unaizalakain

  • Status changed from new to assigned

comment:8 Changed 16 months ago by aaugustin

  • Triage Stage changed from Accepted to Ready 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 Changed 16 months ago by unaizalakain

Thanks for the review, suggestions applied!

comment:10 Changed 16 months ago by claudep

  • Resolution set to fixed
  • Status changed from assigned to closed

In: 99b681e227b5b7880d6edd0d8dd670034d431859

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

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