dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/38658?usp=email )
Change subject: pySim-shell_test: add new testcase for card initialization ......................................................................
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 --- A tests/pySim-shell_test/card_init/__init__.py A tests/pySim-shell_test/card_init/test.py A tests/pySim-shell_test/card_init/test_card_init.script 3 files changed, 62 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/58/38658/1
diff --git a/tests/pySim-shell_test/card_init/__init__.py b/tests/pySim-shell_test/card_init/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/pySim-shell_test/card_init/__init__.py diff --git a/tests/pySim-shell_test/card_init/test.py b/tests/pySim-shell_test/card_init/test.py new file mode 100644 index 0000000..2f25057 --- /dev/null +++ b/tests/pySim-shell_test/card_init/test.py @@ -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() diff --git a/tests/pySim-shell_test/card_init/test_card_init.script b/tests/pySim-shell_test/card_init/test_card_init.script new file mode 100644 index 0000000..9f6d9b0 --- /dev/null +++ b/tests/pySim-shell_test/card_init/test_card_init.script @@ -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