コード例 #1
0
    def test_get_name_server_ip_address_helper_no_type_match(self):
        """
        Test case to retrieve the ip address for a name server for which there is an additional record whose
        name is the name server name, but is of the incorrect type.
        """

        name_server_record: ResourceRecord = ResourceRecord(
            "ca", 2, 1, 172800, 8, "y.ubc.ca")

        name_server_ip: Optional[
            str] = DNSMessage.get_name_server_ip_address_helper(
                name_server_record, self.additional_records)

        self.assertEqual(name_server_ip, None)
コード例 #2
0
    def test_get_name_server_ip_address_helper_only_one_match(self):
        """
        Test case to retrieve the ip address of a name server for which there is a match of the correct type
        and there is only one match in the additional records.
        """

        name_server_record: ResourceRecord = ResourceRecord(
            "ca", 2, 1, 172800, 8, "x.ubc.ca")

        name_server_ip: Optional[
            str] = DNSMessage.get_name_server_ip_address_helper(
                name_server_record, self.additional_records)

        self.assertEqual(name_server_ip, "1.2.3.4")
コード例 #3
0
    def test_get_name_server_ip_address_helper_no_additional_records(self):
        """
        Test case to retrieve the ip address for a name server for which there is additional record whose
        name matches the name server name.
        """

        name_server_record: ResourceRecord = ResourceRecord(
            "ca", 2, 1, 172800, 8, "no-match")

        name_server_ip: Optional[
            str] = DNSMessage.get_name_server_ip_address_helper(
                name_server_record, [])

        self.assertEqual(name_server_ip, None)
コード例 #4
0
    def test_get_name_server_ip_address_helper_multiple_matches(self):
        """
        Test case to retrieve the ip address of a name server for which there is a match of the correct type
        and there are multiple matching records in the additional records. The first match's ip address should be
        returned.
        """

        name_server_record: ResourceRecord = ResourceRecord(
            "ca", 2, 1, 172800, 8, "z.ubc.ca")

        name_server_ip: Optional[
            str] = DNSMessage.get_name_server_ip_address_helper(
                name_server_record, self.additional_records)

        self.assertEqual(name_server_ip, "3.4.5.6")