ϪfȢPdZddlmZddlmZddlmZddlmZm Z m Z m Z ddl m Z mZddlmZGdd eZd ZGd d e j(ZGd de j(ZGddZGddZGddZGddZdZGddej8Zy)z) Test cases for L{twisted.names.server}. ) verifyClass)defer)IProtocolFactory)dnserrorresolveserver)failurelog)unittestceZdZdZdZy)RaisedArgumentszD An exception containing the arguments raised by L{raiser}. c ||_||_yNargskwargsselfrrs @/usr/lib/python3/dist-packages/twisted/names/test/test_server.py__init__zRaisedArguments.__init__s  N)__name__ __module__ __qualname____doc__rrrrrs rrct||)z Raise a L{RaisedArguments} exception containing the supplied arguments. Used as a fake when testing the call signatures of methods and functions. )rrs rraiserrs $ ''rceZdZdZdZdZy)NoResponseDNSServerFactorya A L{server.DNSServerFactory} subclass which does not attempt to reply to any received messages. Used for testing logged messages in C{messageReceived} without having to fake or patch the preceding code which attempts to deliver a response message. cy)a Deny all queries. @param message: See L{server.DNSServerFactory.allowQuery} @param protocol: See L{server.DNSServerFactory.allowQuery} @param address: See L{server.DNSServerFactory.allowQuery} @return: L{False} @rtype: L{bool} Fr)rmessageprotocoladdresss r allowQueryz%NoResponseDNSServerFactory.allowQuery.srcy)z A noop send reply. @param protocol: See L{server.DNSServerFactory.sendReply} @param message: See L{server.DNSServerFactory.sendReply} @param address: See L{server.DNSServerFactory.sendReply} Nr)rr$r#r%s r sendReplyz$NoResponseDNSServerFactory.sendReply;rN)rrrrr&r(rrrr!r!$s  rr!c,eZdZdZGddeZdZy)RaisingDNSServerFactoryz A L{server.DNSServerFactory} subclass whose methods raise an exception containing the supplied arguments. Used for stopping L{messageReceived} and testing the arguments supplied to L{allowQuery}. ceZdZdZy)+RaisingDNSServerFactory.AllowQueryArgumentsG Contains positional and keyword arguments in C{args}. NrrrrrrrAllowQueryArgumentsr-N rr0c&|j||)aC Raise the arguments supplied to L{allowQuery}. @param args: Positional arguments which will be recorded in the raised exception. @type args: L{tuple} @param kwargs: Keyword args which will be recorded in the raised exception. @type kwargs: L{dict} )r0rs rr&z"RaisingDNSServerFactory.allowQuerySs&&tV44rN)rrrr Exceptionr0r&rrrr+r+Es i 5rr+c,eZdZdZGddeZdZy)RaisingProtocolzm A partial fake L{IProtocol} whose methods raise an exception containing the supplied arguments. ceZdZdZy)%RaisingProtocol.WriteMessageArgumentsr.Nr/rrrWriteMessageArgumentsr7hr1rr8c&|j||z Raises the supplied arguments. @param args: Positional arguments @type args: L{tuple} @param kwargs: Keyword args @type kwargs: L{dict} )r8rs r writeMessagezRaisingProtocol.writeMessagems((v66rN)rrrrr3r8r;rrrr5r5bs   7rr5ceZdZdZdZy) NoopProtocolzT A partial fake L{dns.DNSProtocolMixin} with a noop L{writeMessage} method. cy)z A noop version of L{dns.DNSProtocolMixin.writeMessage}. @param args: Positional arguments @type args: L{tuple} @param kwargs: Keyword args @type kwargs: L{dict} Nrrs rr;zNoopProtocol.writeMessager)rN)rrrrr;rrrr=r=zs   rr=c,eZdZdZGddeZdZy)RaisingResolverzm A partial fake L{IResolver} whose methods raise an exception containing the supplied arguments. ceZdZdZy)RaisingResolver.QueryArgumentsr.Nr/rrrQueryArgumentsrBr1rrCc&|j||r:)rCrs rqueryzRaisingResolver.querys!!$//rN)rrrrr3rCrErrrr@r@s   0rr@c,eZdZdZGddeZdZy) RaisingCachez} A partial fake L{twisted.names.cache.Cache} whose methods raise an exception containing the supplied arguments. ceZdZdZy)!RaisingCache.CacheResultArgumentsr.Nr/rrrCacheResultArgumentsrIr1rrJc&|j||r:)rJrs r cacheResultzRaisingCache.cacheResults''f55rN)rrrrr3rJrLrrrrGrGs  y 6rrGcg}tj|j|jtj|j||i||j |Dcgc] }|dd c}|ycc}w)a Assert that the callable logs the expected messages when called. XXX: Put this somewhere where it can be re-used elsewhere. See #6677. @param testCase: The test case controlling the test which triggers the logged messages and on which assertions will be called. @type testCase: L{unittest.SynchronousTestCase} @param expectedMessages: A L{list} of the expected log messages @type expectedMessages: L{list} @param callable: The function which is expected to produce the C{expectedMessages} when called. @type callable: L{callable} @param args: Positional arguments to be passed to C{callable}. @type args: L{list} @param kwargs: Keyword arguments to be passed to C{callable}. @type kwargs: L{dict} r#rN)r addObserverappend addCleanupremoveObserver assertEqual)testCaseexpectedMessagescallablerrloggedMessagesms rassertLogMessagerXsk.NOON))* **N,A,AB df >Ba!I,q/BDTUBs#A;ceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#d"Z$d#Z%d$Z&d%Z'd&Z(d'Z)d(Z*d)Z+d*Z,d+Z-d,Z.d-Z/d.Z0d/Z1d0Z2d1Z3d2Z4d3Z5d4Z6d5Z7d6Z8d7Z9d8Z:d9Z;d:Zd=Z?d>Z@d?ZAd@ZBdAZCyB)CDNSServerFactoryTestsz/ Tests for L{server.DNSServerFactory}. c||jtjjtj y)zd L{server.DNSServerFactory.resolver} is a L{resolve.ResolverChain} instance N)assertIsInstancer DNSServerFactoryresolverr ResolverChainrs rtest_resolverTypez'DNSServerFactoryTests.test_resolverTypes) f557@@'BWBWXrct|jtjjjgy)zn L{server.DNSServerFactory.resolver} is an empty L{resolve.ResolverChain} by default. NrRr r]r^ resolversr`s rtest_resolverDefaultEmptyz/DNSServerFactoryTests.test_resolverDefaultEmptys) 002;;EErJrct}|jtj|gjj |gy)z L{server.DNSServerFactory.__init__} accepts an C{authorities} argument. The value of this argument is a list and is used to extend the C{resolver} L{resolve.ResolverChain}. ) authoritiesNobjectrRr r]r^rdr dummyResolvers rtest_authoritiesz&DNSServerFactoryTests.test_authoritiess:     # # @ I I S S O rct}|jtj|gjj |gy)z L{server.DNSServerFactory.__init__} accepts a C{caches} argument. The value of this argument is a list and is used to extend the C{resolver} L{resolve.ResolverChain}. cachesNrhrjs r test_cachesz!DNSServerFactoryTests.test_cachess:     # #M? ; D D N N O rct}|jtj|gjj |gy)z L{server.DNSServerFactory.__init__} accepts a C{clients} argument. The value of this argument is a list and is used to extend the C{resolver} L{resolve.ResolverChain}. clientsNrhrjs r test_clientsz"DNSServerFactoryTests.test_clientss:     # #]O < E E O O O rcGdd}Gdd}Gdd}|jtj|g|g|gjj|||gy) zz L{server.DNSServerFactory.resolver} contains an ordered list of authorities, caches and clients. c eZdZy)@DNSServerFactoryTests.test_resolverOrder..DummyAuthorityNrrrrrrDummyAuthorityrw rryc eZdZy).DummyCacheNrxrrr DummyCacher|rzrr}c eZdZy)=DNSServerFactoryTests.test_resolverOrder..DummyClientNrxrrr DummyClientrrzrr)rgrorsNrc)rryr}rs rtest_resolverOrderz(DNSServerFactoryTests.test_resolverOrders_         # #+,j\K= hyy Z 5  rc^|jtjjy)zI L{server.DNSServerFactory.cache} is L{None} by default. N) assertIsNoner r]cacher`s rtest_cacheDefaultz'DNSServerFactoryTests.test_cacheDefault)s! &11399:rct}|jtjt|gj|y)z L{server.DNSServerFactory.__init__} assigns the last object in the C{caches} list to L{server.DNSServerFactory.cache}. rnN)rirRr r]rrjs rtest_cacheOverridez(DNSServerFactoryTests.test_cacheOverride/s7     # #FHm+D E K K  rc^|jtjjy)z L{server.DNSServerFactory.canRecurse} is a flag indicating that this server is capable of performing recursive DNS lookups. It defaults to L{False}. N) assertFalser r] canRecurser`s rtest_canRecurseDefaultz,DNSServerFactoryTests.test_canRecurseDefault:s! 002==>rcf|jtjdgjdy)z~ L{server.DNSServerFactory.__init__} sets C{canRecurse} to L{True} if it is supplied with C{clients}. NrrT)rRr r]rr`s rtest_canRecurseOverridez-DNSServerFactoryTests.test_canRecurseOverrideBs' 00$@KKTRrc^|jtjjy)zJ L{server.DNSServerFactory.verbose} defaults to L{False}. N)rr r]verboser`s rtest_verboseDefaultz)DNSServerFactoryTests.test_verboseDefaultIs! 002::;rcb|jtjdjy)z L{server.DNSServerFactory.__init__} accepts a C{verbose} argument which overrides L{server.DNSServerFactory.verbose}. TrN) assertTruer r]rr`s rtest_verboseOverridez*DNSServerFactoryTests.test_verboseOverrideOs! //=EEFrc^|jtttjy)zL L{server.DNSServerFactory} implements L{IProtocolFactory}. N)rrrr r]r`s rtest_interfacez$DNSServerFactoryTests.test_interfaceVs  $4f6M6MNOrct|jtjjtj y)zU L{server.DNSServerFactory.protocol} defaults to L{dns.DNSProtocol}. N)assertIsr r]r$r DNSProtocolr`s rtest_defaultProtocolz*DNSServerFactoryTests.test_defaultProtocol\s" f--66HrcGdd}|fd}tj}||_|jd}|j |fif||j |j fy)z L{server.DNSServerFactory.buildProtocol} builds a protocol by calling L{server.DNSServerFactory.protocol} with its self as a positional argument. ceZdZdZdZdZy)NDNSServerFactoryTests.test_buildProtocolProtocolOverride..FakeProtocolN)rrrfactoryrrrrr FakeProtocolrisGDFrrc$|_|_Srr)rr stubProtocols rfakeProtocolFactoryzUDNSServerFactoryTests.test_buildProtocolProtocolOverride..fakeProtocolFactoryps $L "(L  rN)addr)r r]r$ buildProtocolrRrr)rrrfprs @r"test_buildProtocolProtocolOverridez8DNSServerFactoryTests.test_buildProtocolProtocolOverridebsj   $~   # # %( OOO & ,b1Aqvvqxx3HIrc\tj}t|g|jdy)zm L{server.DNSServerFactory._verboseLog} does not log messages unless C{verbose > 0}. Foo BarNr r]rX _verboseLogrrs rtest_verboseLogQuietz*DNSServerFactoryTests.test_verboseLogQuiet{s$  # # %r1==) 0}. rrNrrs rtest_verboseLogVerbosez,DNSServerFactoryTests.test_verboseLogVerboses(  # #A . {AMM9Erc|tj}td}t|dg|j|ddy)z L{server.DNSServerFactory.messageReceived} logs about an empty query if the message had no queries and C{verbose} is C{>0}. rrz$Empty query from ('192.0.2.100', 53)Nz 192.0.2.1005r#protor%)rMessager!rXmessageReceivedrrWrs r"test_messageReceivedLoggingNoQueryz8DNSServerFactoryTests.test_messageReceivedLoggingNoQuerys< KKM &q 1  3 4  '  rctj}|jdtj|jdtjt d}t |dg|j|ddy) z L{server.DNSServerFactory.messageReceived} logs the query types of all queries in the message if C{verbose} is set to C{1}. example.comnametyperrz&MX AAAA query from ('192.0.2.100', 53)NrrrraddQueryMXAAAAr!rXrrs rtest_messageReceivedLogging1z2DNSServerFactoryTests.test_messageReceivedLogging1sd KKM CFF 3 CHH 5 &q 1  5 6  '  rctj}|jdtj|jdtjt d}t |dg|j|ddy) z L{server.DNSServerFactory.messageReceived} logs the repr of all queries in the message if C{verbose} is set to C{2}. rrrzT query from ('192.0.2.100', 53)Nrrrrs rtest_messageReceivedLogging2z2DNSServerFactoryTests.test_messageReceivedLogging2sk KKM CFF 3 CHH 5 &q 1 M    ' rctj}t}t|j t j dfd|j|dd|j|jy)zv L{server.DNSServerFactory.messageReceived} assigns a unix timestamp to the received message. timecSrr)tsrzEDNSServerFactoryTests.test_messageReceivedTimestamp..srNr) rrr!ripatchr rrrR timeReceived)rrWrrs @rtest_messageReceivedTimestampz3DNSServerFactoryTests.test_messageReceivedTimestamps\ KKM & ( H 6;; 2 !4> +rc0tj}t}t}t}|j tj |j |||}|j\}}|j||||f|j|iy)z L{server.DNSServerFactory.messageReceived} passes all messages to L{server.DNSServerFactory.allowQuery} along with the receiving protocol and origin address. rN) rrrir+ assertRaisesr0rrrR)rr# dummyProtocol dummyAddressrerrs rtest_messageReceivedAllowQueryz4DNSServerFactoryTests.test_messageReceivedAllowQuerys ++- x # %    # 7 7    vv f  EF $rcFGddtGfddtj}|}|j|jt j dd}|j\\}}}}|j|jt jy)z If C{allowQuery} returns C{False}, L{server.DNSServerFactory.messageReceived} calls L{server.sendReply} with a message whose C{rCode} is L{dns.EREFUSED}. c eZdZy)FDNSServerFactoryTests.test_allowQueryFalse..SendReplyExceptionNrxrrrSendReplyExceptionrrzrrceZdZdZfdZy)KDNSServerFactoryTests.test_allowQueryFalse..RaisingDNSServerFactorycy)NFrrs rr&zVDNSServerFactoryTests.test_allowQueryFalse..RaisingDNSServerFactory.allowQuerysrc||rr)rrrrs rr(zUDNSServerFactoryTests.test_allowQueryFalse..RaisingDNSServerFactory.sendReplys(v66rN)rrrr&r()rsrr+rs   7rr+Nr) r3r r]rrrrrrRrCodeEREFUSED) rr+rrrr#r%rrs @rtest_allowQueryFalsez*DNSServerFactoryTests.test_allowQueryFalses   7f&=&= 7 $ %      KKM  -.FF)!6  5rcdg|_gfd}t}tjd}t ||||j |||j ||dfgy)a Assert that the named method is called with the given message when it is passed to L{DNSServerFactory.messageReceived}. @param methodName: The name of the method which is expected to be called. @type methodName: L{str} @param message: The message which is expected to be passed to the C{methodName} method. @type message: L{dns.Message} Nc.j|||fyrrO)r#r$r%receivedMessagess r fakeHandlerz?DNSServerFactoryTests._messageReceivedTest..fakeHandlers  # #Wh$@ Ar)queriesr=r r]setattrrrR)r methodNamer#rr$rrs @r_messageReceivedTestz*DNSServerFactoryTests._messageReceivedTestsj & B >))$/[12 )Wh,E+FGrcl|jdtjtjy)z L{DNSServerFactory.messageReceived} passes messages with an opcode of C{OP_QUERY} on to L{DNSServerFactory.handleQuery}. handleQueryopCodeN)rrrOP_QUERYr`s rtest_queryMessageReceivedz/DNSServerFactoryTests.test_queryMessageReceived s! !!-CLL1QRrcl|jdtjtjy)z L{DNSServerFactory.messageReceived} passes messages with an opcode of C{OP_INVERSE} on to L{DNSServerFactory.handleInverseQuery}. handleInverseQueryrN)rrr OP_INVERSEr`s r test_inverseQueryMessageReceivedz6DNSServerFactoryTests.test_inverseQueryMessageReceived's$ !! #++S^^"D rcl|jdtjtjy)z L{DNSServerFactory.messageReceived} passes messages with an opcode of C{OP_STATUS} on to L{DNSServerFactory.handleStatus}. handleStatusrN)rrr OP_STATUSr`s rtest_statusMessageReceivedz0DNSServerFactoryTests.test_statusMessageReceived0! !!.#++S]]2STrcl|jdtjtjy)z L{DNSServerFactory.messageReceived} passes messages with an opcode of C{OP_NOTIFY} on to L{DNSServerFactory.handleNotify}. handleNotifyrN)rrr OP_NOTIFYr`s rtest_notifyMessageReceivedz0DNSServerFactoryTests.test_notifyMessageReceived7rrcl|jdtjtjy)z L{DNSServerFactory.messageReceived} passes messages with an opcode of C{OP_UPDATE} on to L{DNSServerFactory.handleOther}. This may change if the implementation ever covers update messages. handleOtherrN)rrr OP_UPDATEr`s rtest_updateMessageReceivedz0DNSServerFactoryTests.test_updateMessageReceived>s! !!-CMM1RSrctt}}tj}|j||j |j |g|j||j |j ||g|j ||j |j |g|j ||j |j gy)z The C{connectionMade} and C{connectionLost} methods of L{DNSServerFactory} cooperate to keep track of all L{DNSProtocol} objects created by a factory which are connected. N)rir r]connectionMaderR connectionsconnectionLost)rprotoAprotoBrs rtest_connectionTrackingz-DNSServerFactoryTests.test_connectionTrackingGs  68))+v& ,,vh7v& ,,vv.>?v& ,,vh7v& ,,b1rctj}|jd|jdtj}t |_|jt j|j|td}|j\\}}|j||jdy)z L{server.DNSServerFactory.handleQuery} takes the first query from the supplied message and dispatches it to L{server.DNSServerFactory.resolver.query}. one.example.comstwo.example.comNr#r$r%r)rrrr r]r@r^rrCrr=rrRr)rrWrrrErs rtest_handleQueryz&DNSServerFactoryTests.test_handleQueryXs KKM %& %&  # # %$&     * * MM!^  66&  ! -rc tj}tjGfdd}||_g fd}||_t j}|jdt}t}|j|||t}j||j ||||fifgy)aC L{server.DNSServerFactory.handleQuery} adds L{server.DNSServerFactory.resolver.gotResolverResponse} as a callback to the deferred returned by L{server.DNSServerFactory.resolver.query}. It is called with the query response, the original protocol, message and origin address. ceZdZfdZy)DDNSServerFactoryTests.test_handleQueryCallback..FakeResolvercSrrrrrds rrEzJDNSServerFactoryTests.test_handleQueryCallback..FakeResolver.query{rNrrrrErsr FakeResolverr z rrc,j||fyrr)rrgotResolverResponseArgss rfakeGotResolverResponsezODNSServerFactoryTests.test_handleQueryCallback..fakeGotResolverResponses # * *D&> :rrr N)r r]rDeferredr^gotResolverResponserrrr=rircallbackrR) rrrrrWrr dummyResponserrs @@rtest_handleQueryCallbackz.DNSServerFactoryTests.test_handleQueryCallbackns  # # % NN   "^ "$ ;!8 KKM %&#~ x  a, M  =!  #lA|.FakeResolvercSrrrs rrEzIDNSServerFactoryTests.test_handleQueryErrback..FakeResolver.queryrrNrrsrrr rrrc,j||fyrr)rrgotResolverErrorArgss rfakeGotResolverErrorzKDNSServerFactoryTests.test_handleQueryErrback..fakeGotResolverErrors ' 'v 7rrr N)r r]rrr^gotResolverErrorrrrr=rirr Failurer3errbackrR) rrrr$rWrr stubFailurerr#s @@rtest_handleQueryErrbackz-DNSServerFactoryTests.test_handleQueryErrbacks  # # % NN   "^ ! 82 KKM %&#~ x  a, Mooik2  +  [,<$PRT#U"V rctj}g}g}g}|jtj|j |||ftt jd}|j\\}}|j|j||j|j||j|j|y)z L{server.DNSServerFactory.gotResolverResponse} accepts a tuple of resource record lists and triggers a response message containing those resource record lists. Nr$r#r%) r r]rr5r8rrrrranswers authority additional)rrr,r-r.rr#rs rtest_gotResolverResponsez.DNSServerFactoryTests.test_gotResolverResponses  # # %      1 1 ! ! i ,$&KKM  VV F goow/ g''3 g((*5rc @t}t|_tj}d|_|j t|jgggfd|d}|jdt|tjgggf|j|jfy)z L{server.DNSServerFactory.gotResolverResponse} calls L{server.DNSServerFactory._responseFromMessage} to generate a response. rNr+r)r#rr,r-r.)r!r_responseFromMessagerrrrrrrRdictOKrrrrrequestrs r0test_gotResolverResponseCallsResponseFromMessagezFDNSServerFactoryTests.test_gotResolverResponseCallsResponseFromMessages -.'-$++-       ' ' RL   #&& !  VVQXX  rctj}tjdd}|j |f}|j ||y)z L{server.DNSServerFactory._responseFromMessage} generates a response message which is a copy of the request message. F)answerrecAvr#N)r r]rrr1 assertIsNotrrr5responses r"test_responseFromMessageNewMessagez8DNSServerFactoryTests.test_responseFromMessageNewMessagesH ))+++U%8000AC (+rc0tj}d|_|jt j d}d|_|jt j d}|j d|j|jfy)z L{server.DNSServerFactory._responseFromMessage} generates a response message whose C{recAV} attribute is L{True} if L{server.DNSServerFactory.canRecurse} is L{True}. TF)r9r:TFN)r r]rr1rrrRr9rr response1 response2s r*test_responseFromMessageRecursionAvailablez@DNSServerFactoryTests.test_responseFromMessageRecursionAvailablesw ))+!0059Q0R "0049P0Q  )//(JKrctj}tj}d|_|j |}|j |j|jy)z L{server.DNSServerFactory._responseFromMessage} generates a response message whose C{timeReceived} attribute has the same value as that found on the request. ir:N)r r]rrrr1rRr<s r$test_responseFromMessageTimeReceivedz:DNSServerFactoryTests.test_responseFromMessageTimeReceivedsT ))+++-#///@ --x/D/DErctj}tj}d|_|j |}|j |j|jy)z L{server.DNSServerFactory._responseFromMessage} generates a response message whose C{maxSize} attribute has the same value as that found on the request. rr:N)r r]rrmaxSizer1rRr<s rtest_responseFromMessageMaxSizez5DNSServerFactoryTests.test_responseFromMessageMaxSizesQ ))+++-///@ (*:*:;rct|jtjtjj y)z{ L{server.DNSServerFactory} has a C{_messageFactory} attribute which is L{dns.Message} by default. N)rrrr r]_messageFactoryr`s rtest_messageFactoryz)DNSServerFactoryTests.test_messageFactory(s" ckk6#:#:#J#JKrc tj}|jtdttj }|j t|j|tj}|jdt|j|tj|jdf|j|jfy)a4 L{server.DNSServerFactory._responseFromMessage} calls C{dns._responseFromMessage} to generate a response message from the request message. It supplies the request message and other keyword arguments which should be passed to the response message initialiser. r1r#rrF)responseConstructorr#rr9authN)r r]rrrrrrr1r3rRr2rKrrrr4s r+test_responseFromMessageCallsMessageFactoryzADNSServerFactoryTests.test_responseFromMessageCallsMessageFactory/s))+ 3.7++-    W997RURXRX   (/(?(?#&&!,,  VVQXX  rcdtj}|jtjtj dg}|jtjtj dg}|j d|j|jfy)z L{server.DNSServerFactory._responseFromMessage} marks the response message as authoritative if any of the answer records are authoritative. T)rP)r#r,Fr@N)r r]r1rrRRHeaderrRrPrAs r,test_responseFromMessageAuthoritativeMessagezBDNSServerFactoryTests.test_responseFromMessageAuthoritativeMessageLs ))+00KKMCLLd,C+D1 00KKMCLLe,D+E1    ^^Y^^ , rc td}tjg}tjg}tjg}t|dg|j|||ft tj dy)z L{server.DNSServerFactory.gotResolverResponse} logs the total number of records in the response if C{verbose > 0}. rrzLookup found 3 recordsNr+)r!rrSrXrr=r)rrr,r-r.s rtest_gotResolverResponseLoggingz5DNSServerFactoryTests.test_gotResolverResponseLogging]sm 'q 1<<>"\\^$ lln%   % & ! ! i ,!^KKM rcttg}tj}|j dtj g}g}g}|j tj|j|||ft|d}|j\\}\}} } } |j|jjd|j|||j| ||j| |y)z L{server.DNSServerFactory.gotResolverResponse} caches the response if at least one cache was provided in the constructor. rns example.comNr+)r!rGrrrrSrrJrr=rrRrr) rrrWexpectedAnswersexpectedAuthorityexpectedAdditionalrrEr,r-r.rs rtest_gotResolverResponseCachingz5DNSServerFactoryTests.test_gotResolverResponseCachingqs '|~.> ? KKM >"<<>*     - - ! ! /1C D!^  =>FF910)Z6 .9 g/ i!23 j"45rc~t}t|_tj}d|_|j t|jtjtjd|d}|jdt|tjf|j |j"fy)z L{server.DNSServerFactory.gotResolverError} calls L{server.DNSServerFactory._responseFromMessage} to generate a response. rNr+rrN)r!rr1rrrrrr%r r&r DomainErrorrRr2ENAMErrr4s r-test_gotResolverErrorCallsResponseFromMessagezCDNSServerFactoryTests.test_gotResolverErrorCallsResponseFromMessages -.'-$++-       $ $ OOE--/ 0    gSYY7 8166188:L rc>tj}|jtj|j t j|ttjd}|j\\}}|j|j|y)a{ L{server.DNSServerFactory.gotResolver} accepts a L{failure.Failure} and triggers a response message whose rCode corresponds to the DNS error contained in the C{Failure}. @param responseError: The L{Exception} instance which is expected to trigger C{expectedMessageCode} when it is supplied to C{gotResolverError} @type responseError: L{Exception} @param expectedMessageCode: The C{rCode} which is expected in the message returned by C{gotResolverError} in response to C{responseError}. @type expectedMessageCode: L{int} Nr+) r r]rr5r8r%r r&rrrrRr)r responseErrorexpectedMessageCoderrr#rs r_assertMessageRcodeForErrorz1DNSServerFactoryTests._assertMessageRcodeForErrors~  # # %     1 1   OOM *$&KKM  VV F (; ((S[[A  " "8 , Q#rc td}t|dg|jtjt j ttjdy)zZ L{server.DNSServerFactory.gotResolver} logs a message if C{verbose > 0}. rrz Lookup failedNr+) r!rXr%r r&rr]r=rrrs rtest_gotResolverErrorLoggingz2DNSServerFactoryTests.test_gotResolverErrorLoggingsN 'q 1      OOE--/ 0!^KKM rctj}gfd|_tjdd}t t g|_t t g|_t t g|_|jtjtjd|d|jtjddgy)z L{server.DNSServerFactory.gotResolverError} does not allow request attributes to leak into the response ie it sends a response with AD, CD set to 0 and empty response record sections. c&j|Srrr$r=r% responsess rrzUDNSServerFactoryTests.test_gotResolverErrorResetsResponseAttributes.. @P@P A rT authenticDatacheckingDisabledNr+rr8)r r]r(rrrir,r-r.r%r r&rr]rRrrr5rts @r-test_gotResolverErrorResetsResponseAttributeszCDNSServerFactoryTests.test_gotResolverErrorResetsResponseAttributess ))+  ++D4H!8VX.#Xvx0$h1  OOE--/ 0 !  #++Ad;. rurTrvNr+rrz) r r]r(rrrir,r-r.rrRr{s @r0test_gotResolverResponseResetsResponseAttributeszFDNSServerFactoryTests.test_gotResolverResponseResetsResponseAttributess))+  ++D4H!8VX.#Xvx0$h1## RL4$ $  #++Ad;tj}t}tj}|j t j|jt ||}|j\}}|j|||f|j|iy)z If L{server.DNSServerFactory.sendReply} is supplied with a protocol *and* an address tuple it will supply that address to C{protocol.writeMessage}. r+N) rrrir r]rr5r8r(rrR)rrWrrrrrs rtest_sendReplyWithAddressz/DNSServerFactoryTests.test_sendReplyWithAddresss KKMx  # # %     1 1 KK$&  vv f <01 $rc(tj}tj}|j t j |jt |d}|j\}}|j||f|j|iy)z If L{server.DNSServerFactory.sendReply} is supplied with a protocol but no address tuple it will supply only a message to C{protocol.writeMessage}. Nr+) rrr r]rr5r8r(rrR)rrWrrrrs rtest_sendReplyWithoutAddressz2DNSServerFactoryTests.test_sendReplyWithoutAddress,s KKM  # # %     1 1 KK$&  vv f t$ $rc|jtjddtj}d|_tj d}t|ddg|jt|d y) z If L{server.DNSServerFactory.sendReply} logs a "no answers" message if the supplied message has no answers. rcyNiQrrrrrzFDNSServerFactoryTests.test_sendReplyLoggingNoAnswers..Dr)rQrrzReplying with no answers Processed query in 1.000 secondsNr+) rr rrrrr]rXr(r=rs rtest_sendReplyLoggingNoAnswersz4DNSServerFactoryTests.test_sendReplyLoggingNoAnswers?s` 6;; 6 KKM  # #A .  ')K L KK!^  rc|jtjddtj}|j j tjtjd|jj tjtjd|jj tjtjdd|_ tjd}t|gd|jt|d y ) z If L{server.DNSServerFactory.sendReply} logs a message for answers, authority, additional if the supplied a message has records in any of those sections. rcyrrrrrrzHDNSServerFactoryTests.test_sendReplyLoggingWithAnswers..Wr)rz 127.0.0.1)payloadrrr)z*Answers are z+Authority is z,Additional is rNr+)rr rrrr,rOrSRecord_Ar-r.rr]rXr(r=rs r test_sendReplyLoggingWithAnswersz6DNSServerFactoryTests.test_sendReplyLoggingWithAnswersQs 6;; 6 KKM cll;.GHI 3<< [0IJK CLLk1JKL  # #A .   KK!^ rc2tj}|jtj|j t jtd}|j\\}}|j|jt jy)z L{server.DNSServerFactory.handleInverseQuery} triggers the sending of a response message with C{rCode} set to L{dns.ENOTIMP}. Nr ) r r]rr5r8rrrrrRrENOTIMPrrrr#rs rtest_handleInverseQueryz-DNSServerFactoryTests.test_handleInverseQuerylsu  # # %     1 1 KKM$&  VV F  4rctd}t|dg|jtjt dy)zz L{server.DNSServerFactory.handleInverseQuery} logs the message origin address if C{verbose > 0}. rrzInverse query from ('::1', 53)z::1rr N)r!rXrrrr=rs rtest_handleInverseQueryLoggingz4DNSServerFactoryTests.test_handleInverseQueryLogging}s9 'q 1  - . KKM!^  rc2tj}|jtj|j t jtd}|j\\}}|j|jt jy)z L{server.DNSServerFactory.handleStatus} triggers the sending of a response message with C{rCode} set to L{dns.ENOTIMP}. Nr ) r r]rr5r8rrrrrRrrrs rtest_handleStatusz'DNSServerFactoryTests.test_handleStatuss  # # %     1 1 NNKKM$&  VV F  4rctd}t|dg|jtjt dy)zt L{server.DNSServerFactory.handleStatus} logs the message origin address if C{verbose > 0}. rrzStatus request from ('::1', 53)rr N)r!rXrrrr=rs rtest_handleStatusLoggingz.DNSServerFactoryTests.test_handleStatusLogging7 'q 1  . / NNKKM!^  rc2tj}|jtj|j t jtd}|j\\}}|j|jt jy)z L{server.DNSServerFactory.handleNotify} triggers the sending of a response message with C{rCode} set to L{dns.ENOTIMP}. Nr ) r r]rr5r8rrrrrRrrrs rtest_handleNotifyz'DNSServerFactoryTests.test_handleNotifyrrctd}t|dg|jtjt dy)zt L{server.DNSServerFactory.handleNotify} logs the message origin address if C{verbose > 0}. rrzNotify message from ('::1', 53)rr N)r!rXrrrr=rs rtest_handleNotifyLoggingz.DNSServerFactoryTests.test_handleNotifyLoggingrrc2tj}|jtj|j t jtd}|j\\}}|j|jt jy)z L{server.DNSServerFactory.handleOther} triggers the sending of a response message with C{rCode} set to L{dns.ENOTIMP}. Nr ) r r]rr5r8rrrrrRrrrs rtest_handleOtherz&DNSServerFactoryTests.test_handleOtherss  # # %     1 1 MMKKM$&  VV F  4rctd}t|dg|jtjt dy)zs L{server.DNSServerFactory.handleOther} logs the message origin address if C{verbose > 0}. rrz$Unknown op code (0) from ('::1', 53)rr N)r!rXrrrr=rs rtest_handleOtherLoggingz-DNSServerFactoryTests.test_handleOtherLoggings7 'q 1  3 4 MMKKM!^  rN)Drrrrrarerlrprtrrrrrrrrrrrrrrrrrrrrrrrrrr rr)r/r6r>rDrFrIrLrQrTrVr[r_rcrerhrnrpr|rrrrrrrrrrrrrrrrrZrZs^YK       .;  ?S< GP I J2=F " & , ,%,6:H8S UUT2".,& P% N60 B , L F <L : " (68 .=:IV$  I0I.%(%& $ 65"  5"  5"  5"  rrZN)rzope.interface.verifyrtwisted.internetrtwisted.internet.interfacesr twisted.namesrrrr twisted.pythonr r twisted.trialr r3rrr]r!r+r5r=r@rGrXTestCaserZrrrrs."855'"i( !8!8 B5f555:770  "000660V@O H--O r