Skip to content
This repository has been archived by the owner on Mar 18, 2019. It is now read-only.

Fix handling of deprecated credentials in HTTPTransport #146

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions coreapi/transports/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,16 +345,22 @@ def __init__(self, credentials=None, headers=None, auth=None, session=None, requ
session.cookies.set_policy(BlockAll())

if credentials is not None:
warnings.warn(
"The 'credentials' argument is now deprecated in favor of 'auth'.",
DeprecationWarning
)
auth = DomainCredentials(credentials)
if auth is not None:
warnings.warn(
"Ignoring 'credentials' argument in favor of 'auth'.",
stacklevel=2
)
else:
warnings.warn(
"The 'credentials' argument is now deprecated in favor of 'auth'.",
DeprecationWarning, stacklevel=2
)
session.auth = DomainCredentials(credentials)
if request_callback is not None or response_callback is not None:
warnings.warn(
"The 'request_callback' and 'response_callback' arguments are now deprecated. "
"Use a custom 'session' instance instead.",
DeprecationWarning
DeprecationWarning, stacklevel=2
)
session.mount('https://', CallbackAdapter(request_callback, response_callback))
session.mount('http://', CallbackAdapter(request_callback, response_callback))
Expand Down