mirror of https://gitlab.com/bashrc2/epicyon
Tests for international domain handling
parent
7ac901980f
commit
fd12451f5a
15
tests.py
15
tests.py
|
@ -33,6 +33,7 @@ from follow import clearFollows
|
||||||
from follow import clearFollowers
|
from follow import clearFollowers
|
||||||
from follow import sendFollowRequestViaServer
|
from follow import sendFollowRequestViaServer
|
||||||
from follow import sendUnfollowRequestViaServer
|
from follow import sendUnfollowRequestViaServer
|
||||||
|
from utils import decodedHost
|
||||||
from utils import getFullDomain
|
from utils import getFullDomain
|
||||||
from utils import validNickname
|
from utils import validNickname
|
||||||
from utils import firstParagraphFromString
|
from utils import firstParagraphFromString
|
||||||
|
@ -3059,9 +3060,23 @@ def testMastoApi():
|
||||||
assert nickname2 == nickname
|
assert nickname2 == nickname
|
||||||
|
|
||||||
|
|
||||||
|
def testDomainHandling():
|
||||||
|
print('testDomainHandling')
|
||||||
|
testDomain = 'localhost'
|
||||||
|
assert decodedHost(testDomain) == testDomain
|
||||||
|
testDomain = '127.0.0.1:60'
|
||||||
|
assert decodedHost(testDomain) == testDomain
|
||||||
|
testDomain = '192.168.5.153'
|
||||||
|
assert decodedHost(testDomain) == testDomain
|
||||||
|
testDomain = 'xn--espaa-rta.icom.museum'
|
||||||
|
print(decodedHost(testDomain))
|
||||||
|
assert decodedHost(testDomain) == "españa.icom.museum"
|
||||||
|
|
||||||
|
|
||||||
def runAllTests():
|
def runAllTests():
|
||||||
print('Running tests...')
|
print('Running tests...')
|
||||||
testFunctions()
|
testFunctions()
|
||||||
|
testDomainHandling()
|
||||||
testMastoApi()
|
testMastoApi()
|
||||||
testLinksWithinPost()
|
testLinksWithinPost()
|
||||||
testReplyToPublicPost()
|
testReplyToPublicPost()
|
||||||
|
|
11
utils.py
11
utils.py
|
@ -36,12 +36,11 @@ def decodedHost(host: str) -> str:
|
||||||
https://en.wikipedia.org/wiki/Internationalized_domain_name
|
https://en.wikipedia.org/wiki/Internationalized_domain_name
|
||||||
"""
|
"""
|
||||||
if ':' not in host:
|
if ':' not in host:
|
||||||
if not _localNetworkHost(host):
|
# eg. mydomain:8000
|
||||||
if not host.endswith('.onion'):
|
if not _localNetworkHost(host):
|
||||||
if not host.endswith('.i2p'):
|
if not host.endswith('.onion'):
|
||||||
# For domains on ports numbers don't use idna
|
if not host.endswith('.i2p'):
|
||||||
# eg. mydomain:8000
|
return idna.decode(host)
|
||||||
return idna.decode(host)
|
|
||||||
return host
|
return host
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue