ϪfdZddlmZddlmZddlmZddlmZddl m Z ddl m Z m Z ddlmZdd lmZdd lmZGd d eZy )z! Tests for L{twisted.names.tap}. )ThreadedResolver)Resolver)PORT) ResolverChain)SecondaryAuthorityService)Options_buildResolvers)platform) UsageError)SynchronousTestCasec8eZdZdZddZddZddZddZddZy) OptionsTestszf Tests for L{Options}, defining how command line arguments for the DNS server are parsed. Nc0t}|jt|jddg|jt|jddg|jt|jddg|jt|jddgy)z If the value supplied for an I{--secondary} option does not provide a server IP address, optional port number, and domain name, L{Options.parseOptions} raises L{UsageError}. --secondary1.2.3.4z 1.2.3.4:helloz1.2.3.4:hello/example.comN)r assertRaisesr parseOptionsselfoptionss =/usr/lib/python3/dist-packages/twisted/names/test/test_tap.pytest_malformedSecondaryz$OptionsTests.test_malformedSecondarys ) *g&:&:]B?ATATUrc~t}|jddg|jddgfg|jy)z An argument of the form C{"ip:port/domain"} can be used to specify an alternate port number for which to act as a secondary. r1.2.3.4:5353/example.com)rrN)rrrrrs rtest_secondaryExplicitPortz'OptionsTests.test_secondaryExplicitPort5s@ )m-GHI ,}o>?ATATUrc0t}|jgd|jt|jd|jd}|j |jdt |j|jd|j|jd|jd}|j |jdt |j|jd|j|jdy ) z After parsing I{--secondary} options, L{Options} constructs a L{SecondaryAuthorityService} instance for each configured secondary. )rr!rz1.2.3.5:5354/example.comrrr"z1.2.3.5iN) rrrlensvcsassertIsInstancerprimary_port)rr secondarys rtest_secondaryAuthorityServicesz,OptionsTests.test_secondaryAuthorityServices>s )   W\\*A.LLO  gll1o/HI **I6 $/LLO  gll1o/HI **I6 $/rct}|jgdt|\}}|D]M}t|ts|j d}t|t s4|jjOtjdk7r[ddl m }|jD]F}|j|jj t"j$|jH|j'|dty)z Recursive DNS lookups, if enabled, should be a last-resort option. Any other lookup method (cache, local lookup, etc.) should take precedence over recursive lookups )z --hosts-filez hosts.txtz --recursiveposixr)reactorN)rrr isinstancer resolversr _parseCallcancelr getTypetwisted.internetr1_newTimedCallsrfunc__func__r_cleanupr))rrcaclxrecurserr1s rtest_recursiveConfigurationz(OptionsTests.test_recursiveConfigurationVs )IJ )B 1A!]+;;r?h1''..0  1     ( 1++   2B2K2KL   bfm4r)returnN) __name__ __module__ __qualname____doc__rrr#r-r@rrrrs"  $VV00 5rrN)rEtwisted.internet.basertwisted.names.clientrtwisted.names.dnsrtwisted.names.resolvertwisted.names.secondaryrtwisted.names.taprr twisted.python.runtimer twisted.python.usager twisted.trial.unittestr rrFrrrPs63)"/=6++6c5&c5r