Esempio n. 1
0
 def test_parse_fixed_no_optional(self):
     c = CommandAPDU.parse(bytearray.fromhex('06000498765441'))
     self.assertEqual(
         '987654',
         c.password,
     )
     self.assertEqual(0x41, c.config_byte)
     self.assertIsNone(c.cc)
Esempio n. 2
0
 def test_write_file_2(self):
     c = CommandAPDU.parse([
         16, 2, 8, 20, 101, 0, 0, 0, 6, 96, 45, 10, 29, 1, 48, 31, 0, 4, 0,
         0, 2, 103, 45, 10, 29, 1, 49, 31, 0, 4, 0, 0, 0, 231, 45, 10, 29,
         1, 33, 31, 0, 4, 0, 59, 48, 18, 45, 10, 29, 1, 32, 31, 0, 4, 0, 0,
         2, 103, 45, 10, 29, 1, 16, 16, 31, 0, 4, 0, 41, 58, 67, 45, 10, 29,
         1, 17, 31, 0, 4, 0, 180, 5, 108, 45, 10, 29, 1, 18, 31, 0, 4, 0, 0,
         3, 57, 45, 10, 29, 1, 19, 31, 0, 4, 0, 0, 6, 2, 16, 3, 185, 57
     ])
     self.assertIsInstance(c, WriteFileBase)
Esempio n. 3
0
    def test_parse_with_tlv(self):
        c = CommandAPDU.parse(
            bytearray.fromhex(
                '06501712345606123f210c60065501aa0501bb1002abba110177'))

        self.assertEqual('123456', c.password)
        self.assertEqual(b'\x77', c.tlv.x11)
        self.assertEqual(b'\xaa', c.tlv.x3f21.x60.x55)
        self.assertEqual(b'\xbb', c.tlv.x3f21.x60.x5)
        self.assertEqual(b'\xab\xba', c.tlv.x3f21.x10)
Esempio n. 4
0
    def test_parse_cursed_completion(self):
        c1 = CommandAPDU.parse(bytearray.fromhex('060f07F0F0F3626c6100'))
        self.assertEqual(0x00, c1.terminal_status)
        self.assertEqual('bla', c1.sw_version)

        c2 = CommandAPDU.parse(bytearray.fromhex('060f07F0F0F3626c6106'))
        self.assertEqual(0x06, c2.terminal_status)
        self.assertNotIn('tlv', c2.as_dict())

        c3 = CommandAPDU.parse(bytearray.fromhex('060f09F0F0F3626c61060600'))
        self.assertEqual(0x06, c3.terminal_status)
        self.assertIn('tlv', c3.as_dict())

        c4 = CommandAPDU.parse(bytearray.fromhex('060f0106'))
        self.assertEqual(0x06, c4.terminal_status)
        self.assertIsNone(c4.sw_version)
        self.assertNotIn('tlv', c4.as_dict())

        c5 = CommandAPDU.parse(bytearray.fromhex('060f03060600'))
        self.assertEqual(0x06, c5.terminal_status)
        self.assertIn('tlv', c5.as_dict())
Esempio n. 5
0
 def test_parse_simple(self):
     c = CommandAPDU.parse(bytearray.fromhex('060200'))
     self.assertIsInstance(c, LogOff)
Esempio n. 6
0
 def test_parse_fixed_with_optional(self):
     c = CommandAPDU.parse(bytearray.fromhex('060006987654410978'))
     self.assertEqual(978, c.cc)
Esempio n. 7
0
    def test_override_bitmaps(self):
        c = CommandAPDU.parse(bytearray.fromhex('ffaa040602ffaa'))

        self.assertIsInstance(c.raw_tlv, bytes)
        self.assertEqual(b'\x02\xff\xaa', c.raw_tlv)
Esempio n. 8
0
 def test_parse_fixed(self):
     c = CommandAPDU.parse(bytearray.fromhex('069303999999'))
     self.assertEqual('999999', c.password)