generated from datalad/datalad-extension-template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace the www-authenticate dependency with internal function
The implementation is built on request's parsing utilities rather than elusive regexes. I find this better to grasp. The associated test includes all www-authenticate test cases, plus a set of additional ones that focus on multi-challenge header specifications. Closes #493
- Loading branch information
Showing
5 changed files
with
130 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
### 🏠 Internal | ||
|
||
- The `www-authenticate` dependencies is dropped. The functionality is | ||
replaced by a `requests`-based implementation of an alternative parser. | ||
This trims the dependency footprint and facilitates Debian-packaging. | ||
The previous test cases are kept and further extended. | ||
Fixes https://github.com/datalad/datalad-next/issues/493 via | ||
https://github.com/datalad/datalad-next/pull/495 (by @mih) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
from ..requests_auth import parse_www_authenticate | ||
|
||
|
||
challenges = ( | ||
# just challenge type | ||
('Negotiate', | ||
[('negotiate', None)]), | ||
# challenge and just a token, tolerate any base64 padding | ||
('Negotiate abcdef', | ||
[('negotiate', 'abcdef')]), | ||
('Negotiate abcdef=', | ||
[('negotiate', 'abcdef=')]), | ||
('Negotiate abcdef==', | ||
[('negotiate', 'abcdef==')]), | ||
# standard bearer | ||
('Bearer realm=example.com', | ||
[('bearer', {'realm': 'example.com'})]), | ||
# standard digest | ||
('Digest realm="example.com", qop="auth,auth-int", nonce="abcdef", ' | ||
'opaque="ghijkl"', | ||
[('digest', {'realm': 'example.com', 'qop': 'auth,auth-int', | ||
'nonce': 'abcdef', 'opaque': 'ghijkl'})]), | ||
# multi challenge | ||
('Basic speCial="paf ram", realm="basIC", ' | ||
'Bearer, ' | ||
'Digest realm="[email protected]", qop="auth, auth-int", ' | ||
'algorithm=MD5', | ||
[('basic', {'special': 'paf ram', 'realm': 'basIC'}), | ||
('bearer', None), | ||
('digest', {'realm': "[email protected]", 'qop': "auth, auth-int", | ||
'algorithm': 'MD5'})]), | ||
# same challenge, multiple times, last one wins | ||
('Basic realm="basIC", ' | ||
'Basic realm="complex"', | ||
[('basic', {'realm': 'complex'})]), | ||
) | ||
|
||
|
||
def test_parse_www_authenticate(): | ||
for hdr, targets in challenges: | ||
res = parse_www_authenticate(hdr) | ||
for ctype, props in targets: | ||
assert ctype in res | ||
assert res[ctype] == props |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters