def test_decode_resource_record(self): """ Test case to decode a resource record. """ resource_record: ResourceRecord = ResourceRecord.decode_resource_record(BytesIO(self.resource_record_encoded), BytesIO(self.resource_record_encoded)) self.assertEqual(resource_record.name, 'ca') self.assertEqual(resource_record.type, self.ns_type) self.assertEqual(resource_record.response_class, 1) self.assertEqual(resource_record.ttl, 150873) self.assertEqual(resource_record.rdlength, 14) self.assertEqual(resource_record.rdata, 'x.ca-servers')
def _read_resource_records(data: BytesIO, copy_of_message: BytesIO, num_of_records: int) -> List[ResourceRecord]: """ Read the resource records from the remaining dns message data. :param data: the remaining data of the dns message to be processed :param copy_of_message: a copy of the entire dns message, used for handling pointers in domain names :param num_of_records: number of records to decode :return: list of the resource records decoded """ list_of_records = [] for _ in range(num_of_records): list_of_records.append( ResourceRecord.decode_resource_record(data, copy_of_message)) return list_of_records