コード例 #1
0
    def test_attempt_to_retrieve_all_flags(self):
        """
        Test case to retrieve all the flag values from a hypothetical flags value for a dns message.
        """

        get_response_value: bool = DNSMessage._get_response_value_from_flags(
            46218)
        get_opcode_value: int = DNSMessage._get_opcode_value_from_flags(46218)
        get_authoritative_value: bool = DNSMessage._get_authoritative_value_from_flags(
            46218)
        get_is_truncated_value: bool = DNSMessage._get_is_truncated_value_from_flags(
            46218)
        get_recursion_desired_value: bool = DNSMessage._get_recursion_desired_value_from_flags(
            46218)
        get_recursion_available_value: bool = DNSMessage._get_recursion_available_value_from_flags(
            46218)
        get_rcode_value: int = DNSMessage._get_rcode_value_from_flags(46218)

        self.assertEqual(get_response_value, True)
        self.assertEqual(get_opcode_value, 6)
        self.assertEqual(get_authoritative_value, True)
        self.assertEqual(get_is_truncated_value, False)
        self.assertEqual(get_recursion_desired_value, False)
        self.assertEqual(get_recursion_available_value, True)
        self.assertEqual(get_rcode_value, 10)
コード例 #2
0
    def test_get_opcode_value_from_flags_zero(self):
        """
        Test case to retrieve the opcode field when set to zero in the flags.
        """
        # flags = 0 has opcode = 0
        get_opcode_value_small: int = DNSMessage._get_opcode_value_from_flags(
            0)

        self.assertEqual(get_opcode_value_small, 0)
コード例 #3
0
    def test_get_opcode_value_from_flags_large(self):
        """
        Test case to retrieve the opcode field when set to a large value in the flags.
        """
        # flags = 30720 has opcode = 15
        get_opcode_value_large: int = DNSMessage._get_opcode_value_from_flags(
            30720)

        self.assertEqual(get_opcode_value_large, 15)