def test_03_read_imsi_raw(self): status, data1 = self.shell.read("/ADF0/EF_IMSI") self.shell.assertOk(status, data1) status, data = self.shell.cd("/") self.shell.assertOk(status, data) status, data2 = self.shell.read("EF_IMSI") self.shell.assertOk(status, data2) imsi1 = types.getDataValue(data1) imsi2 = types.getDataValue(data2) self.assertEqual(imsi1, imsi2) imsiRawLength = len(imsi1) self.assertGreater(imsiRawLength, 14+3, "Invalid imsi raw length")
def test_03_read_imsi_raw(self): status, data1 = self.shell.read("/ADF0/EF_IMSI") self.shell.assertOk(status, data1) status, data = self.shell.cd("/") self.shell.assertOk(status, data) status, data2 = self.shell.read("EF_IMSI") self.shell.assertOk(status, data2) imsi1 = types.getDataValue(data1) imsi2 = types.getDataValue(data2) self.assertEqual(imsi1, imsi2) imsiRawLength = len(imsi1) self.assertGreater(imsiRawLength, 14 + 3, "Invalid imsi raw length")
def test_10_ls(self): dirPath = "/" status, out = self.shell.cd(dirPath) self.shell.assertOk(status, out) status, out = self.shell.ls() self.shell.assertOk(status, out) files = types.getDataValue(out) self.assertTrue(files) dirPath = "/7F10" status, out = self.shell.cd(dirPath) self.shell.assertOk(status, out) status, out = self.shell.ls() self.shell.assertOk(status, out) files = types.getDataValue(out) self.assertTrue("5F3A/" in files, "Files: %s" % files)
def test_10_ls(self): dirPath = "/" status, out = self.shell.cd(dirPath) self.shell.assertOk(status, out) status, out = self.shell.ls() self.shell.assertOk(status, out) files = types.getDataValue(out) self.assertTrue(files) dirPath = "/7F10" status, out = self.shell.cd(dirPath) self.shell.assertOk(status, out) status, out = self.shell.ls() self.shell.assertOk(status, out) files = types.getDataValue(out) self.assertTrue("5F3A/" in files, "Files: %s" %files)
def test_01_read_iccid(self): status, data = self.shell.read("/2FE2") self.assertEqual(status, "status OK") value = types.getDataValue(data) self.assertTrue(status, "read imsi failed") valueLength = len(value) self.assertGreater(valueLength, 9, "Invalid ICCID length")
def test_12_extend(self): filePath = "/ADF0/DEAD/BEEF" parentPath = types.parentDirFromPath(filePath) + '/' # Cleanup try: self.shell.delete(parentPath) except: pass # Create temporary dir and file (linear) fileType = types_g.fileDescriptor.LINEAR_FIXED_STRUCTURE fileSize = 0x30 recordLength = 0x10 status, out = self.shell.create(filePath, "fileType=%X,fileSize=%X,recordLength=%X" \ % (fileType, fileSize, recordLength)) self.shell.assertOk(status, out) # Increase the size of the file (by 2 new records) with a pattern numOfRecordsToExtend = 2 status, out = self.shell.extend(filePath, numOfRecordsToExtend) self.shell.assertOk(status, out) # Check the data after extension status, data = self.shell.read(filePath) self.shell.assertOk(status, data) value = types.getDataValue(data).replace(';', '') self.assertEqual(len(value)/2, fileSize + numOfRecordsToExtend * recordLength) status, out = self.shell.delete(parentPath) self.shell.assertOk(status, out)
def test_11_resize(self): filePath = "/ADF0/DEAD/BEEF" parentPath = types.parentDirFromPath(filePath) + '/' # Cleanup try: self.shell.delete(parentPath) except: pass # Create temporary dir and file (linear) fileType = types_g.fileDescriptor.LINEAR_FIXED_STRUCTURE fileSize = 0x30 recordLength = 0x10 status, out = self.shell.create(filePath, "fileType=%X,fileSize=%X,recordLength=%X" \ % (fileType, fileSize, recordLength)) self.shell.assertOk(status, out) # Increase the size of the file (by 2 new records) with a pattern newFileSize = fileSize + recordLength * 2 pattern = types.addTrailingBytes('', 0xA5, recordLength - 4) # not the whole record length status, out = self.shell.resize(filePath, hex(newFileSize), pattern) self.shell.assertOk(status, out) # Check the data after resize status, data = self.shell.read(filePath) self.shell.assertOk(status, data) value = types.getDataValue(data).replace(';', '') self.assertEqual(len(value) / 2, newFileSize) # Decrease the size of the file to one record status, out = self.shell.resize(filePath, hex(recordLength)) self.shell.assertOk(status, out) status, out = self.shell.delete(parentPath) self.shell.assertOk(status, out)
def test_01_read_iccid(self): status, data = self.shell.read("/2FE2") self.assertEqual(status, "status OK") value = types.getDataValue(data) self.assertTrue(status, "read imsi failed") valueLength = len(value) self.assertGreater(valueLength, 9, "Invalid ICCID length")
def test_12_extend(self): filePath = "/ADF0/DEAD/BEEF" parentPath = types.parentDirFromPath(filePath) + '/' # Cleanup try: self.shell.delete(parentPath) except: pass # Create temporary dir and file (linear) fileType = types_g.fileDescriptor.LINEAR_FIXED_STRUCTURE fileSize = 0x30 recordLength = 0x10 status, out = self.shell.create(filePath, "fileType=%X,fileSize=%X,recordLength=%X" \ % (fileType, fileSize, recordLength)) self.shell.assertOk(status, out) # Increase the size of the file (by 2 new records) with a pattern numOfRecordsToExtend = 2 status, out = self.shell.extend(filePath, numOfRecordsToExtend) self.shell.assertOk(status, out) # Check the data after extension status, data = self.shell.read(filePath) self.shell.assertOk(status, data) value = types.getDataValue(data).replace(';', '') self.assertEqual( len(value) / 2, fileSize + numOfRecordsToExtend * recordLength) status, out = self.shell.delete(parentPath) self.shell.assertOk(status, out)
def test_11_resize(self): filePath = "/ADF0/DEAD/BEEF" parentPath = types.parentDirFromPath(filePath) + '/' # Cleanup try: self.shell.delete(parentPath) except: pass # Create temporary dir and file (linear) fileType = types_g.fileDescriptor.LINEAR_FIXED_STRUCTURE fileSize = 0x30 recordLength = 0x10 status, out = self.shell.create(filePath, "fileType=%X,fileSize=%X,recordLength=%X" \ % (fileType, fileSize, recordLength)) self.shell.assertOk(status, out) # Increase the size of the file (by 2 new records) with a pattern newFileSize = fileSize + recordLength * 2 pattern = types.addTrailingBytes('', 0xA5, recordLength-4) # not the whole record length status, out = self.shell.resize(filePath, hex(newFileSize), pattern) self.shell.assertOk(status, out) # Check the data after resize status, data = self.shell.read(filePath) self.shell.assertOk(status, data) value = types.getDataValue(data).replace(';', '') self.assertEqual(len(value)/2, newFileSize) # Decrease the size of the file to one record status, out = self.shell.resize(filePath, hex(recordLength)) self.shell.assertOk(status, out) status, out = self.shell.delete(parentPath) self.shell.assertOk(status, out)
def test_09_pwd(self): dirPath = "/7F10/5F3A" name = "DF_PHONEBOOK" status, out = self.shell.cd(dirPath) self.shell.assertOk(status, out) status, out = self.shell.pwd() self.shell.assertOk(status, out) path = types.getDataValue(out) #compare to directory self.assertEqual(path, "path=%s/,name=%s,simId=0" % (dirPath, name))
def test_09_pwd(self): dirPath = "/7F10/5F3A" name = "DF_PHONEBOOK" status, out = self.shell.cd(dirPath) self.shell.assertOk(status, out) status, out = self.shell.pwd() self.shell.assertOk(status, out) path = types.getDataValue(out) #compare to directory self.assertEqual(path, "path=%s/,name=%s,simId=0" %(dirPath, name))
def copyFiles(self, cardMainFrom, cardMainTo, files): simIdFrom = self.getSimId(self.getRelatedCtrlCard(cardMainFrom)) simIdTo = self.getSimId(self.getRelatedCtrlCard(cardMainTo)) self.shell.select_sim_card(simIdFrom) fileDict = {} for file in files: status, data = self.shell.read(file) self.shell.assertOk(status, data) value = types.getDataValue(data) fileDict.update({file: value}) self.shell.select_sim_card(simIdTo) for fileName, value in fileDict.iteritems(): status, data = self.shell.write(fileName, value) self.shell.assertOk(status, data)
def copyFiles(self, cardMainFrom, cardMainTo, files): simIdFrom = self.getSimId(self.getRelatedCtrlCard(cardMainFrom)) simIdTo = self.getSimId(self.getRelatedCtrlCard(cardMainTo)) self.shell.select_sim_card(simIdFrom) fileDict = {} for file in files: status, data = self.shell.read(file) self.shell.assertOk(status, data) value = types.getDataValue(data) fileDict.update({file : value}) self.shell.select_sim_card(simIdTo) for fileName, value in fileDict.iteritems(): status, data = self.shell.write(fileName, value) self.shell.assertOk(status, data)
def postCardsList(self, status, respData, data): if not self.satCtrl.statusOk(status): return text = "" for simId, cardDict in enumerate(self.satCtrl.simRouter.cardsDict): self.satCtrl.simRouter.simCtrl.setSrvCtrlId(simId) status, data = self.shell.readi("EF_IMSI") if not self.shell.statusOk(status): self.satCtrl.displayText("IMSI read failed!") self.satCtrl.stopPostActionHandler() return imsi = types.getDataValue(data) imsiReadByPhone = cardDict[0].imsi if imsiReadByPhone == imsi: readByPhone = "*" elif imsiReadByPhone != None: readByPhone = "#" else: readByPhone = "" text += ("SIM id: " + str(simId) + "\n" + " IMSI: " + imsi + " " + readByPhone + "\n") self.satCtrl.displayText("Cards connected\n" + text) self.satCtrl.stopPostActionHandler()
def postCardsList(self, status, respData, data): if not self.satCtrl.statusOk(status): return text = "" for simId, cardDict in enumerate(self.satCtrl.simRouter.cardsDict): self.satCtrl.simRouter.simCtrl.setSrvCtrlId(simId) status, data = self.shell.readi("EF_IMSI") if not self.shell.statusOk(status): self.satCtrl.displayText("IMSI read failed!") self.satCtrl.stopPostActionHandler() return imsi = types.getDataValue(data) imsiReadByPhone = cardDict[0].imsi if imsiReadByPhone == imsi: readByPhone = "*" elif imsiReadByPhone != None: readByPhone = "#" else: readByPhone = "" text += ("SIM id: " + str(simId) + "\n" + " IMSI: " + imsi + " " + readByPhone + "\n") self.satCtrl.displayText("Cards connected\n" + text) self.satCtrl.stopPostActionHandler()
def test_01_read_iccid(self): status, data = self.shell.read("/2FE2") self.shell.assertOk(status, data) value = types.getDataValue(data) valueLength = len(value) self.assertGreater(valueLength, 9, "Invalid ICCID length")
def test_01_read_iccid(self): status, data = self.shell.read("/2FE2") self.shell.assertOk(status, data) value = types.getDataValue(data) valueLength = len(value) self.assertGreater(valueLength, 9, "Invalid ICCID length")