Mercurial > public > mercurial-scm > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
15019:f4b7be3f8430 | 15024:0f1311e829c9 |
---|---|
1 from mercurial import demandimport; demandimport.enable() | 1 from mercurial import demandimport; demandimport.enable() |
2 import urllib2 | |
2 from mercurial import ui, util | 3 from mercurial import ui, util |
3 from mercurial import url | 4 from mercurial import url |
4 from mercurial.error import Abort | 5 from mercurial.error import Abort |
5 | 6 |
6 class myui(ui.ui): | 7 class myui(ui.ui): |
93 'x.password': 'xpassword', | 94 'x.password': 'xpassword', |
94 'y.prefix': 'http://example.org/foo', | 95 'y.prefix': 'http://example.org/foo', |
95 'y.username': 'y', | 96 'y.username': 'y', |
96 'y.password': 'ypassword'}, | 97 'y.password': 'ypassword'}, |
97 urls=['http://y@example.org/foo/bar']) | 98 urls=['http://y@example.org/foo/bar']) |
99 | |
100 def testauthinfo(fullurl, authurl): | |
101 print 'URIs:', fullurl, authurl | |
102 pm = urllib2.HTTPPasswordMgrWithDefaultRealm() | |
103 pm.add_password(*util.url(fullurl).authinfo()[1]) | |
104 print pm.find_user_password('test', authurl) | |
105 | |
106 print '\n*** Test urllib2 and util.url\n' | |
107 testauthinfo('http://user@example.com:8080/foo', 'http://example.com:8080/foo') |