mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-17 02:48: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/authenticate/__init__.py
Normal file
0
tests/pySim-shell_test/authenticate/__init__.py
Normal file
8
tests/pySim-shell_test/authenticate/auth_result.ok
Normal file
8
tests/pySim-shell_test/authenticate/auth_result.ok
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"successful_3g_authentication": {
|
||||
"res": "13484811d553ab35",
|
||||
"ck": "0f93c4807f4ff57c6cd348fea590c06d",
|
||||
"ik": "608e7bff4856c73e363e795b165a4158",
|
||||
"kc": "35f08eda84d3b377"
|
||||
}
|
||||
}
|
||||
34
tests/pySim-shell_test/authenticate/test.py
Normal file
34
tests/pySim-shell_test/authenticate/test.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# 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(self):
|
||||
cardname = 'sysmoISIM-SJA5-S17'
|
||||
|
||||
# Perform authentication
|
||||
self.runPySimShell(cardname, "test.script", add_adm = True)
|
||||
self.assertEqualFiles("auth_result.tmp")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
23
tests/pySim-shell_test/authenticate/test.script
Normal file
23
tests/pySim-shell_test/authenticate/test.script
Normal file
@@ -0,0 +1,23 @@
|
||||
set debug true
|
||||
set echo true
|
||||
|
||||
# Create a backup the files we will modify
|
||||
export --filename MF/ADF.USIM/EF.USIM_SQN > restore_ef_usim_sqn.script.tmp
|
||||
export --filename MF/ADF.USIM/EF.USIM_AUTH_KEY > restore_ef_usim_auth_key.script.tmp
|
||||
|
||||
# Write known configuration with KI and OPc value
|
||||
select MF/ADF.USIM/EF.USIM_AUTH_KEY
|
||||
update_binary 0456c3a6da347ae7e43c69d37576725d81e0012b514f84eca9bfd6182bee345e2cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
|
||||
# Reset SQN counter
|
||||
select MF/ADF.USIM/EF.USIM_SQN
|
||||
update_binary d503000200000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
|
||||
# Perform authentication
|
||||
select ADF.USIM
|
||||
authenticate e85b2b7fe58f0e6239b32543d3e3259a 7928ea47ae090000ca8ab1f93c7cb03a > auth_result.tmp
|
||||
|
||||
# Restore modified files to their original state
|
||||
run_script restore_ef_usim_sqn.script.tmp
|
||||
run_script restore_ef_usim_auth_key.script.tmp
|
||||
|
||||
Reference in New Issue
Block a user