comparison tests/test-hgweb-auth.py @ 46907:ffd3e823a7e5

urlutil: extract `url` related code from `util` into the new module The new module is well fitting for this new code. And this will be useful to make the gathered code collaborate more later. Differential Revision: https://phab.mercurial-scm.org/D10374
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 12 Apr 2021 03:01:04 +0200
parents 9d2b2df2c2ba
children 6000f5b25c9b
comparison
equal deleted inserted replaced
46906:33524c46a092 46907:ffd3e823a7e5
8 pycompat, 8 pycompat,
9 ui as uimod, 9 ui as uimod,
10 url, 10 url,
11 util, 11 util,
12 ) 12 )
13 from mercurial.utils import stringutil 13 from mercurial.utils import (
14 stringutil,
15 urlutil,
16 )
14 17
15 urlerr = util.urlerr 18 urlerr = util.urlerr
16 urlreq = util.urlreq 19 urlreq = util.urlreq
17 20
18 21
58 61
59 def _test(uri): 62 def _test(uri):
60 print('URI:', pycompat.strurl(uri)) 63 print('URI:', pycompat.strurl(uri))
61 try: 64 try:
62 pm = url.passwordmgr(ui, urlreq.httppasswordmgrwithdefaultrealm()) 65 pm = url.passwordmgr(ui, urlreq.httppasswordmgrwithdefaultrealm())
63 u, authinfo = util.url(uri).authinfo() 66 u, authinfo = urlutil.url(uri).authinfo()
64 if authinfo is not None: 67 if authinfo is not None:
65 pm.add_password(*_stringifyauthinfo(authinfo)) 68 pm.add_password(*_stringifyauthinfo(authinfo))
66 print( 69 print(
67 ' ', 70 ' ',
68 tuple( 71 tuple(
196 199
197 200
198 def testauthinfo(fullurl, authurl): 201 def testauthinfo(fullurl, authurl):
199 print('URIs:', fullurl, authurl) 202 print('URIs:', fullurl, authurl)
200 pm = urlreq.httppasswordmgrwithdefaultrealm() 203 pm = urlreq.httppasswordmgrwithdefaultrealm()
201 ai = _stringifyauthinfo(util.url(pycompat.bytesurl(fullurl)).authinfo()[1]) 204 ai = _stringifyauthinfo(
205 urlutil.url(pycompat.bytesurl(fullurl)).authinfo()[1]
206 )
202 pm.add_password(*ai) 207 pm.add_password(*ai)
203 print(pm.find_user_password('test', authurl)) 208 print(pm.find_user_password('test', authurl))
204 209
205 210
206 print('\n*** Test urllib2 and util.url\n') 211 print('\n*** Test urllib2 and urlutil.url\n')
207 testauthinfo('http://user@example.com:8080/foo', 'http://example.com:8080/foo') 212 testauthinfo('http://user@example.com:8080/foo', 'http://example.com:8080/foo')