Mercurial > public > mercurial-scm > hg-stable
diff tests/test-hgweb-auth.py @ 15024:0f1311e829c9 stable
http: strip credentials from urllib2 manager URIs (issue2885)
urllib2 password manager does not strip credentials from URIs registered with
add_password() and compare them with stripped URIs in find_password(). Remove
credentials from URIs returned by util.url.authinfo(). It sometimes works when
no port was specified as the URI host is registered too.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Fri, 05 Aug 2011 21:05:40 +0200 |
parents | 4a43e23b8c55 |
children | 0593e8f81c71 |
line wrap: on
line diff
--- a/tests/test-hgweb-auth.py Thu Aug 04 19:41:23 2011 +0300 +++ b/tests/test-hgweb-auth.py Fri Aug 05 21:05:40 2011 +0200 @@ -1,4 +1,5 @@ from mercurial import demandimport; demandimport.enable() +import urllib2 from mercurial import ui, util from mercurial import url from mercurial.error import Abort @@ -95,3 +96,12 @@ 'y.username': 'y', 'y.password': 'ypassword'}, urls=['http://y@example.org/foo/bar']) + +def testauthinfo(fullurl, authurl): + print 'URIs:', fullurl, authurl + pm = urllib2.HTTPPasswordMgrWithDefaultRealm() + pm.add_password(*util.url(fullurl).authinfo()[1]) + print pm.find_user_password('test', authurl) + +print '\n*** Test urllib2 and util.url\n' +testauthinfo('http://user@example.com:8080/foo', 'http://example.com:8080/foo')