##// END OF EJS Templates
errors: name arguments to Abort constructor...
errors: name arguments to Abort constructor Differential Revision: https://phab.mercurial-scm.org/D9179

File last commit:

r46274:d2e1dcd4 default
r46274:d2e1dcd4 default
Show More
test-url.py
463 lines | 13.9 KiB | text/x-python | PythonLexer
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451 # coding=utf-8
Pulkit Goyal
tests: make test-url use absolute_import
r28914 from __future__ import absolute_import, print_function
import doctest
Brodie Rao
tests: fix readline escape characters in heredoctest.py/test-url.py...
r15398 import os
Mads Kiilerich
url: verify correctness of https server certificates (issue2407)...
r12592
Augie Fackler
formatting: blacken the codebase...
r43346
Mads Kiilerich
url: verify correctness of https server certificates (issue2407)...
r12592 def check(a, b):
if a != b:
Pulkit Goyal
py3: make test-url use print_function
r28677 print((a, b))
Mads Kiilerich
url: verify correctness of https server certificates (issue2407)...
r12592
Augie Fackler
formatting: blacken the codebase...
r43346
Martin Geisler
test-url: refactor with shorter lines
r12606 def cert(cn):
Augie Fackler
test-url: move from dict() construction to {} literals...
r20685 return {'subject': ((('commonName', cn),),)}
Martin Geisler
test-url: refactor with shorter lines
r12606
Augie Fackler
formatting: blacken the codebase...
r43346
from mercurial import sslutil
Mads Kiilerich
url: verify correctness of https server certificates (issue2407)...
r12592
Pulkit Goyal
tests: make test-url use absolute_import
r28914 _verifycert = sslutil._verifycert
Augie Fackler
test-url: remove trailing whitespace
r12724 # Test non-wildcard certificates
Augie Fackler
formatting: blacken the codebase...
r43346 check(_verifycert(cert('example.com'), 'example.com'), None)
check(
_verifycert(cert('example.com'), 'www.example.com'),
b'certificate is for example.com',
)
check(
_verifycert(cert('www.example.com'), 'example.com'),
b'certificate is for www.example.com',
)
Mads Kiilerich
url: verify correctness of https server certificates (issue2407)...
r12592
# Test wildcard certificates
Augie Fackler
formatting: blacken the codebase...
r43346 check(_verifycert(cert('*.example.com'), 'www.example.com'), None)
check(
_verifycert(cert('*.example.com'), 'example.com'),
b'certificate is for *.example.com',
)
check(
_verifycert(cert('*.example.com'), 'w.w.example.com'),
b'certificate is for *.example.com',
)
Mads Kiilerich
url: verify correctness of https server certificates (issue2407)...
r12592
Yuya Nishihara
url: check subjectAltName when verifying ssl certificate...
r13249 # Test subjectAltName
Augie Fackler
formatting: blacken the codebase...
r43346 san_cert = {
'subject': ((('commonName', 'example.com'),),),
'subjectAltName': (('DNS', '*.example.net'), ('DNS', 'example.net')),
}
check(_verifycert(san_cert, 'example.net'), None)
check(_verifycert(san_cert, 'foo.example.net'), None)
Nicolas Bareil
sslutil: fall back to commonName when no dNSName in subjectAltName (issue2798)...
r14666 # no fallback to subject commonName when subjectAltName has DNS
Augie Fackler
formatting: blacken the codebase...
r43346 check(
_verifycert(san_cert, 'example.com'),
b'certificate is for *.example.net, example.net',
)
Nicolas Bareil
sslutil: fall back to commonName when no dNSName in subjectAltName (issue2798)...
r14666 # fallback to subject commonName when no DNS in subjectAltName
Augie Fackler
formatting: blacken the codebase...
r43346 san_cert = {
'subject': ((('commonName', 'example.com'),),),
'subjectAltName': (('IP Address', '8.8.8.8'),),
}
Nicolas Bareil
sslutil: fall back to commonName when no dNSName in subjectAltName (issue2798)...
r14666 check(_verifycert(san_cert, 'example.com'), None)
Yuya Nishihara
url: check subjectAltName when verifying ssl certificate...
r13249
Mads Kiilerich
url: verify correctness of https server certificates (issue2407)...
r12592 # Avoid some pitfalls
Augie Fackler
formatting: blacken the codebase...
r43346 check(_verifycert(cert('*.foo'), 'foo'), b'certificate is for *.foo')
Gregory Szorc
sslutil: synchronize hostname matching logic with CPython...
r29452 check(_verifycert(cert('*o'), 'foo'), None)
Mads Kiilerich
url: verify correctness of https server certificates (issue2407)...
r12592
Augie Fackler
formatting: blacken the codebase...
r43346 check(
_verifycert({'subject': ()}, 'example.com'),
b'no commonName or subjectAltName found in certificate',
)
check(_verifycert(None, 'example.com'), b'no certificate received')
Yuya Nishihara
url: fix UnicodeDecodeError on certificate verification error...
r13248
Nicolas Bareil
sslutil: fall back to commonName when no dNSName in subjectAltName (issue2798)...
r14666 # Unicode (IDN) certname isn't supported
Augie Fackler
formatting: blacken the codebase...
r43346 check(
_verifycert(cert(u'\u4f8b.jp'), 'example.jp'),
b'IDN in certificate not supported',
)
Nicolas Bareil
sslutil: fall back to commonName when no dNSName in subjectAltName (issue2798)...
r14666
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451 # The following tests are from CPython's test_ssl.py.
check(_verifycert(cert('example.com'), 'example.com'), None)
check(_verifycert(cert('example.com'), 'ExAmple.cOm'), None)
Augie Fackler
formatting: blacken the codebase...
r43346 check(
_verifycert(cert('example.com'), 'www.example.com'),
b'certificate is for example.com',
)
check(
_verifycert(cert('example.com'), '.example.com'),
b'certificate is for example.com',
)
check(
_verifycert(cert('example.com'), 'example.org'),
b'certificate is for example.com',
)
check(
_verifycert(cert('example.com'), 'exampleXcom'),
b'certificate is for example.com',
)
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451 check(_verifycert(cert('*.a.com'), 'foo.a.com'), None)
Augie Fackler
formatting: blacken the codebase...
r43346 check(
_verifycert(cert('*.a.com'), 'bar.foo.a.com'), b'certificate is for *.a.com'
)
check(_verifycert(cert('*.a.com'), 'a.com'), b'certificate is for *.a.com')
check(_verifycert(cert('*.a.com'), 'Xa.com'), b'certificate is for *.a.com')
check(_verifycert(cert('*.a.com'), '.a.com'), b'certificate is for *.a.com')
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451
# only match one left-most wildcard
Gregory Szorc
sslutil: synchronize hostname matching logic with CPython...
r29452 check(_verifycert(cert('f*.com'), 'foo.com'), None)
check(_verifycert(cert('f*.com'), 'f.com'), None)
Augie Fackler
formatting: blacken the codebase...
r43346 check(_verifycert(cert('f*.com'), 'bar.com'), b'certificate is for f*.com')
check(_verifycert(cert('f*.com'), 'foo.a.com'), b'certificate is for f*.com')
check(_verifycert(cert('f*.com'), 'bar.foo.com'), b'certificate is for f*.com')
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451
# NULL bytes are bad, CVE-2013-4073
Augie Fackler
formatting: blacken the codebase...
r43346 check(
_verifycert(
cert('null.python.org\x00example.org'), 'null.python.org\x00example.org'
),
None,
)
check(
_verifycert(cert('null.python.org\x00example.org'), 'example.org'),
b'certificate is for null.python.org\x00example.org',
)
check(
_verifycert(cert('null.python.org\x00example.org'), 'null.python.org'),
b'certificate is for null.python.org\x00example.org',
)
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451
# error cases with wildcards
Augie Fackler
formatting: blacken the codebase...
r43346 check(
_verifycert(cert('*.*.a.com'), 'bar.foo.a.com'),
b'certificate is for *.*.a.com',
)
check(_verifycert(cert('*.*.a.com'), 'a.com'), b'certificate is for *.*.a.com')
check(_verifycert(cert('*.*.a.com'), 'Xa.com'), b'certificate is for *.*.a.com')
check(_verifycert(cert('*.*.a.com'), '.a.com'), b'certificate is for *.*.a.com')
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451
Augie Fackler
formatting: blacken the codebase...
r43346 check(_verifycert(cert('a.*.com'), 'a.foo.com'), b'certificate is for a.*.com')
check(_verifycert(cert('a.*.com'), 'a..com'), b'certificate is for a.*.com')
check(_verifycert(cert('a.*.com'), 'a.com'), b'certificate is for a.*.com')
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451
# wildcard doesn't match IDNA prefix 'xn--'
idna = u'püthon.python.org'.encode('idna').decode('ascii')
check(_verifycert(cert(idna), idna), None)
Augie Fackler
formatting: blacken the codebase...
r43346 check(
_verifycert(cert('x*.python.org'), idna),
b'certificate is for x*.python.org',
)
check(
_verifycert(cert('xn--p*.python.org'), idna),
b'certificate is for xn--p*.python.org',
)
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451
# wildcard in first fragment and IDNA A-labels in sequent fragments
# are supported.
idna = u'www*.pythön.org'.encode('idna').decode('ascii')
Augie Fackler
formatting: blacken the codebase...
r43346 check(
_verifycert(cert(idna), u'www.pythön.org'.encode('idna').decode('ascii')),
None,
)
check(
_verifycert(cert(idna), u'www1.pythön.org'.encode('idna').decode('ascii')),
None,
)
check(
_verifycert(cert(idna), u'ftp.pythön.org'.encode('idna').decode('ascii')),
b'certificate is for www*.xn--pythn-mua.org',
)
check(
_verifycert(cert(idna), u'pythön.org'.encode('idna').decode('ascii')),
b'certificate is for www*.xn--pythn-mua.org',
)
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451
c = {
'notAfter': 'Jun 26 21:41:46 2011 GMT',
'subject': (((u'commonName', u'linuxfrz.org'),),),
'subjectAltName': (
('DNS', 'linuxfr.org'),
('DNS', 'linuxfr.com'),
('othername', '<unsupported>'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451 }
check(_verifycert(c, 'linuxfr.org'), None)
check(_verifycert(c, 'linuxfr.com'), None)
# Not a "DNS" entry
Augie Fackler
formatting: blacken the codebase...
r43346 check(
_verifycert(c, '<unsupported>'),
b'certificate is for linuxfr.org, linuxfr.com',
)
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451 # When there is a subjectAltName, commonName isn't used
Augie Fackler
formatting: blacken the codebase...
r43346 check(
_verifycert(c, 'linuxfrz.org'),
b'certificate is for linuxfr.org, linuxfr.com',
)
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451
# A pristine real-world example
c = {
'notAfter': 'Dec 18 23:59:59 2011 GMT',
'subject': (
((u'countryName', u'US'),),
((u'stateOrProvinceName', u'California'),),
((u'localityName', u'Mountain View'),),
((u'organizationName', u'Google Inc'),),
((u'commonName', u'mail.google.com'),),
),
}
check(_verifycert(c, 'mail.google.com'), None)
Augie Fackler
tests: port test-url.py to Python 3...
r37892 check(_verifycert(c, 'gmail.com'), b'certificate is for mail.google.com')
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451
# Only commonName is considered
Augie Fackler
tests: port test-url.py to Python 3...
r37892 check(_verifycert(c, 'California'), b'certificate is for mail.google.com')
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451
# Neither commonName nor subjectAltName
c = {
'notAfter': 'Dec 18 23:59:59 2011 GMT',
'subject': (
((u'countryName', u'US'),),
((u'stateOrProvinceName', u'California'),),
((u'localityName', u'Mountain View'),),
((u'organizationName', u'Google Inc'),),
),
}
Augie Fackler
formatting: blacken the codebase...
r43346 check(
_verifycert(c, 'mail.google.com'),
b'no commonName or subjectAltName found in certificate',
)
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451
# No DNS entry in subjectAltName but a commonName
c = {
'notAfter': 'Dec 18 23:59:59 2099 GMT',
'subject': (
((u'countryName', u'US'),),
((u'stateOrProvinceName', u'California'),),
((u'localityName', u'Mountain View'),),
((u'commonName', u'mail.google.com'),),
),
'subjectAltName': (('othername', 'blabla'),),
}
check(_verifycert(c, 'mail.google.com'), None)
# No DNS entry subjectAltName and no commonName
c = {
'notAfter': 'Dec 18 23:59:59 2099 GMT',
'subject': (
((u'countryName', u'US'),),
((u'stateOrProvinceName', u'California'),),
((u'localityName', u'Mountain View'),),
((u'organizationName', u'Google Inc'),),
),
'subjectAltName': (('othername', 'blabla'),),
}
Augie Fackler
formatting: blacken the codebase...
r43346 check(
_verifycert(c, 'google.com'),
b'no commonName or subjectAltName found in certificate',
)
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451
# Empty cert / no cert
Augie Fackler
tests: port test-url.py to Python 3...
r37892 check(_verifycert(None, 'example.com'), b'no certificate received')
check(_verifycert({}, 'example.com'), b'no certificate received')
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451
# avoid denials of service by refusing more than one
# wildcard per fragment.
Augie Fackler
formatting: blacken the codebase...
r43346 check(
_verifycert({'subject': (((u'commonName', u'a*b.com'),),)}, 'axxb.com'),
None,
)
check(
_verifycert({'subject': (((u'commonName', u'a*b.co*'),),)}, 'axxb.com'),
b'certificate is for a*b.co*',
)
check(
_verifycert({'subject': (((u'commonName', u'a*b*.com'),),)}, 'axxbxxc.com'),
b'too many wildcards in certificate DNS name: a*b*.com',
)
Gregory Szorc
tests: import CPython's hostname matching tests...
r29451
Brodie Rao
url: provide url object...
r13770 def test_url():
"""
Augie Fackler
tests: fix error case in test-url.py's doctest...
r37891 >>> from mercurial import error, pycompat
Augie Fackler
tests: fix deprecation warning in test-url.py
r37974 >>> from mercurial.util import url
>>> from mercurial.utils.stringutil import forcebytestr
Brodie Rao
url: provide url object...
r13770
This tests for edge cases in url.URL's parsing algorithm. Most of
these aren't useful for documentation purposes, so they aren't
part of the class's doc tests.
Query strings and fragments:
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'http://host/a?b#c')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'http', host: 'host', path: 'a', query: 'b', fragment: 'c'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'http://host/a?')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'http', host: 'host', path: 'a'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'http://host/a#b#c')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'http', host: 'host', path: 'a', fragment: 'b#c'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'http://host/a#b?c')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'http', host: 'host', path: 'a', fragment: 'b?c'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'http://host/?a#b')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'http', host: 'host', path: '', query: 'a', fragment: 'b'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'http://host/?a#b', parsequery=False)
Brodie Rao
url: provide url object...
r13770 <url scheme: 'http', host: 'host', path: '?a', fragment: 'b'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'http://host/?a#b', parsefragment=False)
Brodie Rao
url: provide url object...
r13770 <url scheme: 'http', host: 'host', path: '', query: 'a#b'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'http://host/?a#b', parsequery=False, parsefragment=False)
Brodie Rao
url: provide url object...
r13770 <url scheme: 'http', host: 'host', path: '?a#b'>
IPv6 addresses:
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'ldap://[2001:db8::7]/c=GB?objectClass?one')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'ldap', host: '[2001:db8::7]', path: 'c=GB',
query: 'objectClass?one'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'ldap://joe:xxx@[2001:db8::7]:80/c=GB?objectClass?one')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'ldap', user: 'joe', passwd: 'xxx', host: '[2001:db8::7]',
port: '80', path: 'c=GB', query: 'objectClass?one'>
Missing scheme, host, etc.:
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'://192.0.2.16:80/')
Brodie Rao
url: provide url object...
r13770 <url path: '://192.0.2.16:80/'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'https://mercurial-scm.org')
Matt Mackall
urls: bulk-change primary website URLs
r26421 <url scheme: 'https', host: 'mercurial-scm.org'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'/foo')
Brodie Rao
url: provide url object...
r13770 <url path: '/foo'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'bundle:/foo')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'bundle', path: '/foo'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'a?b#c')
Brodie Rao
url: provide url object...
r13770 <url path: 'a?b', fragment: 'c'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'http://x.com?arg=/foo')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'http', host: 'x.com', query: 'arg=/foo'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'http://joe:xxx@/foo')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'http', user: 'joe', passwd: 'xxx', path: 'foo'>
Just a scheme and a path:
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'mailto:John.Doe@example.com')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'mailto', path: 'John.Doe@example.com'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'a:b:c:d')
Matt Mackall
url: fix tests
r13808 <url path: 'a:b:c:d'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'aa:bb:cc:dd')
Matt Mackall
url: fix tests
r13808 <url scheme: 'aa', path: 'bb:cc:dd'>
Brodie Rao
url: provide url object...
r13770
SSH examples:
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'ssh://joe@host//home/joe')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'ssh', user: 'joe', host: 'host', path: '/home/joe'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'ssh://joe:xxx@host/src')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'ssh', user: 'joe', passwd: 'xxx', host: 'host', path: 'src'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'ssh://joe:xxx@host')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'ssh', user: 'joe', passwd: 'xxx', host: 'host'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'ssh://joe@host')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'ssh', user: 'joe', host: 'host'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'ssh://host')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'ssh', host: 'host'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'ssh://')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'ssh'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'ssh:')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'ssh'>
Non-numeric port:
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'http://example.com:dd')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'http', host: 'example.com', port: 'dd'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'ssh://joe:xxx@host:ssh/foo')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'ssh', user: 'joe', passwd: 'xxx', host: 'host', port: 'ssh',
path: 'foo'>
Bad authentication credentials:
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'http://joe@joeville:123@4:@host/a?b#c')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'http', user: 'joe@joeville', passwd: '123@4:',
host: 'host', path: 'a', query: 'b', fragment: 'c'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'http://!*#?/@!*#?/:@host/a?b#c')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'http', host: '!*', fragment: '?/@!*#?/:@host/a?b#c'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'http://!*#?@!*#?:@host/a?b#c')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'http', host: '!*', fragment: '?@!*#?:@host/a?b#c'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'http://!*@:!*@@host/a?b#c')
Brodie Rao
url: provide url object...
r13770 <url scheme: 'http', user: '!*@', passwd: '!*@', host: 'host',
path: 'a', query: 'b', fragment: 'c'>
File paths:
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'a/b/c/d.g.f')
Brodie Rao
url: provide url object...
r13770 <url path: 'a/b/c/d.g.f'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'/x///z/y/')
Brodie Rao
url: provide url object...
r13770 <url path: '/x///z/y/'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'/foo:bar')
Brodie Rao
url: be stricter about detecting schemes...
r13848 <url path: '/foo:bar'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'\\\\foo:bar')
Brodie Rao
url: be stricter about detecting schemes...
r13848 <url path: '\\\\foo:bar'>
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> url(b'./foo:bar')
Brodie Rao
url: be stricter about detecting schemes...
r13848 <url path: './foo:bar'>
Brodie Rao
url: provide url object...
r13770
Brodie Rao
url: abort on file:// URLs with non-localhost hosts
r13817 Non-localhost file URL:
Augie Fackler
tests: fix error case in test-url.py's doctest...
r37891 >>> try:
... u = url(b'file://mercurial-scm.org/foo')
... except error.Abort as e:
Martin von Zweigbergk
errors: name arguments to Abort constructor...
r46274 ... e.message
Augie Fackler
tests: fix error case in test-url.py's doctest...
r37891 'file:// URLs can only refer to localhost'
Brodie Rao
url: abort on file:// URLs with non-localhost hosts
r13817
Brodie Rao
url: provide url object...
r13770 Empty URL:
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> u = url(b'')
Brodie Rao
url: provide url object...
r13770 >>> u
<url path: ''>
>>> str(u)
''
Empty path with query string:
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> str(url(b'http://foo/?bar'))
Brodie Rao
url: provide url object...
r13770 'http://foo/?bar'
Invalid path:
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> u = url(b'http://foo/bar')
>>> u.path = b'bar'
Brodie Rao
url: provide url object...
r13770 >>> str(u)
'http://foo/bar'
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> u = url(b'file:/foo/bar/baz')
Peter Arrenbrecht
util: make str(url) return file:/// for abs paths again...
r14313 >>> u
<url scheme: 'file', path: '/foo/bar/baz'>
>>> str(u)
'file:///foo/bar/baz'
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> pycompat.bytestr(u.localpath())
Mads Kiilerich
url: really handle urls of the form file:///c:/foo/bar/ correctly...
r15018 '/foo/bar/baz'
Peter Arrenbrecht
util: make str(url) return file:/// for abs paths again...
r14313
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> u = url(b'file:///foo/bar/baz')
Brodie Rao
url: provide url object...
r13770 >>> u
<url scheme: 'file', path: '/foo/bar/baz'>
>>> str(u)
Peter Arrenbrecht
util: make str(url) return file:/// for abs paths again...
r14313 'file:///foo/bar/baz'
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> pycompat.bytestr(u.localpath())
Mads Kiilerich
url: really handle urls of the form file:///c:/foo/bar/ correctly...
r15018 '/foo/bar/baz'
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> u = url(b'file:///f:oo/bar/baz')
Mads Kiilerich
url: really handle urls of the form file:///c:/foo/bar/ correctly...
r15018 >>> u
<url scheme: 'file', path: 'f:oo/bar/baz'>
>>> str(u)
Matt Mackall
merge with stable
r15611 'file:///f:oo/bar/baz'
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> pycompat.bytestr(u.localpath())
Mads Kiilerich
url: really handle urls of the form file:///c:/foo/bar/ correctly...
r15018 'f:oo/bar/baz'
Peter Arrenbrecht
util: make str(url) return file:/// for abs paths again...
r14313
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> u = url(b'file://localhost/f:oo/bar/baz')
Mads Kiilerich
url: handle file://localhost/c:/foo "correctly"...
r15496 >>> u
<url scheme: 'file', host: 'localhost', path: 'f:oo/bar/baz'>
>>> str(u)
Matt Mackall
merge with stable
r15513 'file://localhost/f:oo/bar/baz'
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> pycompat.bytestr(u.localpath())
Mads Kiilerich
url: handle file://localhost/c:/foo "correctly"...
r15496 'f:oo/bar/baz'
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> u = url(b'file:foo/bar/baz')
Peter Arrenbrecht
util: make str(url) return file:/// for abs paths again...
r14313 >>> u
<url scheme: 'file', path: 'foo/bar/baz'>
>>> str(u)
'file:foo/bar/baz'
Augie Fackler
tests: port test-url.py to Python 3...
r37892 >>> pycompat.bytestr(u.localpath())
Mads Kiilerich
url: really handle urls of the form file:///c:/foo/bar/ correctly...
r15018 'foo/bar/baz'
Brodie Rao
url: provide url object...
r13770 """
Augie Fackler
formatting: blacken the codebase...
r43346
Brodie Rao
tests: fix readline escape characters in heredoctest.py/test-url.py...
r15398 if 'TERM' in os.environ:
del os.environ['TERM']
Brodie Rao
url: provide url object...
r13770 doctest.testmod(optionflags=doctest.NORMALIZE_WHITESPACE)