def test_01_manage_multiple_messages(self): asyncio.get_event_loop().run_until_complete( utils.run_wait_close_multiple(self.manager.manage_message, self.manager, '10.10.10.10', self.msgs)) expected_file = Path(self.base_data_dir, 'Encoded', 'TCAP_MAP', 'Primary_00000001.TCAPMAP') self.assertBinaryFileContentsEqual( expected_file, binascii.unhexlify(self.multiple_encoded_hex[0])) expected_file = Path(self.base_data_dir, 'Encoded', 'TCAP_MAP', 'Primary_840001ff.TCAPMAP') self.assertBinaryFileContentsEqual( expected_file, binascii.unhexlify(self.multiple_encoded_hex[1])) expected_file = Path(self.base_data_dir, 'Encoded', 'TCAP_MAP', 'Primary_a5050001.TCAPMAP') self.assertBinaryFileContentsEqual( expected_file, binascii.unhexlify(self.multiple_encoded_hex[2])) expected_file = Path(self.base_data_dir, 'Encoded', 'TCAP_MAP', 'Primary_00000000.TCAPMAP') self.assertBinaryFileContentsEqual( expected_file, binascii.unhexlify(self.multiple_encoded_hex[3])) self.assertNumberOfFilesInDirectory( Path(self.base_data_dir, 'Decoded', 'TCAP_MAP'), 4) self.assertNumberOfFilesInDirectory( Path(self.base_data_dir, 'Prettified', 'TCAP_MAP'), 4) expected_file = Path(self.base_data_dir, 'Summaries', "Summary_%s.csv" % utils.current_date()) self.assertTrue(expected_file.exists()) self.assertNumLinesInFile(expected_file, 4)
def test_02_play_recording(self): recording = os.path.join(definitions.TESTS_DIR, 'recordings', 'tcprecord.mmr') asyncio.run(tasks.play_recording(self.client, recording)) time.sleep(3) expected_file = os.path.join(self.base_data_dir, 'Encoded', 'TCAP_MAP', 'localhost_00000001.TCAPMAP') self.assertBinaryFileContentsEqual( expected_file, b'bGH\x04\x00\x00\x00\x01k\x1e(\x1c\x06\x07\x00\x11\x86\x05\x01\x01\x01\xa0\x11`\x0f\x80\x02\x07\x80\xa1\t\x06\x07\x04\x00\x00\x01\x00\x14\x02l\x1f\xa1\x1d\x02\x01\xff\x02\x01-0\x15\x80\x07\x91\x14\x97Bu3\xf3\x81\x01\x00\x82\x07\x91\x14\x97yy\x08\xf0' ) expected_file = os.path.join(self.base_data_dir, 'Decoded', 'TCAP_MAP', 'localhost_00000001.txt') self.assertFileContentsEqual( expected_file, "('begin',\n {'components': [('basicROS',\n ('invoke',\n {'argument': ('RoutingInfoForSM-Arg',\n {'msisdn': b'\\x91\\x14\\x97Bu3\\xf3',\n 'serviceCentreAddress': b'\\x91\\x14\\x97y'\n b'y\\x08\\xf0',\n 'sm-RP-PRI': False}),\n 'invokeId': ('present', -1),\n 'opcode': ('local', 45)}))],\n 'dialoguePortion': {'direct-reference': (0, 0, 17, 773, 1, 1, 1),\n 'encoding': ('single-ASN1-type',\n ('DialoguePDU',\n ('dialogueRequest',\n {'application-context-name': (0,\n 4,\n 0,\n 0,\n 1,\n 0,\n 20,\n 2),\n 'protocol-version': (1, 1)})))},\n 'otid': b'\\x00\\x00\\x00\\x01'})" ) expected_file = os.path.join(self.base_data_dir, 'Summaries', "Summary_%s.csv" % utils.current_date()) self.assertPathExists(expected_file) expected_file = os.path.join(self.base_data_dir, 'Prettified', 'TCAP_MAP', 'localhost_00000001.txt') self.assertPathExists(expected_file) expected_file = os.path.join(definitions.TESTS_DIR, 'recordings', 'testrecord.mmr') self.assertPathExists(expected_file)
def test_06_do(self): self.action.do(self.msg) expected_file = Path(self.base_data_dir, 'Summaries', "Summary_%s.csv" % utils.current_date()) self.assertFileContentsEqual( expected_file, """2018-09-15 11:09:31.033925 1234 Modify 2018-09-15 11:09:42.641033 2222 Add 2018-09-15 11:09:58.782290 173 Delete """)
def test_07_do_many(self): self.action.do_multiple(self.msgs) expected_file = Path(self.base_data_dir, 'Summaries', "Summary_%s.csv" % utils.current_date()) self.assertFileContentsEqual( expected_file, """begin 00000001 2018-01-01 01:01:00 continue 840001ff 2018-01-01 01:01:00 continue a5050001 2018-01-01 01:01:00 end 00000000 2018-01-01 01:01:00 """)
def test_07_do_many(self): self.action.do_multiple(self.msgs) expected_file = Path(self.base_data_dir, 'Summaries', "Summary_%s.csv" % utils.current_date()) self.assertFileContentsEqual( expected_file, """2018-09-15 11:09:31.033925 1234 Modify 2018-09-15 11:09:42.641033 2222 Add 2018-09-15 11:09:58.782290 173 Delete 2018-09-15 11:09:35.033925 7777 Modify 2018-09-15 11:09:52.641033 7778 Add 2018-09-15 11:09:59.782290 7779 Delete """)
def test_00_manage_message(self): asyncio.run(self.run_and_add_item_to_queue(), debug=True) expected_file = Path(self.base_data_dir, 'Encoded', 'TCAP_MAP', 'Primary_00000001.TCAPMAP') self.assertBinaryFileContentsEqual(expected_file, b'bGH\x04\x00\x00\x00\x01k\x1e(\x1c\x06\x07\x00\x11\x86\x05\x01\x01\x01\xa0\x11`\x0f\x80\x02\x07\x80\xa1\t\x06\x07\x04\x00\x00\x01\x00\x14\x02l\x1f\xa1\x1d\x02\x01\xff\x02\x01-0\x15\x80\x07\x91\x14\x97Bu3\xf3\x81\x01\x00\x82\x07\x91\x14\x97yy\x08\xf0') expected_file = Path(self.base_data_dir, 'Decoded', 'TCAP_MAP', 'Primary_00000001.txt') self.assertFileContentsEqual(expected_file, "('begin',\n {'components': [('basicROS',\n ('invoke',\n {'argument': ('RoutingInfoForSM-Arg',\n {'msisdn': b'\\x91\\x14\\x97Bu3\\xf3',\n 'serviceCentreAddress': b'\\x91\\x14\\x97y'\n b'y\\x08\\xf0',\n 'sm-RP-PRI': False}),\n 'invokeId': ('present', -1),\n 'opcode': ('local', 45)}))],\n 'dialoguePortion': {'direct-reference': (0, 0, 17, 773, 1, 1, 1),\n 'encoding': ('single-ASN1-type',\n ('DialoguePDU',\n ('dialogueRequest',\n {'application-context-name': (0,\n 4,\n 0,\n 0,\n 1,\n 0,\n 20,\n 2),\n 'protocol-version': (1, 1)})))},\n 'otid': b'\\x00\\x00\\x00\\x01'})") expected_file = Path(self.base_data_dir, 'Summaries', "Summary_%s.csv" % utils.current_date()) self.assertTrue(expected_file.exists()) expected_file = Path(self.base_data_dir, 'Prettified', 'TCAP_MAP', 'Primary_00000001.txt') self.assertTrue(expected_file.exists())
def test_00_manage_multiple_messages(self): self.loop.run_until_complete( utils.run_wait_close_multiple(self.manager.manage_message, self.manager, '10.10.10.10', self.msgs)) expected_file = os.path.join(self.base_data_dir, 'Encoded', 'Primary_TCAP_MAP.TCAPMAPMULTI') self.assertBinaryFileContentsEqual( expected_file, b"I\x00\x00\x00bGH\x04\x00\x00\x00\x01k\x1e(\x1c\x06\x07\x00\x11\x86\x05\x01\x01\x01\xa0\x11`\x0f\x80\x02\x07\x80\xa1\t\x06\x07\x04\x00\x00\x01\x00\x14\x02l\x1f\xa1\x1d\x02\x01\xff\x02\x01-0\x15\x80\x07\x91\x14\x97Bu3\xf3\x81\x01\x00\x82\x07\x91\x14\x97yy\x08\xf0\xad\x00\x00\x00e\x81\xaaH\x04\x84\x00\x01\xffI\x04\xa5\x05\x00\x01k*((\x06\x07\x00\x11\x86\x05\x01\x01\x01\xa0\x1da\x1b\x80\x02\x07\x80\xa1\t\x06\x07\x04\x00\x00\x01\x00\x0e\x03\xa2\x03\x02\x01\x00\xa3\x05\xa1\x03\x02\x01\x00l\x80\xa2l\x02\x01\x010g\x02\x018\xa3\x80\xa1\x800Z\x04\x10K\x9da\x91\x10u6e\x8c\xfeY\x88\x0c\xd2\xac'\x04\x10K\x8cC\xa2T P\x12\x04g\xf33\xc0\x0fB\xd8\x04\x10\x8cC\xa2T P\x12\x04g\xf33\xc0\x0fB\xd8K\x04\x10C\xa2T P\x12\x04g\xf33\xc0\x0fB\xd8K\x8c\x04\x10\xa2U\x1a\x05\x8c\xdb\x00\x00K\x8dy\xf7\xca\xffP\x12\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00e\x16H\x04\xa5\x05\x00\x01I\x04\x84\x00\x01\xffl\x08\xa1\x06\x02\x01\x02\x02\x018>\x00\x00\x00d<I\x04W\x18\x00\x00k*((\x06\x07\x00\x11\x86\x05\x01\x01\x01\xa0\x1da\x1b\x80\x02\x07\x80\xa1\t\x06\x07\x04\x00\x00\x01\x00\x05\x03\xa2\x03\x02\x01\x00\xa3\x05\xa1\x03\x02\x01\x00l\x08\xa3\x06\x02\x01\x01\x02\x01\x0b" ) msgs = self.protocol.from_file_multi(self.sender, expected_file) self.assertSequenceEqual( self.multiple_encoded_hex, [binascii.hexlify(msg.encoded) for msg in msgs]) expected_file = os.path.join(self.base_data_dir, 'Decoded', 'Primary_TCAP_MAP.txt') self.assertFileContentsEqual( expected_file, '(\'begin\',\n {\'components\': [(\'basicROS\',\n (\'invoke\',\n {\'argument\': (\'RoutingInfoForSM-Arg\',\n {\'msisdn\': b\'\\x91\\x14\\x97Bu3\\xf3\',\n \'serviceCentreAddress\': b\'\\x91\\x14\\x97y\'\n b\'y\\x08\\xf0\',\n \'sm-RP-PRI\': False}),\n \'invokeId\': (\'present\', -1),\n \'opcode\': (\'local\', 45)}))],\n \'dialoguePortion\': {\'direct-reference\': (0, 0, 17, 773, 1, 1, 1),\n \'encoding\': (\'single-ASN1-type\',\n (\'DialoguePDU\',\n (\'dialogueRequest\',\n {\'application-context-name\': (0,\n 4,\n 0,\n 0,\n 1,\n 0,\n 20,\n 2),\n \'protocol-version\': (1, 1)})))},\n \'otid\': b\'\\x00\\x00\\x00\\x01\'})\n\n(\'continue\',\n {\'components\': [(\'basicROS\',\n (\'returnResult\',\n {\'invokeId\': (\'present\', 1),\n \'result\': {\'opcode\': (\'local\', 56),\n \'result\': (\'SendAuthenticationInfoRes\',\n {\'authenticationSetList\': (\'quintupletList\',\n [{\'autn\': b\'\\xa2U\\x1a\\x05\'\n b\'\\x8c\\xdb\\x00\\x00\'\n b\'K\\x8dy\\xf7\'\n b\'\\xca\\xffP\\x12\',\n \'ck\': b\'\\x8cC\\xa2T\'\n b\' P\\x12\\x04\'\n b\'g\\xf33\\xc0\'\n b\'\\x0fB\\xd8K\',\n \'ik\': b\'C\\xa2T \'\n b\'P\\x12\\x04g\'\n b\'\\xf33\\xc0\\x0f\'\n b\'B\\xd8K\\x8c\',\n \'rand\': b\'K\\x9da\\x91\'\n b\'\\x10u6e\'\n b\'\\x8c\\xfeY\\x88\'\n b"\\x0c\\xd2\\xac\'",\n \'xres\': b\'K\\x8cC\\xa2\'\n b\'T P\\x12\'\n b\'\\x04g\\xf33\'\n b\'\\xc0\\x0fB\\xd8\'}])})}}))],\n \'dialoguePortion\': {\'direct-reference\': (0, 0, 17, 773, 1, 1, 1),\n \'encoding\': (\'single-ASN1-type\',\n (\'DialoguePDU\',\n (\'dialogueResponse\',\n {\'application-context-name\': (0,\n 4,\n 0,\n 0,\n 1,\n 0,\n 14,\n 3),\n \'protocol-version\': (1, 1),\n \'result\': 0,\n \'result-source-diagnostic\': (\'dialogue-service-user\',\n 0)})))},\n \'dtid\': b\'\\xa5\\x05\\x00\\x01\',\n \'otid\': b\'\\x84\\x00\\x01\\xff\'})\n\n(\'continue\',\n {\'components\': [(\'basicROS\',\n (\'invoke\',\n {\'invokeId\': (\'present\', 2), \'opcode\': (\'local\', 56)}))],\n \'dtid\': b\'\\x84\\x00\\x01\\xff\',\n \'otid\': b\'\\xa5\\x05\\x00\\x01\'})\n\n(\'end\',\n {\'components\': [(\'basicROS\',\n (\'returnError\',\n {\'errcode\': (\'local\', 11), \'invokeId\': (\'present\', 1)}))],\n \'dialoguePortion\': {\'direct-reference\': (0, 0, 17, 773, 1, 1, 1),\n \'encoding\': (\'single-ASN1-type\',\n (\'DialoguePDU\',\n (\'dialogueResponse\',\n {\'application-context-name\': (0,\n 4,\n 0,\n 0,\n 1,\n 0,\n 5,\n 3),\n \'protocol-version\': (1, 1),\n \'result\': 0,\n \'result-source-diagnostic\': (\'dialogue-service-user\',\n 0)})))},\n \'dtid\': b\'W\\x18\\x00\\x00\'})\n\n' ) expected_file = os.path.join(self.base_data_dir, 'Prettified', 'Primary_TCAP_MAP.txt') self.assertFileContentsEqual( expected_file, """Event_type: begin Otid: 00000001 Direct-reference: 0.0.17.773.1.1.1 Event_type: continue Otid: 840001ff Direct-reference: 0.0.17.773.1.1.1 Event_type: continue Otid: a5050001 Direct-reference: Event_type: end Otid: 00000000 Direct-reference: 0.0.17.773.1.1.1 """) expected_file = os.path.join(self.base_data_dir, 'Summaries', "Summary_%s.csv" % utils.current_date()) self.assertPathExists(expected_file) with open(expected_file, 'r') as f: for i, l in enumerate(f): pass self.assertEqual(i + 1, 4)
def test_01_manage_multiple_messages(self): asyncio.run(tasks.send_hex_msgs(self.client, self.multiple_encoded_hex)) time.sleep(3) expected_file = os.path.join(self.base_data_dir, 'Encoded', 'TCAP_MAP', 'localhost_00000000.TCAPMAP') self.assertBinaryFileContentsEqual( expected_file, binascii.unhexlify(self.multiple_encoded_hex[3])) expected_file = os.path.join(self.base_data_dir, 'Encoded', 'TCAP_MAP', 'localhost_00000001.TCAPMAP') self.assertBinaryFileContentsEqual( expected_file, binascii.unhexlify(self.multiple_encoded_hex[0])) expected_file = os.path.join(self.base_data_dir, 'Encoded', 'TCAP_MAP', 'localhost_840001ff.TCAPMAP') self.assertBinaryFileContentsEqual( expected_file, binascii.unhexlify(self.multiple_encoded_hex[1])) expected_file = os.path.join(self.base_data_dir, 'Encoded', 'TCAP_MAP', 'localhost_a5050001.TCAPMAP') self.assertBinaryFileContentsEqual( expected_file, binascii.unhexlify(self.multiple_encoded_hex[2])) self.assertEqual( len( os.listdir( os.path.join(self.base_data_dir, 'Decoded', 'TCAP_MAP'))), 4) self.assertEqual( len( os.listdir( os.path.join(self.base_data_dir, 'Prettified', 'TCAP_MAP'))), 4) expected_file = os.path.join(self.base_data_dir, 'Summaries', "Summary_%s.csv" % utils.current_date()) self.assertPathExists(expected_file) with open(expected_file, 'r') as f: for i, l in enumerate(f): pass self.assertEqual(i + 1, 4) expected_file = os.path.join(definitions.TEST_DATA_DIR, 'recordings', 'testrecord.mmr') self.assertPathExists(expected_file)
def test_06_do(self): asyncio.run(self.do_async(self.action.do, self.msg)) expected_file = Path(self.base_data_dir, 'Summaries', "Summary_%s.csv" % utils.current_date()) self.assertFileContentsEqual(expected_file, 'begin\t00000001\t2018-01-01 01:01:00\n')
def test_01_from_two_clients(self): asyncio.run(self.send_two_clients(self.multiple_encoded_hex[0], self.multiple_encoded_hex[1])) expected_file = Path(self.base_data_dir, 'Summaries', "Summary_%s.csv" % utils.current_date()) self.assertTrue(expected_file.exists()) self.assertNumLinesInFile(expected_file, 2)