From 873910a6e4f43a19c045bbf323aa429be947bf43 Mon Sep 17 00:00:00 2001 From: pawel-kow Date: Tue, 29 Oct 2019 13:27:40 +0100 Subject: [PATCH 1/2] BUGFIX: issues/4 error when setting up .app domain UNIT TEST: added test of detecting right domain name --- README.md | 1 + domainconnect/domainconnect.py | 4 +-- domainconnect/tests/test_domainConnect.py | 38 +++++++++++++++++++++++ requirements.txt | 12 +++---- setup.py | 12 +++---- 5 files changed, 53 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 4e0bd1c..c96f770 100644 --- a/README.md +++ b/README.md @@ -145,5 +145,6 @@ dc = DomainConnect( ## CHANGELOG | version | date | changes | | ------- | -----------| ------ | +| 0.0.7 | 2019-10-29 | Bugfix: error when setting up .app domain | | 0.0.6 | 2019-07-05 | UPDATE: moved from pycrypto to cryptography (due to know security issues) | | 0.0.5 | 2019-03-12 | NEW FEATURE: url signing capability added | diff --git a/domainconnect/domainconnect.py b/domainconnect/domainconnect.py index 1effe31..a66214f 100644 --- a/domainconnect/domainconnect.py +++ b/domainconnect/domainconnect.py @@ -13,7 +13,7 @@ from six.moves import urllib from dns.exception import Timeout from dns.resolver import Resolver, NXDOMAIN, YXDOMAIN, NoAnswer, NoNameservers -from publicsuffix import PublicSuffixList +from publicsuffixlist import PublicSuffixList import webbrowser from .network import get_json, get_http, http_request_json, NetworkContext @@ -195,7 +195,7 @@ def __init__(self, networkcontext=NetworkContext()): @staticmethod def identify_domain_root(domain): - return psl.get_public_suffix(domain) + return psl.privatesuffix(domain) def _identify_domain_connect_api(self, domain_root): # noinspection PyBroadException diff --git a/domainconnect/tests/test_domainConnect.py b/domainconnect/tests/test_domainConnect.py index 0d1022e..d610471 100644 --- a/domainconnect/tests/test_domainConnect.py +++ b/domainconnect/tests/test_domainConnect.py @@ -185,6 +185,44 @@ def _test_get_domain_config(config): assert (res.urlAPI == config['API_URL']), 'urlAPI not correct: {}'.format(res.urlAPI) assert (res.providerName == config['PROVIDER_ID']), 'providerName not correct: {}'.format(res.providerName) + domainroottests = [ + ('test.com', 'test.com', ''), + ('subdomain.test.com', 'test.com', 'subdomain'), + ('sub.subdomain.test.com', 'test.com', 'sub.subdomain'), + ('test.co.uk', 'test.co.uk', ''), + ('subdomain.test.co.uk', 'test.co.uk', 'subdomain'), + ('sub.subdomain.test.co.uk', 'test.co.uk', 'sub.subdomain'), + ('test.uk', 'test.uk', ''), + ('subdomain.test.uk', 'test.uk', 'subdomain'), + ('sub.subdomain.test.uk', 'test.uk', 'sub.subdomain'), + ('test.com.de', 'test.com.de', ''), + ('subdomain.test.com.de', 'test.com.de', 'subdomain'), + ('sub.subdomain.test.com.de', 'test.com.de', 'sub.subdomain'), + ('test.poznan.pl', 'test.poznan.pl', ''), + ('subdomain.test.poznan.pl', 'test.poznan.pl', 'subdomain'), + ('sub.subdomain.test.poznan.pl', 'test.poznan.pl', 'sub.subdomain'), + ('get.app', 'get.app', ''), + ('subdomain.get.app', 'get.app', 'subdomain'), + ('sub.subdomain.get.app', 'get.app', 'sub.subdomain'), + ('get.unkownnewtld', 'get.unkownnewtld', ''), + ('subdomain.get.unkownnewtld', 'get.unkownnewtld', 'subdomain'), + ('sub.subdomain.get.unkownnewtld', 'get.unkownnewtld', 'sub.subdomain'), + ] + + def test_get_domain_root(self): + for i in TestDomainConnect.domainroottests: + with self.subTest(i=i): + self._test_get_domain_root(i) + + @staticmethod + def _test_get_domain_root(config): + dc = DomainConnect() + domain_root = dc.identify_domain_root(config[0]); + assert domain_root is not None, "No domain root found" + assert domain_root == config[1], "Wrong domain root found. Expected {}, Found {}".format(config[1], domain_root) + assert '{}{}{}'.format(config[2], '' if config[2] == '' else '.', domain_root) == config[0], "Domain root + subdomain != domain" + + def test_get_domain_connect_template_async_url(self): for i in configs: with self.subTest(i=i): diff --git a/requirements.txt b/requirements.txt index b933b75..6fde7db 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,12 @@ -asn1crypto==0.24.0 -cffi==1.12.3 -cryptography==2.7 +asn1crypto==1.2.0 +cffi==1.13.1 +cryptography==2.8 dnspython==1.16.0 -future==0.17.1 +future==0.18.1 linecache2==1.0.0 publicsuffix==1.1.0 -publicsuffixlist==0.6.5 -pybase64==0.5.0 +publicsuffixlist==0.6.11 +pybase64==1.0.0 pycparser==2.19 six==1.12.0 traceback2==1.4.0 diff --git a/setup.py b/setup.py index 6d4f36b..b95416c 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup setup(name='domain_connect', - version='0.0.6', + version='0.0.7', description='Python client library for Domain Connect protocol. See: https://domainconnect.org', long_description_content_type="text/markdown", long_description=open('README.md').read(), @@ -19,11 +19,11 @@ 'domainconnect', ], install_requires=[ - 'dnspython >= 1.15.0', + 'dnspython >= 1.16.0', 'publicsuffix >= 1.1.0', - 'publicsuffixlist >= 0.6.1', - 'six >= 1.11.0', - 'future >= 0.16.0', - 'cryptography >= 2.7' + 'publicsuffixlist >= 0.6.11', + 'six >= 1.12.0', + 'future >= 0.18.1', + 'cryptography >= 2.8' ], ) From 2e67f78859f650312c720faaa20fdb3a93967434 Mon Sep 17 00:00:00 2001 From: pawel-kow Date: Tue, 29 Oct 2019 13:40:58 +0100 Subject: [PATCH 2/2] BUGFIX: pybase downgraded to keep python 2.7 support --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 6fde7db..e291b06 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ future==0.18.1 linecache2==1.0.0 publicsuffix==1.1.0 publicsuffixlist==0.6.11 -pybase64==1.0.0 +pybase64==0.5.0 pycparser==2.19 six==1.12.0 traceback2==1.4.0