From 01314646eaa428550846c470c11d3a7fff726885 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Fri, 9 May 2025 15:12:13 +0200 Subject: [PATCH] blank password should be acceptable Solves issue https://github.com/python-caldav/caldav/issues/479 --- caldav/davclient.py | 8 ++++++-- tests/conf.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/caldav/davclient.py b/caldav/davclient.py index c18ea44a..6c4ad53e 100644 --- a/caldav/davclient.py +++ b/caldav/davclient.py @@ -707,12 +707,16 @@ def request( ): auth_types = self.extract_auth_types(r_headers["WWW-Authenticate"]) - if self.password and self.username and "digest" in auth_types: + if self.username and "digest" in auth_types: self.auth = niquests.auth.HTTPDigestAuth(self.username, self.password) - elif self.password and self.username and "basic" in auth_types: + elif self.username and "basic" in auth_types: self.auth = niquests.auth.HTTPBasicAuth(self.username, self.password) elif self.password and "bearer" in auth_types: self.auth = HTTPBearerAuth(self.password) + elif "bearer" in auth_types: + raise error.AuthorizationError( + reason="Server provides bearer auth, but no password given. The bearer token should be configured as password" + ) else: raise NotImplementedError( "The server does not provide any of the currently " diff --git a/tests/conf.py b/tests/conf.py index 93e2bc2f..2e24a58e 100644 --- a/tests/conf.py +++ b/tests/conf.py @@ -138,7 +138,7 @@ def teardown_radicale(self): "url": url, "name": "LocalRadicale", "username": "user1", - "password": "any-password-seems-to-work", + "password": "", "backwards_compatibility_url": url + "user1", "incompatibilities": compatibility_issues.radicale, "setup": setup_radicale,