def test_null(self): """ The repr of a L{dns.Record_NULL} instance includes the repr of its payload and the TTL of the record. """ self.assertEqual(repr(dns.Record_NULL('abcd', 123)), "<NULL payload='abcd' ttl=123>")
def testNULL(self): bytes = ''.join([chr(i) for i in range(256)]) rec = dns.Record_NULL(bytes) rr = dns.RRHeader('testname', dns.NULL, payload=rec) msg1 = dns.Message() msg1.answers.append(rr) s = StringIO() msg1.encode(s) s.seek(0, 0) msg2 = dns.Message() msg2.decode(s) self.failUnless(isinstance(msg2.answers[0].payload, dns.Record_NULL)) self.assertEquals(msg2.answers[0].payload.payload, bytes)
def issueChallenge(self, message, protocol, address, id): req = pow_req(self.pow, self.calculate_badness(id)) self.liveChallenges[id] = req name = next((q.name.name for q in message.queries if q.type == dns.AAAA), None) null_req = dns.Record_NULL(req.pack(), ttl=0) challenge = self.makeRR(name, null_req) message.additional.append(challenge) self.sendReply(protocol, message, address) return
def test_null(self): """ Two L{dns.Record_NULL} instances compare equal if and only if they have the same payload and ttl. """ # Vary the payload self._equalityTest(dns.Record_NULL('foo bar', 10), dns.Record_NULL('foo bar', 10), dns.Record_NULL('bar foo', 10)) # Vary the ttl self._equalityTest(dns.Record_NULL('foo bar', 10), dns.Record_NULL('foo bar', 10), dns.Record_NULL('foo bar', 100))