##// END OF EJS Templates
util: extract all date-related utils in utils/dateutil module...
util: extract all date-related utils in utils/dateutil module With this commit, util.py lose 262 lines Note for extensions author, if this commit breaks your extension, you can pull the step-by-step split here to help you more easily pinpoint the renaming that broke your extension: hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ac1f6453010d Differential Revision: https://phab.mercurial-scm.org/D2282

File last commit:

r36345:58c1368a default
r36625:c6061cad default
Show More
test-hgweb-auth.py
114 lines | 3.5 KiB | text/x-python | PythonLexer
/ tests / test-hgweb-auth.py
Robert Stanca
py3: use print_function in test-hgweb-auth.py
r28748 from __future__ import absolute_import, print_function
Robert Stanca
py3: use absolute_import in test-hgweb-auth.py
r28747
Sune Foldager
allow http authentication information to be specified in the configuration
r8333 from mercurial import demandimport; demandimport.enable()
Robert Stanca
py3: use absolute_import in test-hgweb-auth.py
r28747 from mercurial import (
Yuya Nishihara
test-hgweb-auth: stop direct symbol import of mercurial.error.Abort
r28808 error,
Yuya Nishihara
test-hgweb-auth: alias ui as uimod
r28807 ui as uimod,
Robert Stanca
py3: use absolute_import in test-hgweb-auth.py
r28747 url,
util,
)
Sune Foldager
allow http authentication information to be specified in the configuration
r8333
timeless
pycompat: switch to util.urlreq/util.urlerr for py3 compat
r28883 urlerr = util.urlerr
urlreq = util.urlreq
Yuya Nishihara
test-hgweb-auth: alias ui as uimod
r28807 class myui(uimod.ui):
Sune Foldager
allow http authentication information to be specified in the configuration
r8333 def interactive(self):
return False
Yuya Nishihara
ui: factor out ui.load() to create a ui without loading configs (API)...
r30559 origui = myui.load()
Sune Foldager
allow http authentication information to be specified in the configuration
r8333
def writeauth(items):
ui = origui.copy()
Pulkit Goyal
py3: use dict.items() instead of dict.iteritems() in tests...
r36345 for name, value in items.items():
Sune Foldager
allow http authentication information to be specified in the configuration
r8333 ui.setconfig('auth', name, value)
return ui
def dumpdict(dict):
Matt Mackall
many, many trivial check-code fixups
r10282 return '{' + ', '.join(['%s: %s' % (k, dict[k])
Augie Fackler
python3: replace sorted(<dict>.iterkeys()) with sorted(<dict>)
r34025 for k in sorted(dict)]) + '}'
Sune Foldager
allow http authentication information to be specified in the configuration
r8333
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005 def test(auth, urls=None):
Robert Stanca
py3: use print_function in test-hgweb-auth.py
r28748 print('CFG:', dumpdict(auth))
Sune Foldager
allow http authentication information to be specified in the configuration
r8333 prefixes = set()
for k in auth:
prefixes.add(k.split('.', 1)[0])
for p in prefixes:
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005 for name in ('.username', '.password'):
if (p + name) not in auth:
auth[p + name] = p
Pulkit Goyal
py3: use dict.items() instead of dict.iteritems() in tests...
r36345 auth = dict((k, v) for k, v in auth.items() if v is not None)
Sune Foldager
allow http authentication information to be specified in the configuration
r8333
ui = writeauth(auth)
def _test(uri):
Robert Stanca
py3: use print_function in test-hgweb-auth.py
r28748 print('URI:', uri)
Sune Foldager
allow http authentication information to be specified in the configuration
r8333 try:
liscju
url: extract password database from password manager...
r29377 pm = url.passwordmgr(ui, urlreq.httppasswordmgrwithdefaultrealm())
Patrick Mezard
http: pass user to readauthforuri() (fix 4a43e23b8c55)...
r15025 u, authinfo = util.url(uri).authinfo()
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005 if authinfo is not None:
pm.add_password(*authinfo)
Robert Stanca
py3: use print_function in test-hgweb-auth.py
r28748 print(' ', pm.find_user_password('test', u))
Yuya Nishihara
test-hgweb-auth: stop direct symbol import of mercurial.error.Abort
r28808 except error.Abort:
Robert Stanca
py3: use print_function in test-hgweb-auth.py
r28748 print(' ','abort')
Sune Foldager
allow http authentication information to be specified in the configuration
r8333
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005 if not urls:
urls = [
'http://example.org/foo',
'http://example.org/foo/bar',
'http://example.org/bar',
'https://example.org/foo',
'https://example.org/foo/bar',
'https://example.org/bar',
'https://x@example.org/bar',
'https://y@example.org/bar',
]
for u in urls:
_test(u)
Sune Foldager
allow http authentication information to be specified in the configuration
r8333
Robert Stanca
py3: use print_function in test-hgweb-auth.py
r28748 print('\n*** Test in-uri schemes\n')
Sune Foldager
allow http authentication information to be specified in the configuration
r8333 test({'x.prefix': 'http://example.org'})
test({'x.prefix': 'https://example.org'})
test({'x.prefix': 'http://example.org', 'x.schemes': 'https'})
test({'x.prefix': 'https://example.org', 'x.schemes': 'http'})
Robert Stanca
py3: use print_function in test-hgweb-auth.py
r28748 print('\n*** Test separately configured schemes\n')
Sune Foldager
allow http authentication information to be specified in the configuration
r8333 test({'x.prefix': 'example.org', 'x.schemes': 'http'})
test({'x.prefix': 'example.org', 'x.schemes': 'https'})
test({'x.prefix': 'example.org', 'x.schemes': 'http https'})
Robert Stanca
py3: use print_function in test-hgweb-auth.py
r28748 print('\n*** Test prefix matching\n')
Matt Mackall
many, many trivial check-code fixups
r10282 test({'x.prefix': 'http://example.org/foo',
'y.prefix': 'http://example.org/bar'})
test({'x.prefix': 'http://example.org/foo',
'y.prefix': 'http://example.org/foo/bar'})
Sune Foldager
allow http authentication information to be specified in the configuration
r8333 test({'x.prefix': '*', 'y.prefix': 'https://example.org/bar'})
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005
Robert Stanca
py3: use print_function in test-hgweb-auth.py
r28748 print('\n*** Test user matching\n')
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005 test({'x.prefix': 'http://example.org/foo',
'x.username': None,
'x.password': 'xpassword'},
urls=['http://y@example.org/foo'])
test({'x.prefix': 'http://example.org/foo',
'x.username': None,
'x.password': 'xpassword',
'y.prefix': 'http://example.org/foo',
'y.username': 'y',
'y.password': 'ypassword'},
urls=['http://y@example.org/foo'])
test({'x.prefix': 'http://example.org/foo/bar',
'x.username': None,
'x.password': 'xpassword',
'y.prefix': 'http://example.org/foo',
'y.username': 'y',
'y.password': 'ypassword'},
urls=['http://y@example.org/foo/bar'])
Patrick Mezard
http: strip credentials from urllib2 manager URIs (issue2885)...
r15024
def testauthinfo(fullurl, authurl):
Robert Stanca
py3: use print_function in test-hgweb-auth.py
r28748 print('URIs:', fullurl, authurl)
timeless
pycompat: switch to util.urlreq/util.urlerr for py3 compat
r28883 pm = urlreq.httppasswordmgrwithdefaultrealm()
Patrick Mezard
http: strip credentials from urllib2 manager URIs (issue2885)...
r15024 pm.add_password(*util.url(fullurl).authinfo()[1])
Robert Stanca
py3: use print_function in test-hgweb-auth.py
r28748 print(pm.find_user_password('test', authurl))
Patrick Mezard
http: strip credentials from urllib2 manager URIs (issue2885)...
r15024
Robert Stanca
py3: use print_function in test-hgweb-auth.py
r28748 print('\n*** Test urllib2 and util.url\n')
Patrick Mezard
http: strip credentials from urllib2 manager URIs (issue2885)...
r15024 testauthinfo('http://user@example.com:8080/foo', 'http://example.com:8080/foo')