From 385d4407da37ae2ebc0022478f2b988004d0db48 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Mon, 4 Nov 2024 15:01:40 +0100 Subject: [PATCH] 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 --- tests/pySim-shell_test/card_init/__init__.py | 0 tests/pySim-shell_test/card_init/test.py | 33 +++++++++++++++++++ .../card_init/test_card_init.script | 29 ++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 tests/pySim-shell_test/card_init/__init__.py create mode 100644 tests/pySim-shell_test/card_init/test.py create mode 100644 tests/pySim-shell_test/card_init/test_card_init.script 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 00000000..e69de29b 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 00000000..2f25057b --- /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 . + +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 00000000..1b8ad3b4 --- /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