text: from unittest.mock import Mock
  import unittest
  from dns_shark.resolver_core import ResolverCore
  from dns_shark.resource_record import ResourceRecord
  from typing import List
  
  
  class CnameAndNameServerResolutionIpv6Test(unittest.TestCase):
      """
      Unit testing for resolver_core.
      """
  
      @classmethod
      def setUpClass(cls):
          """
          Initialize test values used in the tests.
          """
  
          cls.first_response: bytes = bytes.fromhex('5543800000010000000400080766696e616e636506676f6f676c6502636100001c0001c01b000200010002a300000f01630a63612d73657276657273c01bc01b000200010002a3000004016ac031c01b000200010002a30000040178c031c01b000200010002a300000603616e79c031c02f000100010002a3000004b99fc402c04a000100010002a3000004c6b6a701c05a000100010002a3000004c7fdfa44c06a000100010002a3000004c7049002c02f001c00010002a30000102620010a805300000000000000000002c04a001c00010002a300001020010500008300000000000000000001c05a001c00010002a30000102620010a80ba00000000000000000068c06a001c00010002a30000102001050000a700000000000000000002')
  
          cls.second_response: bytes = bytes.fromhex('3acc800000010000000400000766696e616e636506676f6f676c6502636100001c0001c01400020001000151800010036e733106676f6f676c6503636f6d00c02300020001000151800006036e7332c033c02300020001000151800006036e7333c033c02300020001000151800006036e7334c033')
  
          cls.third_response: bytes = bytes.fromhex('03dd800000010000000d000e036e733106676f6f676c6503636f6d0000010001c017000200010002a300001401610c67746c642d73657276657273036e657400c017000200010002a30000040162c02ec017000200010002a30000040163c02ec017000200010002a30000040164c02ec017000200010002a30000040165c02ec017000200010002a30000040166c02ec017000200010002a30000040167c02ec017000200010002a30000040168c02ec017000200010002a30000040169c02ec017000200010002a3000004016ac02ec017000200010002a3000004016bc02ec017000200010002a3000004016cc02ec017000200010002a3000004016dc02ec02c000100010002a3000004c005061ec04c000100010002a3000004c0210e1ec05c000100010002a3000004c01a5c1ec06c000100010002a3000004c01f501ec07c000100010002a3000004c00c5e1ec08c000100010002a3000004c023331ec09c000100010002a3000004c02a5d1ec0ac000100010002a3000004c036701ec0bc000100010002a3000004c02bac1ec0cc000100010002a3000004c0304f1ec0dc000100010002a3000004c034b21ec0ec000100010002a3000004c029a21ec0fc000100010002a3000004c037531ec02c001c00010002a300001020010503a83e00000000000000020030')
  
          cls.fourth_response: bytes = bytes.fromhex('721d80000001000000040008036e733106676f6f676c6503636f6d0000010001c010000200010002a3000006036e7332c010c010000200010002a3000002c00cc010000200010002a3000006036e7333c010c010000200010002a3000006036e7334c010c02c001c00010002a30000102001486048020034000000000000000ac02c000100010002a3000004d8ef220ac00c001c00010002a30000102001486048020032000000000000000ac00c000100010002a3000004d8ef200ac04c001c00010002a30000102001486048020036000000000000000ac04c000100010002a3000004d8ef240ac05e001c00010002a30000102001486048020038000000000000000ac05e000100010002a3000004d8ef260a')
  
          cls.fifth_response: bytes = bytes.fromhex('119e84000001000100000000036e733106676f6f676c6503636f6d0000010001c00c00010001000546000004d8ef200a')
  
          cls.sixth_response: bytes = bytes.fromhex('e847840000010003000000000766696e616e636506676f6f676c6502636100001c0001c00c000500010005460000140766696e616e636506676f6f676c6503636f6d00c02f0005000100093a8000090477777733016cc037c04f001c00010000012c00102607f8b0400a0800000000000000200e')
  
          cls.seventh_response: bytes = bytes.fromhex('0304800000010000000d000e0766696e616e636506676f6f676c6503636f6d00001c0001c01b000200010002a300001401610c67746c642d73657276657273036e657400c01b000200010002a30000040162c032c01b000200010002a30000040163c032c01b000200010002a30000040164c032c01b000200010002a30000040165c032c01b000200010002a30000040166c032c01b000200010002a30000040167c032c01b000200010002a30000040168c032c01b000200010002a30000040169c032c01b000200010002a3000004016ac032c01b000200010002a3000004016bc032c01b000200010002a3000004016cc032c01b000200010002a3000004016dc032c030000100010002a3000004c005061ec050000100010002a3000004c0210e1ec060000100010002a3000004c01a5c1ec070000100010002a3000004c01f501ec080000100010002a3000004c00c5e1ec090000100010002a3000004c023331ec0a0000100010002a3000004c02a5d1ec0b0000100010002a3000004c036701ec0c0000100010002a3000004c02bac1ec0d0000100010002a3000004c0304f1ec0e0000100010002a3000004c034b21ec0f0000100010002a3000004c029a21ec100000100010002a3000004c037531ec030001c00010002a300001020010503a83e00000000000000020030')
  
          cls.eighth_response: bytes = bytes.fromhex('0566800000010000000400080766696e616e636506676f6f676c6503636f6d00001c0001c014000200010002a3000006036e7332c014c014000200010002a3000006036e7331c014c014000200010002a3000006036e7333c014c014000200010002a3000006036e7334c014c030001c00010002a30000102001486048020034000000000000000ac030000100010002a3000004d8ef220ac042001c00010002a30000102001486048020032000000000000000ac042000100010002a3000004d8ef200ac054001c00010002a30000102001486048020036000000000000000ac054000100010002a3000004d8ef240ac066001c00010002a30000102001486048020038000000000000000ac066000100010002a3000004d8ef260a')
  
          cls.ninth_response: bytes = bytes.fromhex('59bf840000010002000000000766696e616e636506676f6f676c6503636f6d00001c0001c00c0005000100093a8000090477777733016cc014c030001c00010000012c00102607f8b0400a0800000000000000200e')
  
          cls.tenth_response: bytes = bytes.fromhex('55e2800000010000000d000e0477777733016c06676f6f676c6503636f6d00001c0001c01a000200010002a300001401610c67746c642d73657276657273036e657400c01a000200010002a30000040162c031c01a000200010002a30000040163c031c01a000200010002a30000040164c031c01a000200010002a30000040165c031c01a000200010002a30000040166c031c01a000200010002a30000040167c031c01a000200010002a30000040168c031c01a000200010002a30000040169c031c01a000200010002a3000004016ac031c01a000200010002a3000004016bc031c01a000200010002a3000004016cc031c01a000200010002a3000004016dc031c02f000100010002a3000004c005061ec04f000100010002a3000004c0210e1ec05f000100010002a3000004c01a5c1ec06f000100010002a3000004c01f501ec07f000100010002a3000004c00c5e1ec08f000100010002a3000004c023331ec09f000100010002a3000004c02a5d1ec0af000100010002a3000004c036701ec0bf000100010002a3000004c02bac1ec0cf000100010002a3000004c0304f1ec0df000100010002a3000004c034b21ec0ef000100010002a3000004c029a21ec0ff000100010002a3000004c037531ec02f001c00010002a300001020010503a83e00000000000000020030')
  
          cls.eleventh_response: bytes = bytes.fromhex('b650800000010000000400080477777733016c06676f6f676c6503636f6d00001c0001c013000200010002a3000006036e7332c013c013000200010002a3000006036e7331c013c013000200010002a3000006036e7333c013c013000200010002a3000006036e7334c013c02f001c00010002a30000102001486048020034000000000000000ac02f000100010002a3000004d8ef220ac041001c00010002a30000102001486048020032000000000000000ac041000100010002a3000004d8ef200ac053001c00010002a30000102001486048020036000000000000000ac053000100010002a3000004d8ef240ac065001c00010002a30000102001486048020038000000000000000ac065000100010002a3000004d8ef260a')
  
          cls.authoritative_response: bytes = bytes.fromhex('5523840000010001000000000477777733016c06676f6f676c6503636f6d00001c0001c00c001c00010000012c00102607f8b0400a0800000000000000200e')
  
          cls.mock_socket: Mock = Mock(**{'recv.side_effect': [cls.first_response,
                                                               cls.second_response,
                                                               cls.third_response,
                                                               cls.fourth_response,
                                                               cls.fifth_response,
                                                               cls.sixth_response,
                                                               cls.seventh_response,
                                                               cls.eighth_response,
                                                               cls.ninth_response,
                                                               cls.tenth_response,
                                                               cls.eleventh_response,
                                                               cls.authoritative_response]})
  
          cls.mock_random: Mock = Mock(**{'randint.side_effect': [0x5543, 0x3acc, 0x03dd, 0x721d, 0x119e, 0xe847, 0x0304,
                                                                  0x0566, 0x59bf, 0x55e2, 0xb650, 0x5523]})
  
      def test_cname_and_name_resolution_ipv6(self):
          """
          Test case for when two different cname resolutions and one name server resolution
          needs to be performed before finding an authoritative response. Searching for an ipv6 address.
          """
  
          resolver: ResolverCore = ResolverCore(self.mock_socket, False, "1.2.3.4", self.mock_random)
  
          answers: List[ResourceRecord] = resolver.resolve_domain_name("finance.google.ca", "1.2.3.4", 28)
          expected_answer: List[ResourceRecord] = [ResourceRecord('www3.l.google.com', 28, 1, 300, 16, '2607:f8b0:400a:800::200e')]
  
          self.assertEqual(answers, expected_answer)
  
  