Mercurial > public > mercurial-scm > hg-stable
diff tests/test-hgweb-auth.py @ 40704:c53f0ead5781
http: allow 'auth.prefix' to have a username consistent with the URI
It may be a little weird to put a username in the prefix, but the documentation
doesn't disallow it, and silently disallowing it has caused confusion[1]. The
username must match what is passed in (which seems to be from the URI via a
circuitous route), as well as 'auth.username' if it was specified. I thought
about printing a warning for a mismatch, but we already don't print a warning if
the 'auth.username' and URI username don't match.
This change allows the first and second last new test cases to work as expected.
It looks like this would have been a problem since at least 0593e8f81c71.
[1] https://www.mercurial-scm.org/pipermail/mercurial/2018-November/051069.html
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Fri, 16 Nov 2018 17:56:36 -0500 |
parents | 32bc3815efae |
children | 30dd20a56f3e |
line wrap: on
line diff
--- a/tests/test-hgweb-auth.py Thu Nov 15 18:14:57 2018 -0500 +++ b/tests/test-hgweb-auth.py Fri Nov 16 17:56:36 2018 -0500 @@ -104,6 +104,39 @@ 'y.password': 'ypassword'}, urls=['http://y@example.org/foo/bar']) +print('\n*** Test user matching with name in prefix\n') + +# prefix, username and URL have the same user +test({'x.prefix': 'https://example.org/foo', + 'x.username': None, + 'x.password': 'xpassword', + 'y.prefix': 'http://y@example.org/foo', + 'y.username': 'y', + 'y.password': 'ypassword'}, + urls=['http://y@example.org/foo']) +# Prefix has a different user from username and URL +test({'y.prefix': 'http://z@example.org/foo', + 'y.username': 'y', + 'y.password': 'ypassword'}, + urls=['http://y@example.org/foo']) +# Prefix has a different user from URL; no username +test({'y.prefix': 'http://z@example.org/foo', + 'y.password': 'ypassword'}, + urls=['http://y@example.org/foo']) +# Prefix and URL have same user, but doesn't match username +test({'y.prefix': 'http://y@example.org/foo', + 'y.username': 'z', + 'y.password': 'ypassword'}, + urls=['http://y@example.org/foo']) +# Prefix and URL have the same user; no username +test({'y.prefix': 'http://y@example.org/foo', + 'y.password': 'ypassword'}, + urls=['http://y@example.org/foo']) +# Prefix user, but no URL user or username +test({'y.prefix': 'http://y@example.org/foo', + 'y.password': 'ypassword'}, + urls=['http://example.org/foo']) + def testauthinfo(fullurl, authurl): print('URIs:', fullurl, authurl) pm = urlreq.httppasswordmgrwithdefaultrealm()