mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-19 11:58:34 +03:00
Add testsuite for pySim-shell with real cards
This patch adds a comprehensive testsuite for pySim-shell. The testsuite is based on python's unittest framework in combination with pySim-shell scripts. Related: OS#6531 Change-Id: Ieae1330767a6e55e62437f5f988a0d33b727b5de
This commit is contained in:
0
tests/pySim-shell_test/get_identity/__init__.py
Normal file
0
tests/pySim-shell_test/get_identity/__init__.py
Normal file
37
tests/pySim-shell_test/get_identity/test.py
Normal file
37
tests/pySim-shell_test/get_identity/test.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# 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 *
|
||||
from pySim.utils import is_hex
|
||||
|
||||
class test_case(UnittestUtils):
|
||||
def test(self):
|
||||
cardname = 'sysmoISIM-SJA5-S17'
|
||||
|
||||
self.runPySimShell(cardname, "test.script", add_adm = True)
|
||||
suci = self.getFileContent("suci.tmp", substr_regex = ': (.*?)$')
|
||||
self.assertTrue(is_hex(suci, minlen = 108, maxlen = 108),
|
||||
"calculated SUCI (%s) is not a valid hex string or has a wrong length (%u)" %
|
||||
(suci, len(suci)))
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
34
tests/pySim-shell_test/get_identity/test.script
Normal file
34
tests/pySim-shell_test/get_identity/test.script
Normal file
@@ -0,0 +1,34 @@
|
||||
set debug true
|
||||
set echo true
|
||||
|
||||
# This test requires a sysmoISIM-SJA5 with S17 chip variant. The file DF.SAIP/EF.SUCI_Calc_Info has the same format
|
||||
# as DF.5GS/EF.SUCI_Calc_Info, but its location is propritary. The contents of this file are accessed only by the card
|
||||
# OS to calculate the SUCI, not by the UE (see also sysmoISIM-SJA5 User Manual, section 3.5.1)
|
||||
|
||||
# Create a backup the files we will modify
|
||||
export --filename MF/ADF.USIM/DF.SAIP/EF.SUCI_Calc_Info > restore_ef_suci_calc_info.script.tmp
|
||||
export --filename MF/ADF.USIM/DF.5GS/EF.Routing_Indicator > restore_ef_routing_indicator.script.tmp
|
||||
export --filename MF/ADF.USIM/EF.UST > restore_ef_ust.script.tmp
|
||||
|
||||
# Program SUCI calc info (see also 3GPP TS 31.121, section 4.9.4)
|
||||
select MF/ADF.USIM/DF.SAIP/EF.SUCI_Calc_Info
|
||||
update_binary_decoded '{ "prot_scheme_id_list": [ {"priority": 0, "identifier": 2, "key_index": 1}, {"priority": 1, "identifier": 1, "key_index": 2}, {"priority": 2, "identifier": 0, "key_index": 0}], "hnet_pubkey_list": [ {"hnet_pubkey_identifier": 27, "hnet_pubkey": "0472DA71976234CE833A6907425867B82E074D44EF907DFB4B3E21C1C2256EBCD15A7DED52FCBB097A4ED250E036C7B9C8C7004C4EEDC4F068CD7BF8D3F900E3B4"}, {"hnet_pubkey_identifier": 30, "hnet_pubkey": "5A8D38864820197C3394B92613B20B91633CBD897119273BF8E4A6F4EEC0A650"}]}'
|
||||
|
||||
# Set routing indicator (see also 3GPP TS 31.102, section 4.4.11.11)
|
||||
select MF/ADF.USIM/DF.5GS/EF.Routing_Indicator
|
||||
update_binary 17ffffff
|
||||
|
||||
# Enable services (see also 3GPP TS 31.102, section 5.3.48)
|
||||
select MF/ADF.USIM/EF.UST
|
||||
ust_service_activate 124
|
||||
ust_service_activate 125
|
||||
|
||||
# Calculate SUCI (see also 3GPP TS 31.102, section 7.5)
|
||||
select ADF.USIM
|
||||
get_identity > suci.tmp
|
||||
|
||||
# Restore modified files to their original state
|
||||
run_script restore_ef_suci_calc_info.script.tmp
|
||||
run_script restore_ef_routing_indicator.script.tmp
|
||||
run_script restore_ef_ust.script.tmp
|
||||
|
||||
Reference in New Issue
Block a user