@@ -185,6 +185,44 @@ def _test_get_domain_config(config):
185185 assert (res .urlAPI == config ['API_URL' ]), 'urlAPI not correct: {}' .format (res .urlAPI )
186186 assert (res .providerName == config ['PROVIDER_ID' ]), 'providerName not correct: {}' .format (res .providerName )
187187
188+ domainroottests = [
189+ ('test.com' , 'test.com' , '' ),
190+ ('subdomain.test.com' , 'test.com' , 'subdomain' ),
191+ ('sub.subdomain.test.com' , 'test.com' , 'sub.subdomain' ),
192+ ('test.co.uk' , 'test.co.uk' , '' ),
193+ ('subdomain.test.co.uk' , 'test.co.uk' , 'subdomain' ),
194+ ('sub.subdomain.test.co.uk' , 'test.co.uk' , 'sub.subdomain' ),
195+ ('test.uk' , 'test.uk' , '' ),
196+ ('subdomain.test.uk' , 'test.uk' , 'subdomain' ),
197+ ('sub.subdomain.test.uk' , 'test.uk' , 'sub.subdomain' ),
198+ ('test.com.de' , 'test.com.de' , '' ),
199+ ('subdomain.test.com.de' , 'test.com.de' , 'subdomain' ),
200+ ('sub.subdomain.test.com.de' , 'test.com.de' , 'sub.subdomain' ),
201+ ('test.poznan.pl' , 'test.poznan.pl' , '' ),
202+ ('subdomain.test.poznan.pl' , 'test.poznan.pl' , 'subdomain' ),
203+ ('sub.subdomain.test.poznan.pl' , 'test.poznan.pl' , 'sub.subdomain' ),
204+ ('get.app' , 'get.app' , '' ),
205+ ('subdomain.get.app' , 'get.app' , 'subdomain' ),
206+ ('sub.subdomain.get.app' , 'get.app' , 'sub.subdomain' ),
207+ ('get.unkownnewtld' , 'get.unkownnewtld' , '' ),
208+ ('subdomain.get.unkownnewtld' , 'get.unkownnewtld' , 'subdomain' ),
209+ ('sub.subdomain.get.unkownnewtld' , 'get.unkownnewtld' , 'sub.subdomain' ),
210+ ]
211+
212+ def test_get_domain_root (self ):
213+ for i in TestDomainConnect .domainroottests :
214+ with self .subTest (i = i ):
215+ self ._test_get_domain_root (i )
216+
217+ @staticmethod
218+ def _test_get_domain_root (config ):
219+ dc = DomainConnect ()
220+ domain_root = dc .identify_domain_root (config [0 ]);
221+ assert domain_root is not None , "No domain root found"
222+ assert domain_root == config [1 ], "Wrong domain root found. Expected {}, Found {}" .format (config [1 ], domain_root )
223+ assert '{}{}{}' .format (config [2 ], '' if config [2 ] == '' else '.' , domain_root ) == config [0 ], "Domain root + subdomain != domain"
224+
225+
188226 def test_get_domain_connect_template_async_url (self ):
189227 for i in configs :
190228 with self .subTest (i = i ):
0 commit comments