def test_resolveIndex(self): rslvr = linkResolver() mtd = rslvr.resolveIndex(5, javatest_cap) try: mtd(0x9000) self.fail() except ISOException, ioe: self.assertEquals(0x9000, ioe.getReason())
def test_gcdRecursif(self): intr = JavaCardVM(linkResolver()) intr.load(javatest_cap) intr.frames.push( JavaCardFrame( [42, 56], [29, 97, 4, 28, 120, 29, 28, 29, 73, 141, 0, 9, 120])) self._run(intr) self.assertEquals(14, intr.getRetValue())
def test__resolveExtStaticMethod(self): rslvr = linkResolver() # ISOExcption.throwIt mtd = rslvr._resolveExtStaticMethod(b'\xa0\x00\x00\x00b\x01\x01', 7, 1) try: mtd(0x9000) self.fail() except ISOException as ioe: self.assertEqual(0x9000, ioe.getReason())
def test_callExtStaticMethod(self): intr = JavaCardVM(linkResolver()) intr.load(javatest_cap) intr.frames.push(JavaCardFrame([None, None], [17, 106, 129, 141, 0, 5, 122])) try: self._run(intr) self.fail() except ISOException, ioe: self.assertEquals(0x6A81, ioe.getReason())
def test__resolveExtStaticMethod(self): rslvr = linkResolver() # ISOExcption.throwIt mtd = rslvr._resolveExtStaticMethod('\xa0\x00\x00\x00b\x01\x01', 7, 1) try: mtd(0x9000) self.fail() except ISOException, ioe: self.assertEquals(0x9000, ioe.getReason())
def test_callExtStaticMethod(self): intr = JavaCardVM(linkResolver()) intr.load(javatest_cap) intr.frames.push(JavaCardFrame([None, None], [17, 106, 129, 141, 0, 5, 122], 0)) try: self._run(intr) self.fail() except ISOException as ioe: self.assertEqual(0x6A81, ioe.getReason())
def test_objectCreation(self): intr = JavaCardVM(linkResolver()) intr.load(javatest_cap) intr.frames.push(TestDummyFrame([None])) intr.new(2) intr.dup() intr.invokespecial(3) self._run(intr) # dig into intr.invokevirtual(4) intr.returnn()
def test_resolveIndex(self): rslvr = linkResolver() mtd = rslvr.resolveIndex(5, javatest_cap) try: mtd(0x9000) self.fail() except ISOException as ioe: self.assertEqual(0x9000, ioe.getReason()) cls = rslvr.resolveIndex(2, javatest_cap) self.assertTrue(issubclass(cls.cls, Applet))
def __init__(self, jcversion = (3,0,1)): self.current_applet_aid = None # a2d(aid) => Applet self.applets = {} # channel => Applet self.selected = [None, None, None, None] # opened self.channels = [True, False, False, False] # current one self.current_channel = 0 # Create the VM self.vm = JavaCardVM(resolver.linkResolver(jcversion)) self.installJCFunctions()
def __init__(self, jcversion=(3, 0, 1)): self.current_applet_aid = None # a2d(aid) => Applet self.applets = {} # channel => Applet self.selected = [None, None, None, None] # opened self.channels = [True, False, False, False] # current one self.current_channel = 0 # Create the VM self.vm = JavaCardVM(resolver.linkResolver(jcversion)) self.installJCFunctions()
def test_callVirtualMethod(self): intr = JavaCardVM(linkResolver()) intr.load(javatest_cap) intr.frames.push(TestDummyFrame([None])) intr.new(2) intr.dup() intr.invokespecial(3) self._run(intr) self.assertTrue(isinstance(intr.frame.stack[-1], Applet)) for i in xrange(1, 4): intr.dup() intr.sspush(i) intr.invokevirtual(7) self._run(intr) self.assertEqual(i, intr.frame.stack[-1]) intr.pop() intr.returnn()
def test_addExportFile(self): rslvr = linkResolver() self.assertFalse(rslvr.hasPackage('\xA0\x00\x00\x00\x18\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01')) rslvr.addExportFile(javatest_exp) self.assertTrue(rslvr.hasPackage('\xA0\x00\x00\x00\x18\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01'))
def testInit(self): rslvr = linkResolver() jcmtd = JavaCardStaticMethod(109, javatest_cap, rslvr) jcmtd = JavaCardVirtualMethod(0, 8, False, javatest_cap, rslvr) self.assertEqual(2, len(jcmtd.excpt_handlers))
def test_gcdRecursif(self): intr = JavaCardVM(linkResolver()) intr.load(javatest_cap) intr.frames.push(JavaCardFrame([42, 56], [29, 97, 4, 28, 120, 29, 28, 29, 73, 141, 0, 9, 120])) self._run(intr) self.assertEquals(14, intr.getRetValue())
def test_getModule(self): rslvr = linkResolver() from python import lang as java_lang self.assertEqual(java_lang, rslvr._getModule('java.lang'))
def test_addExportFile(self): rslvr = linkResolver() self.assertFalse(rslvr.hasPackage(b'\xA0\x00\x00\x00\x18\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01')) rslvr.addExportFile(javatest_exp) self.assertTrue(rslvr.hasPackage(b'\xA0\x00\x00\x00\x18\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01'))
def test__resolveExtClass(self): rslvr = linkResolver() self.assertEqual(ISOException, rslvr._resolveExtClass(b'\xa0\x00\x00\x00b\x01\x01', 7).cls)
def test_basicPackage(self): rslvr = linkResolver() self.assertTrue(rslvr.hasPackage(b'\xa0\x00\x00\x00b\x00\x01')) self.assertFalse(rslvr.hasPackage(b'\xa0'))
def test__resolveExtClass(self): rslvr = linkResolver() self.assertEquals(ISOException, rslvr._resolveExtClass('\xa0\x00\x00\x00b\x01\x01', 7).cls)
def test_basicPackage(self): rslvr = linkResolver() self.assertTrue(rslvr.hasPackage('\xa0\x00\x00\x00b\x00\x01')) self.assertFalse(rslvr.hasPackage('\xa0'))