##// END OF EJS Templates
sslutil: synchronize hostname matching logic with CPython...
sslutil: synchronize hostname matching logic with CPython sslutil contains its own hostname matching logic. CPython has code for the same intent. However, it is only available to Python 2.7.9+ (or distributions that have backported 2.7.9's ssl module improvements). This patch effectively imports CPython's hostname matching code from its ssl.py into sslutil.py. The hostname matching code itself is pretty similar. However, the DNS name matching code is much more robust and spec conformant. As the test changes show, this changes some behavior around wildcard handling and IDNA matching. The new behavior allows wildcards in the middle of words (e.g. 'f*.com' matches 'foo.com') This is spec compliant according to RFC 6125 Section 6.5.3 item 3. There is one test where the matcher is more strict. Before, '*.a.com' matched '.a.com'. Now it doesn't match. Strictly speaking this is a security vulnerability.

File last commit:

r28776:5508a277 default
r29452:26a5d605 3.8.4 stable
Show More
test-ui-config.py
103 lines | 3.7 KiB | text/x-python | PythonLexer
/ tests / test-ui-config.py
Pulkit Goyal
py3: make test-ui-config use print_function
r28681 from __future__ import absolute_import, print_function
Pulkit Goyal
py3: make test-ui-config use absolute_import
r28680 from mercurial import (
dispatch,
error,
Yuya Nishihara
tests: alias ui as uimod in test-ui-config
r28776 ui as uimod,
Pulkit Goyal
py3: make test-ui-config use absolute_import
r28680 )
Martin Geisler
tests: renamed Python tests to .py
r8449
Yuya Nishihara
tests: alias ui as uimod in test-ui-config
r28776 testui = uimod.ui()
Martin Geisler
tests: renamed Python tests to .py
r8449 parsed = dispatch._parseconfig(testui, [
'values.string=string value',
'values.bool1=true',
'values.bool2=false',
Sune Foldager
ui: add configint function and tests
r14171 'values.boolinvalid=foo',
'values.int1=42',
'values.int2=-42',
'values.intinvalid=foo',
Martin Geisler
tests: renamed Python tests to .py
r8449 'lists.list1=foo',
'lists.list2=foo bar baz',
'lists.list3=alice, bob',
'lists.list4=foo bar baz alice, bob',
Henrik Stuart
ui: support quotes in configlist (issue2147)...
r10982 'lists.list5=abc d"ef"g "hij def"',
'lists.list6="hello world", "how are you?"',
'lists.list7=Do"Not"Separate',
'lists.list8="Do"Separate',
'lists.list9="Do\\"NotSeparate"',
'lists.list10=string "with extraneous" quotation mark"',
'lists.list11=x, y',
'lists.list12="x", "y"',
'lists.list13=""" key = "x", "y" """',
'lists.list14=,,,, ',
'lists.list15=" just with starting quotation',
'lists.list16="longer quotation" with "no ending quotation',
'lists.list17=this is \\" "not a quotation mark"',
Thomas Arendsen Hein
ui: handle leading newlines/spaces/commas in configlist...
r11309 'lists.list18=\n \n\nding\ndong',
Sune Foldager
ui: add configint function and tests
r14171 ])
Martin Geisler
tests: renamed Python tests to .py
r8449
Pulkit Goyal
py3: make test-ui-config use print_function
r28681 print(repr(testui.configitems('values')))
print(repr(testui.configitems('lists')))
print("---")
print(repr(testui.config('values', 'string')))
print(repr(testui.config('values', 'bool1')))
print(repr(testui.config('values', 'bool2')))
print(repr(testui.config('values', 'unknown')))
print("---")
Martin Geisler
tests: renamed Python tests to .py
r8449 try:
Pulkit Goyal
py3: make test-ui-config use print_function
r28681 print(repr(testui.configbool('values', 'string')))
Gregory Szorc
global: mass rewrite to use modern exception syntax...
r25660 except error.ConfigError as inst:
Pulkit Goyal
py3: make test-ui-config use print_function
r28681 print(inst)
print(repr(testui.configbool('values', 'bool1')))
print(repr(testui.configbool('values', 'bool2')))
print(repr(testui.configbool('values', 'bool2', True)))
print(repr(testui.configbool('values', 'unknown')))
print(repr(testui.configbool('values', 'unknown', True)))
print("---")
print(repr(testui.configint('values', 'int1')))
print(repr(testui.configint('values', 'int2')))
print("---")
print(repr(testui.configlist('lists', 'list1')))
print(repr(testui.configlist('lists', 'list2')))
print(repr(testui.configlist('lists', 'list3')))
print(repr(testui.configlist('lists', 'list4')))
print(repr(testui.configlist('lists', 'list4', ['foo'])))
print(repr(testui.configlist('lists', 'list5')))
print(repr(testui.configlist('lists', 'list6')))
print(repr(testui.configlist('lists', 'list7')))
print(repr(testui.configlist('lists', 'list8')))
print(repr(testui.configlist('lists', 'list9')))
print(repr(testui.configlist('lists', 'list10')))
print(repr(testui.configlist('lists', 'list11')))
print(repr(testui.configlist('lists', 'list12')))
print(repr(testui.configlist('lists', 'list13')))
print(repr(testui.configlist('lists', 'list14')))
print(repr(testui.configlist('lists', 'list15')))
print(repr(testui.configlist('lists', 'list16')))
print(repr(testui.configlist('lists', 'list17')))
print(repr(testui.configlist('lists', 'list18')))
print(repr(testui.configlist('lists', 'unknown')))
print(repr(testui.configlist('lists', 'unknown', '')))
print(repr(testui.configlist('lists', 'unknown', 'foo')))
print(repr(testui.configlist('lists', 'unknown', ['foo'])))
print(repr(testui.configlist('lists', 'unknown', 'foo bar')))
print(repr(testui.configlist('lists', 'unknown', 'foo, bar')))
print(repr(testui.configlist('lists', 'unknown', ['foo bar'])))
print(repr(testui.configlist('lists', 'unknown', ['foo', 'bar'])))
Martin Geisler
tests: renamed Python tests to .py
r8449
Pulkit Goyal
py3: make test-ui-config use print_function
r28681 print(repr(testui.config('values', 'String')))
Martin Geisler
tests: renamed Python tests to .py
r8449
def function():
pass
# values that aren't strings should work
testui.setconfig('hook', 'commit', function)
Pulkit Goyal
py3: make test-ui-config use print_function
r28681 print(function == testui.config('hook', 'commit'))
Sune Foldager
ui: add configint function and tests
r14171
# invalid values
try:
testui.configbool('values', 'boolinvalid')
except error.ConfigError:
Pulkit Goyal
py3: make test-ui-config use print_function
r28681 print('boolinvalid')
Sune Foldager
ui: add configint function and tests
r14171 try:
testui.configint('values', 'intinvalid')
except error.ConfigError:
Pulkit Goyal
py3: make test-ui-config use print_function
r28681 print('intinvalid')