Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 3 additions & 5 deletions caldav/davclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,11 +616,9 @@ def delete(self, url: str) -> DAVResponse:
def options(self, url: str) -> DAVResponse:
return self.request(url, "OPTIONS")

def extract_auth_types(self, header):
auth_types = header.lower().split(",")
auth_types = map(lambda auth_type: auth_type.strip(), auth_types)
auth_types = map(lambda auth_type: auth_type.split(" ")[0], auth_types)
return list(filter(lambda auth_type: auth_type, auth_types))
def extract_auth_types(self, header: str):
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/WWW-Authenticate#syntax
return {h.split()[0] for h in header.lower().split(",")}

def request(
self,
Expand Down
12 changes: 6 additions & 6 deletions tests/test_caldav_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1293,12 +1293,12 @@ def testExtractAuth(self):
"""
cal_url = "http://me:hunter2@calendar.example:80/"
with DAVClient(url=cal_url) as client:
assert client.extract_auth_types("Basic\n") == ["basic"]
assert client.extract_auth_types("Basic") == ["basic"]
assert client.extract_auth_types('Basic Realm=foo;charset="UTF-8"') == [
assert client.extract_auth_types("Basic\n") == {"basic"}
assert client.extract_auth_types("Basic") == {"basic"}
assert client.extract_auth_types('Basic Realm=foo;charset="UTF-8"') == {
"basic"
]
assert client.extract_auth_types("Basic,dIGEST Realm=foo") == [
}
assert client.extract_auth_types("Basic,dIGEST Realm=foo") == {
"basic",
"digest",
]
}