pySim-shell_test: add new testcase for card initialization

The card initialization normally takes place automatically. Nearly all
testcases implicitly cover this code-path. However, it is also possible
to skip the card initialization and do it at some later point. This is
commonly the case for unprovisioned card that require some custom APDUs
in a basic initialization step. When this step is done one would use
the "equip" command to level up to the full featured mode. This patch
adds a testcase for this scenario

Related: OS#6367
Change-Id: I01a03fa07d8c62164453bd707c5943288ff1a972
This commit is contained in:
Philipp Maier
2024-11-04 15:01:40 +01:00
parent 852eff54df
commit 385d4407da
3 changed files with 62 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
# Testsuite for pySim-shell.py
#
# (C) 2024 by sysmocom - s.f.m.c. GmbH
# All Rights Reserved
#
# Author: Philipp Maier
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest
import os
from utils import *
class test_case(UnittestUtils):
def test_card_init(self):
cardname = 'sysmoISIM-SJA5-S17'
self.runPySimShell(cardname, "test_card_init.script", no_exceptions = True, skip_card_init = True)
if __name__ == "__main__":
unittest.main()

View File

@@ -0,0 +1,29 @@
set debug true
set echo true
# In this test we start without initializing any card profile. In this situation
# only the "apdu" command and the "reset" command will work.
# Select a file deep in the file system using APDUs only
apdu 00a40004023f0000 --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$'
apdu 00a4040410a0000000871002ffffffff890709000000 --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$'
apdu 00a40004026f0700 --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$'
# Try a reset
reset
# If the reset had an effect, selecting a file at MF level should work
apdu 00a40004022fe200 --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$'
# Equip the card, this will do the profile initialization. After this,
# pySim-shell commands should work normally.
equip
# Select a file deep in the file system
select MF/ADF.USIM/EF.IMSI
# Try again to reset the card
reset
# If the reset had an effect, selecting a file at MF level should work
select EF.ICCID