Пример #1
0
 def test_filter_dict(self):
     dict = {"a": b("123"), "b": b("456"), "c": b("789")}
     field_list = ["a", "c"]
     expected_dict = {"a": "123", "c": "789"}
     actual_dict = filter_dictionary(dict, field_list)
     self.assertEqual(len(actual_dict), 2)
     self.assertEqual(actual_dict, expected_dict)
Пример #2
0
 def test_get_de55_fields(self):
     return_dict = _get_icc_fields(self.de55_field)
     print(return_dict)
     self.assertNotEqual(return_dict.get("TAG9F26", False), False)
     self.assertEqual(return_dict["TAG9F26"], b("3e2424eda369aa47"))
     self.assertNotEqual(return_dict.get("TAG9F36", False), False)
     self.assertEqual(return_dict["TAG9F36"], b("04dd"))
     self.assertNotEqual(return_dict.get("TAG82", False), False)
     self.assertEqual(return_dict["TAG82"], b("2000"))
Пример #3
0
def create_test_ascii_de55_ipm_file():
    message_raw = b(
        "1240" + "\xf0"
        "\x10\x07\xc2\x8d\xe1\x82\x02\x02\x00\x00\x04\x00\x00\x00\x00" + "1"
        "65204230010000012000000000000063"
        "20015102901120601010109014C00120"
        "01401599423752309053030010113511"
        "09110000000988503314801120609054"
        "9120000000290000010364     65MER"
        "CH TERMINAL SETT1\\152 Edward Str"
        "eetq\\BRISBANE\\4000      QLDAUS04"
        "80023003NA 014800403620158012   "
        "       750165001M036052"
        "\x9f\x26\x08\x3e\x24\x24\xed\xa3\x69"
        "\xaa\x47\x9f\x36\x02\x04\xdd\x82\x02\x20\x00\x9f\x02\x06\x00\x00"
        "\x00\x00\x14\x50\x9f\x03\x06\x00\x00\x00\x00\x00\x00\x9f\x27\x01"
        "\x80\x9f\x34\x03\x1f\x00\x00\x9f\x53\x01\xb5"
        "016 M"
        "DP388S6Q1015  000000921100000009"
        "885"
    )

    filename = "build/test/test_ascii_de55_ipm.in"

    message_list = [message_raw for _ in range(5)]
    block_and_write_list(message_list, filename)
Пример #4
0
def create_test_ebcdic_ipm_file():
    message_raw = _convert_text_asc2eb(b("1144")) + \
        b("\xF0\x10\x05\x42\x84\x61\x80\x02\x02\x00\x00\x04"
          "\x00\x00\x00\x00") + \
        _convert_text_asc2eb(b(
            "164444555544445555111111000000009999201508"
            "151715123456789012333123423579957991200000"
            "012306120612345612345657994211111111145BIG"
            " BOBS\\70 FERNDALE ST\\ANNERLEY\\4103  QLD"
            "AUS0080001001Y9990160000000000000001123456"
            "7806999999")
        )
    # add 5 records to a list
    message_list = [message_raw for x in range(5)]
    block_and_write_list(message_list,
                         ".".join([TEST_EBCDIC_IPM_FILENAME, "1014block"]))
Пример #5
0
def create_test_ascii_de55_ipm_file():
    message_raw = b(
        "1240" + "\xf0"
        "\x10\x07\xc2\x8d\xe1\x82\x02\x02\x00\x00\x04\x00\x00\x00\x00" + "1"
        "65204230010000012000000000000063"
        "20015102901120601010109014C00120"
        "01401599423752309053030010113511"
        "09110000000988503314801120609054"
        "9120000000290000010364     65MER"
        "CH TERMINAL SETT1\\152 Edward Str"
        "eetq\\BRISBANE\\4000      QLDAUS04"
        "80023003NA 014800403620158012   "
        "       750165001M036052"
        "\x9f\x26\x08\x3e\x24\x24\xed\xa3\x69"
        "\xaa\x47\x9f\x36\x02\x04\xdd\x82\x02\x20\x00\x9f\x02\x06\x00\x00"
        "\x00\x00\x14\x50\x9f\x03\x06\x00\x00\x00\x00\x00\x00\x9f\x27\x01"
        "\x80\x9f\x34\x03\x1f\x00\x00\x9f\x53\x01\xb5"
        "016 M"
        "DP388S6Q1015  000000921100000009"
        "885")

    filename = "build/test/test_ascii_de55_ipm.in"

    message_list = [message_raw for _ in range(5)]
    block_and_write_list(message_list, filename)
Пример #6
0
    def test_get_message_elements_ebcdic(self):
        message_raw = (_convert_text_asc2eb(b("1144")) +
                       b("\xF0\x10\x05\x42\x84\x61\x80\x02\x02\x00\x00\x04") +
                       b("\x00\x00\x00\x00") + _convert_text_asc2eb(
                           b("164444555544445555111111000000009999201508"
                             "151715123456789012333123423579957991200000"
                             "012306120612345612345657994211111111145BIG"
                             " BOBS\\70 FERNDALE ST\\ANNERLEY\\4103  QLD"
                             "AUS0080001001Y9990160000000000000001123456"
                             "7806999999")))
        message_elements = mciutil.get_message_elements(
            message_raw, CONFIG['data_elements'], 'ebcdic')

        # print message_elements
        self.assertEqual(message_elements["DE2"], b"444455*******555")
        self.assertEqual(message_elements["DE3"], b"111111")
        self.assertEqual(message_elements["DE4"], b"000000009999")
Пример #7
0
def create_test_ebcdic_ipm_file():
    message_raw = (
        _convert_text_asc2eb(b("1144"))
        + b("\xF0\x10\x05\x42\x84\x61\x80\x02\x02\x00\x00\x04" "\x00\x00\x00\x00")
        + _convert_text_asc2eb(
            b(
                "164444555544445555111111000000009999201508"
                "151715123456789012333123423579957991200000"
                "012306120612345612345657994211111111145BIG"
                " BOBS\\70 FERNDALE ST\\ANNERLEY\\4103  QLD"
                "AUS0080001001Y9990160000000000000001123456"
                "7806999999"
            )
        )
    )
    # add 5 records to a list
    message_list = [message_raw for x in range(5)]
    block_and_write_list(message_list, TEST_EBCDIC_IPM_FILENAME)
Пример #8
0
 def test_block(self):
     linebreakdata = []
     for x in range(0, 73):
         linebreakdata.append(b("1234567890"))
     output = mciutil.block(linebreakdata)
     hexdump.hexdump(output)
     input = mciutil.unblock(output)
     print(len(input))
     print(input)
Пример #9
0
 def test_block(self):
     linebreakdata = []
     for x in range(0, 73):
         linebreakdata.append(b("1234567890"))
     output = mciutil.block(linebreakdata)
     hexdump.hexdump(output)
     input = mciutil.unblock(output)
     print(len(input))
     print(input)
Пример #10
0
 def test_get_de43_elements(self):
     de43_raw = b("AAMI                  \\36 WICKHAM TERRACE             "
                  "              \\BRISBANE     \\4000      QLDAUS")
     de43_elements = _get_de43_fields(de43_raw)
     self.assertEqual(de43_elements["DE43_NAME"], b"AAMI")
     self.assertEqual(de43_elements["DE43_ADDRESS"], b"36 WICKHAM TERRACE")
     self.assertEqual(de43_elements["DE43_SUBURB"], b"BRISBANE")
     self.assertEqual(de43_elements["DE43_POSTCODE"], b"4000")
     self.assertEqual(de43_elements["DE43_STATE"], b"QLD")
     self.assertEqual(de43_elements["DE43_COUNTRY"], b"AUS")
Пример #11
0
 def test_get_de43_elements(self):
     de43_raw = b(
         "AAMI                  \\36 WICKHAM TERRACE             " "              \\BRISBANE     \\4000      QLDAUS"
     )
     de43_elements = _get_de43_fields(de43_raw)
     self.assertEqual(de43_elements["DE43_NAME"], b"AAMI")
     self.assertEqual(de43_elements["DE43_ADDRESS"], b"36 WICKHAM TERRACE")
     self.assertEqual(de43_elements["DE43_SUBURB"], b"BRISBANE")
     self.assertEqual(de43_elements["DE43_POSTCODE"], b"4000")
     self.assertEqual(de43_elements["DE43_STATE"], b"QLD")
     self.assertEqual(de43_elements["DE43_COUNTRY"], b"AUS")
Пример #12
0
    def test_get_message_elements_ebcdic(self):
        message_raw = (
            _convert_text_asc2eb(b("1144"))
            + b("\xF0\x10\x05\x42\x84\x61\x80\x02\x02\x00\x00\x04")
            + b("\x00\x00\x00\x00")
            + _convert_text_asc2eb(
                b(
                    "164444555544445555111111000000009999201508"
                    "151715123456789012333123423579957991200000"
                    "012306120612345612345657994211111111145BIG"
                    " BOBS\\70 FERNDALE ST\\ANNERLEY\\4103  QLD"
                    "AUS0080001001Y9990160000000000000001123456"
                    "7806999999"
                )
            )
        )
        message_elements = mciutil.get_message_elements(message_raw, CONFIG["data_elements"], "ebcdic")

        # print message_elements
        self.assertEqual(message_elements["DE2"], b"444455*******555")
        self.assertEqual(message_elements["DE3"], b"111111")
        self.assertEqual(message_elements["DE4"], b"000000009999")
Пример #13
0
def create_test_ascii_ipm_file():
    """
    Create a test IPM file to perform cli testing with
    """
    message_raw = b("1144\xF0\x10\x05\x42\x84\x61\x80\x02\x02\x00\x00\x04"
                    "\x00\x00\x00\x00"
                    "1644445555444455551111110000000099992015081517151234"
                    "5678901233312342357995799120000001230612061234561234"
                    "5657994211111111145BIG BOBS\\70 FERNDALE ST\\ANNERLE"
                    "Y\\4103  QLDAUS0080001001Y99901600000000000000011234"
                    "567806999999")
    # add 5 records to a list
    message_list = [message_raw for x in range(5)]
    block_and_write_list(message_list, TEST_ASCII_IPM_FILENAME)
Пример #14
0
def create_bad_ascii_ipm_file():
    """
    Create a test IPM file with length greater than bitmap data.
    This record has additional byte added
    """
    message_raw = b(
        "\x00\x00\x00\xee1144\xF0\x10\x05\x42\x84\x61\x80\x02\x02\x00\x00\x04"
        "\x00\x00\x00\x00"
        "1644445555444455551111110000000099992015081517151234"
        "5678901233312342357995799120000001230612061234561234"
        "5657994211111111145BIG BOBS\\70 FERNDALE ST\\ANNERLE"
        "Y\\4103  QLDAUS0080001001Y99901600000000000000011234"
        "567806999999^")
    filename = "build/test/test_bad_ascii_ipm.in"
    with open(filename, 'wb') as output_file:
        output_file.write(message_raw)
Пример #15
0
def create_test_ascii_ipm_file():
    """
    Create a test IPM file to perform cli testing with
    """
    message_raw = b(
        "1144\xF0\x10\x05\x42\x84\x61\x80\x02\x02\x00\x00\x04"
        "\x00\x00\x00\x00"
        "1644445555444455551111110000000099992015081517151234"
        "5678901233312342357995799120000001230612061234561234"
        "5657994211111111145BIG BOBS\\70 FERNDALE ST\\ANNERLE"
        "Y\\4103  QLDAUS0080001001Y99901600000000000000011234"
        "567806999999"
    )
    # add 5 records to a list
    message_list = [message_raw for x in range(5)]
    block_and_write_list(message_list, TEST_ASCII_IPM_FILENAME)
Пример #16
0
class TestDe55unblock(TestCase):

    de55_field = b(
        "\x9f\x26\x08\x3e\x24\x24\xed\xa3\x69"
        "\xaa\x47\x9f\x36\x02\x04\xdd\x82\x02\x20\x00\x9f\x02\x06\x00\x00"
        "\x00\x00\x14\x50\x9f\x03\x06\x00\x00\x00\x00\x00\x00\x9f\x27\x01"
        "\x80\x9f\x34\x03\x1f\x00\x00\x9f\x53\x01\xb5")

    def test_get_de55_fields(self):
        return_dict = _get_icc_fields(self.de55_field)
        print(return_dict)
        self.assertNotEqual(return_dict.get("TAG9F26", False), False)
        self.assertEqual(return_dict['TAG9F26'], b("3e2424eda369aa47"))
        self.assertNotEqual(return_dict.get("TAG9F36", False), False)
        self.assertEqual(return_dict['TAG9F36'], b("04dd"))
        self.assertNotEqual(return_dict.get("TAG82", False), False)
        self.assertEqual(return_dict['TAG82'], b("2000"))
Пример #17
0
    def test_flip_message_elements_ascii(self):
        message_raw = b(
            "1144\xF0\x10\x05\x42\x84\x61\x80\x02\x02\x00\x00\x04"
            "\x00\x00\x00\x00" + "1644445555444455551111110000000099992015081517151234"
            "5678901233312342357995799120000001230612061234561234"
            "5657994211111111145BIG BOBS\\70 FERNDALE ST\\ANNERLE"
            "Y\\4103  QLDAUS0080001001Y99901600000000000000011234"
            "567806999999"
        )

        message_elements = flip_message_encoding(message_raw, CONFIG["data_elements"], "ascii")
        print("************* E B C D I C ******************")
        hexdump.hexdump(message_elements)
        message_elements = flip_message_encoding(message_elements, CONFIG["data_elements"], "ebcdic")
        print("************* A S C I I ********************")
        hexdump.hexdump(message_elements)
        print("********************************************")
        self.assertEqual(message_raw, message_elements)
Пример #18
0
    def test_get_message_elements_ascii(self):
        message_raw = b(
            "1144\xF0\x10\x05\x42\x84\x61\x80\x02\x02\x00\x00\x04"
            "\x00\x00\x00\x00" + "1644445555444455551111110000000099992015081517151234"
            "5678901233312342357995799120000001230612061234561234"
            "5657994211111111145BIG BOBS\\70 FERNDALE ST\\ANNERLE"
            "Y\\4103  QLDAUS0080001001Y99901600000000000000011234"
            "567806999999"
        )

        message_elements = mciutil.get_message_elements(message_raw, CONFIG["data_elements"], "ascii")

        print(message_elements)

        # print message_elements
        self.assertEqual(message_elements["DE2"], b"444455*******555")
        self.assertEqual(message_elements["DE3"], b"111111")
        self.assertEqual(message_elements["DE4"], b"000000009999")
        self.assertEqual(message_elements["PDS0001"], b"Y")
Пример #19
0
    def test_get_message_elements_ascii(self):
        message_raw = b("1144\xF0\x10\x05\x42\x84\x61\x80\x02\x02\x00\x00\x04"
                        "\x00\x00\x00\x00" +
                        "1644445555444455551111110000000099992015081517151234"
                        "5678901233312342357995799120000001230612061234561234"
                        "5657994211111111145BIG BOBS\\70 FERNDALE ST\\ANNERLE"
                        "Y\\4103  QLDAUS0080001001Y99901600000000000000011234"
                        "567806999999")

        message_elements = mciutil.get_message_elements(
            message_raw, CONFIG['data_elements'], 'ascii')

        print(message_elements)

        # print message_elements
        self.assertEqual(message_elements["DE2"], b"444455*******555")
        self.assertEqual(message_elements["DE3"], b"111111")
        self.assertEqual(message_elements["DE4"], b"000000009999")
        self.assertEqual(message_elements["PDS0001"], b"Y")
Пример #20
0
    def test_flip_message_elements_ascii(self):
        message_raw = b("1144\xF0\x10\x05\x42\x84\x61\x80\x02\x02\x00\x00\x04"
                        "\x00\x00\x00\x00" +
                        "1644445555444455551111110000000099992015081517151234"
                        "5678901233312342357995799120000001230612061234561234"
                        "5657994211111111145BIG BOBS\\70 FERNDALE ST\\ANNERLE"
                        "Y\\4103  QLDAUS0080001001Y99901600000000000000011234"
                        "567806999999")

        message_elements = flip_message_encoding(message_raw,
                                                 CONFIG['data_elements'],
                                                 'ascii')
        print("************* E B C D I C ******************")
        hexdump.hexdump(message_elements)
        message_elements = flip_message_encoding(message_elements,
                                                 CONFIG['data_elements'],
                                                 'ebcdic')
        print("************* A S C I I ********************")
        hexdump.hexdump(message_elements)
        print("********************************************")
        self.assertEqual(message_raw, message_elements)
Пример #21
0
class TestDe55unblock(TestCase):

    de55_field = b(
        "\x9f\x26\x08\x3e\x24\x24\xed\xa3\x69"
        "\xaa\x47\x9f\x36\x02\x04\xdd\x82\x02\x20\x00\x9f\x02\x06\x00\x00"
        "\x00\x00\x14\x50\x9f\x03\x06\x00\x00\x00\x00\x00\x00\x9f\x27\x01"
        "\x80\x9f\x34\x03\x1f\x00\x00\x9f\x53\x01\xb5")

    def test_get_de55_fields(self):
        return_dict = _get_icc_fields(self.de55_field)
        print(return_dict)
        self.assertNotEqual(return_dict.get("TAG9F26", False), False)
        self.assertEqual(return_dict['TAG9F26'], b("3e2424eda369aa47"))
        self.assertNotEqual(return_dict.get("TAG9F36", False), False)
        self.assertEqual(return_dict['TAG9F36'], b("04dd"))
        self.assertNotEqual(return_dict.get("TAG82", False), False)
        self.assertEqual(return_dict['TAG82'], b("2000"))

    def test_get_de55_null_eof(self):
        de55_data = binascii.unhexlify(
            '9f26081c89a48c0c4c3a309f2701809f10120110a04001240000000000000000000000ff9f370401bd0f6d9f36020011950500000480009a031909069c01009f02060000000289985f2a020032820239009f1a0200329f03060000000000009f1e0837383636343738349f3303e0f0c89f3501009f090200009f34034203008407a0000000041010910aaf6f5977b4ca292500120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
        )
        return_dict = _get_icc_fields(de55_data)
        print(return_dict)
Пример #22
0
 def test_vbs_to_line(self):
     vbs_record = b("\x00\x00\x00\x0A1234567890\x00\x00\x00\x0A1234567890")
     records = mciutil.vbs_unpack(vbs_record)
     print("Length of output =", len(records))
     print(records)
Пример #23
0
 def test_vbs_to_line(self):
     vbs_record = b("\x00\x00\x00\x0A1234567890\x00\x00\x00\x0A1234567890")
     records = mciutil.vbs_unpack(vbs_record)
     print("Length of output =", len(records))
     print(records)
Пример #24
0
 def test_line_to_vbs(self):
     linebreakdata = [b("1234567890"), b("1234567890")]
     vbsdata = mciutil.vbs_pack(linebreakdata)
     hexdump.hexdump(vbsdata)
     self.assertEqual(vbsdata, b"\x00\x00\x00\x0A1234567890\x00\x00\x00\x0A123456" b"7890\x00\x00\x00\x00")
Пример #25
0
 def test_mask_pan_prefix(self):
     card_number = b("1234567890123456")
     self.assertEqual(_mask_pan(card_number, prefix_only=True),
                      b"123456789")
Пример #26
0
 def test_mask_pan(self):
     card_number = b("1234567890123456")
     self.assertEqual(_mask_pan(card_number), b"123456*******456")
Пример #27
0
 def test_unblock(self):
     umodedata = (b("\x00\x00\x00\x0A1234567890") * 72) + b("\x00\x00\x00\x0A\x40\x401234567890")
     records = mciutil.unblock(umodedata)
     print(len(records))
     print(records[0])
     print(records[72])
Пример #28
0
 def test_mask_pan(self):
     card_number = b("1234567890123456")
     self.assertEqual(_mask_pan(card_number), b"123456*******456")
Пример #29
0
 def test_get_de43_elements_no_pattern_match(self):
     de43_raw = b("MUMBAI EMV ATM - 2  MUMBAI      IN")
     de43_elements = _get_de43_fields(de43_raw)
     self.assertEqual({}, de43_elements)