equal
deleted
inserted
replaced
1 from __future__ import print_function |
1 from __future__ import absolute_import, print_function |
|
2 |
|
3 import doctest |
2 import os |
4 import os |
3 |
5 |
4 def check(a, b): |
6 def check(a, b): |
5 if a != b: |
7 if a != b: |
6 print((a, b)) |
8 print((a, b)) |
7 |
9 |
8 def cert(cn): |
10 def cert(cn): |
9 return {'subject': ((('commonName', cn),),)} |
11 return {'subject': ((('commonName', cn),),)} |
10 |
12 |
11 from mercurial.sslutil import _verifycert |
13 from mercurial import ( |
12 |
14 sslutil, |
|
15 ) |
|
16 |
|
17 _verifycert = sslutil._verifycert |
13 # Test non-wildcard certificates |
18 # Test non-wildcard certificates |
14 check(_verifycert(cert('example.com'), 'example.com'), |
19 check(_verifycert(cert('example.com'), 'example.com'), |
15 None) |
20 None) |
16 check(_verifycert(cert('example.com'), 'www.example.com'), |
21 check(_verifycert(cert('example.com'), 'www.example.com'), |
17 'certificate is for example.com') |
22 'certificate is for example.com') |
55 'no certificate received') |
60 'no certificate received') |
56 |
61 |
57 # Unicode (IDN) certname isn't supported |
62 # Unicode (IDN) certname isn't supported |
58 check(_verifycert(cert(u'\u4f8b.jp'), 'example.jp'), |
63 check(_verifycert(cert(u'\u4f8b.jp'), 'example.jp'), |
59 'IDN in certificate not supported') |
64 'IDN in certificate not supported') |
60 |
|
61 import doctest |
|
62 |
65 |
63 def test_url(): |
66 def test_url(): |
64 """ |
67 """ |
65 >>> from mercurial.util import url |
68 >>> from mercurial.util import url |
66 |
69 |