Skip to content

Commit

Permalink
Allow empty string in auth
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Jul 4, 2022
1 parent 5e60e66 commit 35bf2bb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ This document describes changes between each past release.
10.11.0 (unreleased)
====================

- Nothing changed yet.
**Bug fixes**

- Fix breaking change introduced in previous version, accept empty string in ``auth`` parameter


10.10.0 (2022-06-27)
Expand Down
2 changes: 1 addition & 1 deletion kinto_http/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def create_session(server_url=None, auth=None, session=None, **kwargs):
msg = "You need to either set session or auth + server_url"
raise AttributeError(msg)

if auth is not None and isinstance(auth, str):
if auth and isinstance(auth, str):
if ":" in auth:
auth = tuple(auth.split(":", 1))
elif "bearer" in auth.lower():
Expand Down
5 changes: 5 additions & 0 deletions kinto_http/tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ def test_auth_can_be_passed_as_basic_header(session_setup: Tuple[MagicMock, Sess
assert session.auth.token == "abcdef"


def test_auth_cannot_be_an_empty_string(session_setup: Tuple[MagicMock, Session]):
session = create_session(auth="")
assert session.auth == ""


def test_auth_cannot_be_an_arbitrary_string(session_setup: Tuple[MagicMock, Session]):
with pytest.raises(ValueError) as exc:
create_session(auth="Some abcdef")
Expand Down

0 comments on commit 35bf2bb

Please sign in to comment.