Ejemplo n.º 1
0
	def testSameName(self):
		name = "paired.local."
		generated = r.DNSOutgoing(r._FLAGS_QR_RESPONSE)
		question = r.DNSQuestion(name, r._TYPE_SRV, r._CLASS_IN)
		generated.addQuestion(question)
		generated.addQuestion(question)
		parsed = r.DNSIncoming(generated.packet())
Ejemplo n.º 2
0
	def testMatchQuestion(self):
		generated = r.DNSOutgoing(r._FLAGS_QR_QUERY)
		question = r.DNSQuestion("testname.local.", r._TYPE_SRV, r._CLASS_IN)
		generated.addQuestion(question)
		parsed = r.DNSIncoming(generated.packet())
		self.assertEqual(len(generated.questions), 1)
		self.assertEqual(len(generated.questions), len(parsed.questions))
		self.assertEqual(question, parsed.questions[0])
Ejemplo n.º 3
0
	def testNumbersQuestions(self):
		generated = r.DNSOutgoing(r._FLAGS_QR_RESPONSE)
		question = r.DNSQuestion("testname.local.", r._TYPE_SRV, r._CLASS_IN)
		for i in range(0, 10):
			generated.addQuestion(question)
		bytes = generated.packet()
		numQuestions = ord(bytes[4]) << 8 | ord(bytes[5])
		numAnswers = ord(bytes[6]) << 8 | ord(bytes[7])
		numAuthorities = ord(bytes[8]) << 8 | ord(bytes[9])
		numAddtionals = ord(bytes[10]) << 8 | ord(bytes[11])
		self.assertEqual(numQuestions, 10)
		self.assertEqual(numAnswers, 0)
		self.assertEqual(numAuthorities, 0)
		self.assertEqual(numAddtionals, 0)
Ejemplo n.º 4
0
	def testParseOwnPacketQuestion(self):
		generated = r.DNSOutgoing(r._FLAGS_QR_QUERY)
		generated.addQuestion(r.DNSQuestion("testname.local.", r._TYPE_SRV, r._CLASS_IN))
		parsed = r.DNSIncoming(generated.packet())
Ejemplo n.º 5
0
	def testExceedinglyLongNamePart(self):
		name = "%s.local." % ("a" * 1000)
		generated = r.DNSOutgoing(r._FLAGS_QR_RESPONSE)
		question = r.DNSQuestion(name, r._TYPE_SRV, r._CLASS_IN)
		generated.addQuestion(question)
		self.assertRaises(r.NamePartTooLongException, generated.packet)
Ejemplo n.º 6
0
	def testExceedinglyLongName(self):
		generated = r.DNSOutgoing(r._FLAGS_QR_RESPONSE)
		name = "%slocal." % ("part." * 1000)
		question = r.DNSQuestion(name, r._TYPE_SRV, r._CLASS_IN)
		generated.addQuestion(question)
		parsed = r.DNSIncoming(generated.packet())
Ejemplo n.º 7
0
	def testLongName(self):
		generated = r.DNSOutgoing(r._FLAGS_QR_RESPONSE)
		question = r.DNSQuestion("this.is.a.very.long.name.with.lots.of.parts.in.it.local.", r._TYPE_SRV, r._CLASS_IN)
		generated.addQuestion(question)
		parsed = r.DNSIncoming(generated.packet())