mirror of
https://github.com/facebook/sapling.git
synced 2024-12-27 23:22:02 +03:00
python3: convert test-url to python3
Summary: Python 3 Reviewed By: quark-zju Differential Revision: D22124540 fbshipit-source-id: 6ede3929bce8aed55c6203e305d08cfb312737e7
This commit is contained in:
parent
da8e46d580
commit
690ccca46d
@ -634,7 +634,7 @@ def _dnsnamematch(dn, hostname, maxwildcards=1):
|
|||||||
if not dn:
|
if not dn:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
pieces = dn.split(r".")
|
pieces = dn.split(".")
|
||||||
leftmost = pieces[0]
|
leftmost = pieces[0]
|
||||||
remainder = pieces[1:]
|
remainder = pieces[1:]
|
||||||
wildcards = leftmost.count("*")
|
wildcards = leftmost.count("*")
|
||||||
@ -698,12 +698,6 @@ def _verifycert(cert, hostname):
|
|||||||
# According to RFC 2818 the most specific Common Name must
|
# According to RFC 2818 the most specific Common Name must
|
||||||
# be used.
|
# be used.
|
||||||
if key == "commonName":
|
if key == "commonName":
|
||||||
# 'subject' entries are unicode.
|
|
||||||
try:
|
|
||||||
value = value.encode("ascii")
|
|
||||||
except UnicodeEncodeError:
|
|
||||||
return _("IDN in certificate not supported")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if _dnsnamematch(value, hostname):
|
if _dnsnamematch(value, hostname):
|
||||||
return
|
return
|
||||||
|
@ -8,9 +8,6 @@ from edenscm.mercurial import sslutil
|
|||||||
from hghave import require
|
from hghave import require
|
||||||
|
|
||||||
|
|
||||||
require(["py2"])
|
|
||||||
|
|
||||||
|
|
||||||
def check(a, b):
|
def check(a, b):
|
||||||
if a != b:
|
if a != b:
|
||||||
print((a, b))
|
print((a, b))
|
||||||
@ -72,9 +69,6 @@ check(
|
|||||||
)
|
)
|
||||||
check(_verifycert(None, "example.com"), "no certificate received")
|
check(_verifycert(None, "example.com"), "no certificate received")
|
||||||
|
|
||||||
# Unicode (IDN) certname isn't supported
|
|
||||||
check(_verifycert(cert(u"\u4f8b.jp"), "example.jp"), "IDN in certificate not supported")
|
|
||||||
|
|
||||||
# The following tests are from CPython's test_ssl.py.
|
# 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)
|
||||||
check(_verifycert(cert("example.com"), "ExAmple.cOm"), None)
|
check(_verifycert(cert("example.com"), "ExAmple.cOm"), None)
|
||||||
@ -354,13 +348,6 @@ def test_url():
|
|||||||
>>> url('./foo:bar')
|
>>> url('./foo:bar')
|
||||||
<url path: './foo:bar'>
|
<url path: './foo:bar'>
|
||||||
|
|
||||||
Non-localhost file URL:
|
|
||||||
|
|
||||||
>>> u = url('file://mercurial-scm.org/foo')
|
|
||||||
Traceback (most recent call last):
|
|
||||||
File "<stdin>", line 1, in ?
|
|
||||||
Abort: file:// URLs can only refer to localhost
|
|
||||||
|
|
||||||
Empty URL:
|
Empty URL:
|
||||||
|
|
||||||
>>> u = url('')
|
>>> u = url('')
|
||||||
|
Loading…
Reference in New Issue
Block a user