mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
The existing pattern matching code: val.find('*.') == 0 and name.find(val[1:]) + len(val[1:]) == len(name) will return True in the following case: val = '*.host.com' name = 'blah.org' since string.find() will return -1, len(val[1:]) == 9 and len(name) == 8.
24 lines
1 KiB
Python
24 lines
1 KiB
Python
import unittest
|
|
|
|
from lib import interface
|
|
|
|
|
|
class TestInterface(unittest.TestCase):
|
|
|
|
def test_match_host_name(self):
|
|
self.assertTrue(interface._match_hostname('asd.fgh.com', 'asd.fgh.com'))
|
|
self.assertFalse(interface._match_hostname('asd.fgh.com', 'asd.zxc.com'))
|
|
self.assertTrue(interface._match_hostname('asd.fgh.com', '*.fgh.com'))
|
|
self.assertFalse(interface._match_hostname('asd.fgh.com', '*fgh.com'))
|
|
self.assertFalse(interface._match_hostname('asd.fgh.com', '*.zxc.com'))
|
|
|
|
def test_check_host_name(self):
|
|
self.assertFalse(interface.check_host_name(None, None))
|
|
self.assertFalse(interface.check_host_name(
|
|
peercert={'subjectAltName': []}, name=''))
|
|
self.assertTrue(interface.check_host_name(
|
|
peercert={'subjectAltName': [('DNS', '*.bar.com')]},
|
|
name='foo.bar.com'))
|
|
self.assertTrue(interface.check_host_name(
|
|
peercert={'subject': [('commonName', '*.bar.com')]},
|
|
name='foo.bar.com'))
|