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:
@@ -36,6 +36,9 @@ case "$JOB_TYPE" in
|
|||||||
|
|
||||||
# Run pySim-trace test
|
# Run pySim-trace test
|
||||||
tests/pySim-trace_test/pySim-trace_test.sh
|
tests/pySim-trace_test/pySim-trace_test.sh
|
||||||
|
|
||||||
|
# Run pySim-shell integration tests (requires physical cards)
|
||||||
|
python3 -m unittest discover -v -s ./tests/pySim-shell_test/
|
||||||
;;
|
;;
|
||||||
"distcheck")
|
"distcheck")
|
||||||
virtualenv -p python3 venv --system-site-packages
|
virtualenv -p python3 venv --system-site-packages
|
||||||
|
|||||||
107
tests/pySim-shell_test/README.txt
Normal file
107
tests/pySim-shell_test/README.txt
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
Integration Testsuite for pySim-shell
|
||||||
|
=====================================
|
||||||
|
|
||||||
|
The testsuite presented here is build on python's unittest framework, which is
|
||||||
|
extended via a UnittestUtils class, which can be found in utils.py. This class
|
||||||
|
contains methods to execute pySim-shell, compare files, load file contents,
|
||||||
|
generate pySim-shell scripts from templates, etc. It also cares about managing
|
||||||
|
the cards and their related data (ICCIDs, ADM pins, keys, etc.)
|
||||||
|
|
||||||
|
Each testcase has its own subdirectory and can be executed separately. The sub
|
||||||
|
directory of each testcase usually contains a single python script (test.py),
|
||||||
|
one or more pySim-shell scripts or templates and also one or more .ok files.
|
||||||
|
The .ok files are auto-generated using a known-to-work version of pySim-shell
|
||||||
|
and can be re-generated at any-time if required.
|
||||||
|
|
||||||
|
This testsuite is designed to be executed automatically on a build sever, but
|
||||||
|
it can also be executed on a developer workstation.
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
The testsuite is executes pySim-shell on physical cards. This means all card
|
||||||
|
models for which the tests were written must be physially present in PCSC
|
||||||
|
readers.
|
||||||
|
|
||||||
|
(see `config.yaml` for which card models are required)
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
|
The card models, which are present in the testsuite are set up via
|
||||||
|
`config.yaml`. All cards are listed by their model ´name´, ´atr´ and ´iccid´
|
||||||
|
(or eid for eUICCs). The testsuite user should not add or remove models. The
|
||||||
|
only change that is required is to adjust the iccid and eid fields so that they
|
||||||
|
match the values of the cards that are used for the test.
|
||||||
|
|
||||||
|
Card data, such as ADM, PIN1, PIN2, etc. are configured in ´card_data.csv´. This
|
||||||
|
file is used with the --csv parameter of pySim-shell. The format is described
|
||||||
|
in the osmopysim-usermanual. Each card configured in ´config.yaml´ has a
|
||||||
|
coresponding entry in ´card_data.csv´. The entries are connected via either
|
||||||
|
the ´iccid´ or the eid as ´key´. Like with ´config.yaml´, the testsuite user
|
||||||
|
must adjust the values, so that they match the actual cards.
|
||||||
|
|
||||||
|
The file card_data.csv is also read by the testsuite, so that all contained
|
||||||
|
fields are also available to the testcases.
|
||||||
|
|
||||||
|
Data collection
|
||||||
|
---------------
|
||||||
|
|
||||||
|
On startup, the testsuite will check the presence of each card configured in
|
||||||
|
´config.yaml´. While doing that, the PCSC reader number is determined. Then it
|
||||||
|
will use either the ´iccid´ or the ´eid´ to fetch the card data from
|
||||||
|
card_data.csv.
|
||||||
|
|
||||||
|
All information, that is gathered during the startup procedure is collected
|
||||||
|
in a dict that is available to the testcase. The testsuite will list all cards
|
||||||
|
and their related information on startup.
|
||||||
|
|
||||||
|
Running
|
||||||
|
-------
|
||||||
|
|
||||||
|
Testcases are implemented as python unittests and the execution of the testcases
|
||||||
|
is no different from the execution of other python unittests.
|
||||||
|
|
||||||
|
To run all tests, run the following command line from the top directory of the
|
||||||
|
pySim repository:
|
||||||
|
|
||||||
|
```
|
||||||
|
python3 -m unittest discover ./tests/pySim-shell_test/
|
||||||
|
```
|
||||||
|
|
||||||
|
It is also possible to run a specific test only:
|
||||||
|
```
|
||||||
|
python3 -m unittest discover -k export_fs ./tests/pySim-shell_test
|
||||||
|
```
|
||||||
|
|
||||||
|
Regenerating .ok files
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
The testsuite ships with a set of .ok files. Those files are used to compare
|
||||||
|
the output of certain pySim-shell commands. In case the .ok files contain card
|
||||||
|
specific data (IMSI values, ICCID values, etc.) the comparison happens in such
|
||||||
|
a way that this data is ignored. This means a card with a different IMSI,
|
||||||
|
ICCID, Ki etc. should work with the included .ok files. However, there may be
|
||||||
|
changes in the code or in the file system structure that may cause a certain
|
||||||
|
testcase to fial anyway. In this case a regeneration of the .ok files may be
|
||||||
|
necessary.
|
||||||
|
|
||||||
|
To instruct the testsuite to regenerate all .ok files, change the ´regenerate´
|
||||||
|
field in config.yaml to True and run the testsuite once. The testsuite will then
|
||||||
|
overwrite the .ok files with the output it got from pySim-shell. When the
|
||||||
|
testcase execution is done, the regenerate field must be set back to False and
|
||||||
|
the new content of the .ok files must be reviewed.
|
||||||
|
|
||||||
|
Keeping temporary files
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
During development of new testcases or for debugging, it can be helpful not to
|
||||||
|
delete all temporary files after a test run. To keep the temporary files, the
|
||||||
|
´keepfiles´ field in config.yaml can be set to True.
|
||||||
|
|
||||||
|
Printing file contents
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
To locate testcase failures more easily, the user has the option to display the
|
||||||
|
content of files that are compared or loaded from a testcase. To display the
|
||||||
|
file contents, set the field ´print_content´ in config.yaml to true
|
||||||
0
tests/pySim-shell_test/__init__.py
Normal file
0
tests/pySim-shell_test/__init__.py
Normal file
0
tests/pySim-shell_test/ara_m/__init__.py
Normal file
0
tests/pySim-shell_test/ara_m/__init__.py
Normal file
152
tests/pySim-shell_test/ara_m/adf_ara-m.cfg.ok
Normal file
152
tests/pySim-shell_test/ara_m/adf_ara-m.cfg.ok
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"response_all_ref_ar_do": [
|
||||||
|
{
|
||||||
|
"ref_ar_do": [
|
||||||
|
{
|
||||||
|
"ref_do": [
|
||||||
|
{
|
||||||
|
"aid_ref_do": "ffffffffffaa"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dev_app_id_ref_do": "aa6872787654334567840de535c2bbd5a04f0baa"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ar_do": [
|
||||||
|
{
|
||||||
|
"apdu_ar_do": {
|
||||||
|
"generic_access_rule": "never"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nfc_ar_do": {
|
||||||
|
"nfc_event_access_rule": "never"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"perm_ar_do": {
|
||||||
|
"permissions": "0000000000000004"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ref_ar_do": [
|
||||||
|
{
|
||||||
|
"ref_do": [
|
||||||
|
{
|
||||||
|
"aid_ref_do": "ffffffffffbb"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dev_app_id_ref_do": "aa6872f28b340b2345678905d5c2bbd5a04f0bdd"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ar_do": [
|
||||||
|
{
|
||||||
|
"apdu_ar_do": {
|
||||||
|
"generic_access_rule": "always"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nfc_ar_do": {
|
||||||
|
"nfc_event_access_rule": "always"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"perm_ar_do": {
|
||||||
|
"permissions": "0000000000000004"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ref_ar_do": [
|
||||||
|
{
|
||||||
|
"ref_do": [
|
||||||
|
{
|
||||||
|
"aid_ref_do": "ffffffffffcc"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dev_app_id_ref_do": "a1234567890aaabb1f140de987657891a04f0bdd"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ar_do": [
|
||||||
|
{
|
||||||
|
"apdu_ar_do": {
|
||||||
|
"apdu_filter": [
|
||||||
|
{
|
||||||
|
"header": "aabbccdd",
|
||||||
|
"mask": "01020304"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nfc_ar_do": {
|
||||||
|
"nfc_event_access_rule": "always"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"perm_ar_do": {
|
||||||
|
"permissions": "0000000000000004"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ref_ar_do": [
|
||||||
|
{
|
||||||
|
"ref_do": [
|
||||||
|
{
|
||||||
|
"aid_ref_do": "ffffffffffdd"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dev_app_id_ref_do": "a1234567890123bb1f140de987aaa891bbbf0bdd"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ar_do": [
|
||||||
|
{
|
||||||
|
"apdu_ar_do": {
|
||||||
|
"apdu_filter": [
|
||||||
|
{
|
||||||
|
"header": "aabbccdd",
|
||||||
|
"mask": "01020304"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"header": "11223344",
|
||||||
|
"mask": "05060708"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nfc_ar_do": {
|
||||||
|
"nfc_event_access_rule": "never"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"perm_ar_do": {
|
||||||
|
"permissions": "0000000000000004"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
20
tests/pySim-shell_test/ara_m/adf_ara-m.script.ok
Normal file
20
tests/pySim-shell_test/ara_m/adf_ara-m.script.ok
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
################################################################################
|
||||||
|
# MF/ADF.ARA-M #
|
||||||
|
################################################################################
|
||||||
|
# directory: MF/ADF.ARA-M (3f00/a00000015141434c00)
|
||||||
|
# file: ADF.ARA-M (None)
|
||||||
|
# RAW FCP Template: None
|
||||||
|
# Decoded FCP Template: None
|
||||||
|
select MF/ADF.ARA-M
|
||||||
|
aram_delete_all
|
||||||
|
aram_store_ref_ar_do --aid ffffffffffdd --device-app-id a1234567890123bb1f140de987aaa891bbbf0bdd --apdu-filter aabbccdd010203041122334405060708 --nfc-never --android-permissions 0000000000000004
|
||||||
|
aram_store_ref_ar_do --aid ffffffffffcc --device-app-id a1234567890aaabb1f140de987657891a04f0bdd --apdu-filter aabbccdd01020304 --nfc-always --android-permissions 0000000000000004
|
||||||
|
aram_store_ref_ar_do --aid ffffffffffbb --device-app-id aa6872f28b340b2345678905d5c2bbd5a04f0bdd --apdu-always --nfc-always --android-permissions 0000000000000004
|
||||||
|
aram_store_ref_ar_do --aid ffffffffffaa --device-app-id aa6872787654334567840de535c2bbd5a04f0baa --apdu-never --nfc-never --android-permissions 0000000000000004
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
# Export summary #
|
||||||
|
################################################################################
|
||||||
|
# total files visited: 1
|
||||||
|
# bad files: 0
|
||||||
|
# skipped dedicated files(s): 0
|
||||||
5
tests/pySim-shell_test/ara_m/adf_ara-m_empty.cfg.ok
Normal file
5
tests/pySim-shell_test/ara_m/adf_ara-m_empty.cfg.ok
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"response_all_ref_ar_do": null
|
||||||
|
}
|
||||||
|
]
|
||||||
35
tests/pySim-shell_test/ara_m/test.py
Normal file
35
tests/pySim-shell_test/ara_m/test.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# 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'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test.script")
|
||||||
|
self.assertEqualFiles("adf_ara-m.script.tmp")
|
||||||
|
self.assertEqualFiles("adf_ara-m.cfg.tmp")
|
||||||
|
self.assertEqualFiles("adf_ara-m_empty.cfg.tmp")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
31
tests/pySim-shell_test/ara_m/test.script
Normal file
31
tests/pySim-shell_test/ara_m/test.script
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Export existing ARA-M configuration
|
||||||
|
export --filename ADF.ARA-M > restore_adf_ara_m.script.tmp
|
||||||
|
|
||||||
|
# Create a known config in ADF.ARA-M
|
||||||
|
select ADF.ARA-M
|
||||||
|
aram_delete_all
|
||||||
|
aram_store_ref_ar_do --aid ffffffffffaa --device-app-id aa6872787654334567840de535c2bbd5a04f0baa --apdu-never --nfc-never --android-permissions 0000000000000004
|
||||||
|
aram_store_ref_ar_do --aid ffffffffffbb --device-app-id aa6872f28b340b2345678905d5c2bbd5a04f0bdd --apdu-always --nfc-always --android-permissions 0000000000000004
|
||||||
|
aram_store_ref_ar_do --aid ffffffffffcc --device-app-id a1234567890aaabb1f140de987657891a04f0bdd --apdu-filter aabbccdd01020304 --nfc-always --android-permissions 0000000000000004
|
||||||
|
aram_store_ref_ar_do --aid ffffffffffdd --device-app-id a1234567890123bb1f140de987aaa891bbbf0bdd --apdu-filter aabbccdd010203041122334405060708 --nfc-never --android-permissions 0000000000000004
|
||||||
|
|
||||||
|
# Export ADF.ARA-M to a temporary script file
|
||||||
|
export --filename ADF.ARA-M > adf_ara-m.script.tmp
|
||||||
|
|
||||||
|
# Ensure ADF.ARA-M is empty
|
||||||
|
aram_delete_all
|
||||||
|
|
||||||
|
# Check that ADF.ARA-M is empty
|
||||||
|
aram_get_all > adf_ara-m_empty.cfg.tmp
|
||||||
|
|
||||||
|
# Run the temporary script file to restore ADF.ARA-M again
|
||||||
|
run_script adf_ara-m.script.tmp
|
||||||
|
|
||||||
|
# Read out ADF.ARA-M using aram_get_all
|
||||||
|
aram_get_all > adf_ara-m.cfg.tmp
|
||||||
|
|
||||||
|
# Restore ARA-M configuration to its original state
|
||||||
|
run_script restore_adf_ara_m.script.tmp
|
||||||
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
|
||||||
|
|
||||||
5
tests/pySim-shell_test/card_data.csv
Normal file
5
tests/pySim-shell_test/card_data.csv
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
eid,iccid,adm1,pin1,puk1,SCP02_DEK_1,SCP02_ENC_1,SCP02_MAC_1,SCP03_DEK_1,SCP03_ENC_1,SCP03_MAC_1
|
||||||
|
0,8949440000001155314,34173960,0000,15091909,FFB53E96E5FF99731D51AD7BEAFD0E23,51D4FC44BCBA7C4589DFADA3297720AF,0449699C472CE71E2FB7B56245EF7684,0,0,0
|
||||||
|
0,8988211000000467343,67225880,5563,42936344,AD1AF0EC5643FFD4986F0F00A48FF244,112788F75D15F678F51A8EB606766B16,02A6FC022F8F871611237F2A9FC72315,0,0,0
|
||||||
|
89049044900000000000000000102355,0,0,0,0,0,0,0,9b3bf6fda1bc88d9bd6083bb704243f920702a9bd744a484482049ebdab40ef3,67230241fd09e4ff46f4b4db3450dd839bf8b545bdd70199ac2a7788e87e2243,f80f4a71f6dbf7eca8cdc18a9c65c59abdd07e3da74b1c48e106954d76cb793f
|
||||||
|
0,2222334455667788990,0,0,0,0,0,0,0,0,0
|
||||||
|
0
tests/pySim-shell_test/cardinfo/__init__.py
Normal file
0
tests/pySim-shell_test/cardinfo/__init__.py
Normal file
13
tests/pySim-shell_test/cardinfo/sysmoEUICC1-C2T-cardinfo.ok
Normal file
13
tests/pySim-shell_test/cardinfo/sysmoEUICC1-C2T-cardinfo.ok
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
Card info:
|
||||||
|
Name: UICC
|
||||||
|
ATR: 3b9f96803f87828031e073fe211f574543753130136502
|
||||||
|
EID: 89049044900000000000000000102355
|
||||||
|
ICCID: 89000123456789012341
|
||||||
|
Class-Byte: 00
|
||||||
|
Select-Ctrl: 0004
|
||||||
|
AIDs:
|
||||||
|
a0000000871002
|
||||||
|
a0000000871004
|
||||||
|
a0000005591010ffffffff8900000200
|
||||||
|
a0000005591010ffffffff8900000100
|
||||||
|
a00000015141434c00
|
||||||
11
tests/pySim-shell_test/cardinfo/sysmoISIM-SJA2-cardinfo.ok
Normal file
11
tests/pySim-shell_test/cardinfo/sysmoISIM-SJA2-cardinfo.ok
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
Card info:
|
||||||
|
Name: UICC
|
||||||
|
ATR: 3b9f96801f878031e073fe211b674a4c753034054ba9
|
||||||
|
ICCID: 8988211000000467343
|
||||||
|
Class-Byte: 00
|
||||||
|
Select-Ctrl: 0004
|
||||||
|
AIDs:
|
||||||
|
a0000000871002
|
||||||
|
a0000000871004
|
||||||
|
a000000003000000
|
||||||
|
a00000015141434c00
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
Card info:
|
||||||
|
Name: UICC
|
||||||
|
ATR: 3b9f96801f878031e073fe211b674a357530350265f8
|
||||||
|
ICCID: 8949440000001155314
|
||||||
|
Class-Byte: 00
|
||||||
|
Select-Ctrl: 0004
|
||||||
|
AIDs:
|
||||||
|
a0000000871002
|
||||||
|
a0000000871004
|
||||||
|
a000000003000000
|
||||||
|
a00000015141434c00
|
||||||
6
tests/pySim-shell_test/cardinfo/sysmoSIM-GR1-cardinfo.ok
Normal file
6
tests/pySim-shell_test/cardinfo/sysmoSIM-GR1-cardinfo.ok
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
Card info:
|
||||||
|
Name: SIM
|
||||||
|
ATR: 3b991800118822334455667760
|
||||||
|
ICCID: 2222334455667788990
|
||||||
|
Class-Byte: a0
|
||||||
|
Select-Ctrl: 0000
|
||||||
36
tests/pySim-shell_test/cardinfo/test.py
Normal file
36
tests/pySim-shell_test/cardinfo/test.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# 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):
|
||||||
|
for cardname in self.cards:
|
||||||
|
self.equipTemplate("test.script", CARDNAME=cardname)
|
||||||
|
self.runPySimShell(cardname, "test.script")
|
||||||
|
self.assertEqualFiles(cardname + "-cardinfo.tmp",
|
||||||
|
mask_regex_list = [' [A-Fa-f0-9]*$'],
|
||||||
|
interesting_regex_list = ['^ a0.*', '^ ATR.*', '^ Cla.*', '^ Sel.*'])
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
5
tests/pySim-shell_test/cardinfo/test.template
Normal file
5
tests/pySim-shell_test/cardinfo/test.template
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Export the entire file system
|
||||||
|
cardinfo > $CARDNAME-cardinfo.tmp
|
||||||
0
tests/pySim-shell_test/chv/__init__.py
Normal file
0
tests/pySim-shell_test/chv/__init__.py
Normal file
61
tests/pySim-shell_test/chv/test.py
Normal file
61
tests/pySim-shell_test/chv/test.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# 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_manage(self):
|
||||||
|
cardname = 'sysmoISIM-SJA5-S17'
|
||||||
|
pin1 = self.cards[cardname]['pin1']
|
||||||
|
puk1 = self.cards[cardname]['puk1']
|
||||||
|
|
||||||
|
# Provide PIN via commandline directly
|
||||||
|
self.equipTemplate("test_manage_direct.script", PIN1=pin1)
|
||||||
|
self.runPySimShell(cardname, "test_manage_direct.script")
|
||||||
|
self.assertEqualFiles("test_manage_direct.tmp")
|
||||||
|
os.remove("test_manage_direct.script")
|
||||||
|
|
||||||
|
# Provide PIN via CSV file (CardKeyProvider)
|
||||||
|
self.equipTemplate("test_manage_csv.script", PIN1=pin1)
|
||||||
|
self.runPySimShell(cardname, "test_manage_csv.script", add_csv = True)
|
||||||
|
ignore_regex_list = ['\'[A-Fa-f0-9]*\''] # do not compare the actual PIN and ICCID values echoed by the commands
|
||||||
|
self.assertEqualFiles("test_manage_csv.tmp",
|
||||||
|
ignore_regex_list=ignore_regex_list)
|
||||||
|
|
||||||
|
def test_unblock(self):
|
||||||
|
cardname = 'sysmoISIM-SJA5-S17'
|
||||||
|
pin1 = self.cards[cardname]['pin1']
|
||||||
|
puk1 = self.cards[cardname]['puk1']
|
||||||
|
|
||||||
|
# Provide PIN via commandline directly
|
||||||
|
self.equipTemplate("test_unblock_direct.script", PIN1=pin1, PUK1=puk1)
|
||||||
|
self.runPySimShell(cardname, "test_unblock_direct.script")
|
||||||
|
self.assertEqualFiles("test_unblock_direct.tmp")
|
||||||
|
|
||||||
|
# Provide PIN via CSV file (CardKeyProvider)
|
||||||
|
self.runPySimShell(cardname, "test_unblock_csv.script", add_csv = True)
|
||||||
|
ignore_regex_list = ['\'[A-Fa-f0-9]*\''] # do not compare the actual PIN and ICCID values echoed by the commands
|
||||||
|
self.assertEqualFiles("test_unblock_csv.tmp",
|
||||||
|
ignore_regex_list=ignore_regex_list)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
10
tests/pySim-shell_test/chv/test_manage_csv.ok
Normal file
10
tests/pySim-shell_test/chv/test_manage_csv.ok
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
found PIN1 '30303030ffffffff' for ICCID '8949440000001155314'
|
||||||
|
CHV enable successful
|
||||||
|
found PIN1 '30303030ffffffff' for ICCID '8949440000001155314'
|
||||||
|
CHV verification successful
|
||||||
|
found PIN1 '30303030ffffffff' for ICCID '8949440000001155314'
|
||||||
|
CHV change successful
|
||||||
|
CHV verification successful
|
||||||
|
CHV change successful
|
||||||
|
found PIN1 '30303030ffffffff' for ICCID '8949440000001155314'
|
||||||
|
CHV disable successful
|
||||||
26
tests/pySim-shell_test/chv/test_manage_csv.template
Normal file
26
tests/pySim-shell_test/chv/test_manage_csv.template
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Enable PIN1
|
||||||
|
enable_chv > test_manage_csv.tmp
|
||||||
|
reset
|
||||||
|
|
||||||
|
# Verify PIN1
|
||||||
|
verify_chv >> test_manage_csv.tmp
|
||||||
|
reset
|
||||||
|
|
||||||
|
# Change PIN1 to some arbitrary value
|
||||||
|
change_chv 1234 >> test_manage_csv.tmp
|
||||||
|
reset
|
||||||
|
|
||||||
|
# Verify PIN1
|
||||||
|
verify_chv 1234 >> test_manage_csv.tmp
|
||||||
|
reset
|
||||||
|
|
||||||
|
# Change PIN1 back to its original value
|
||||||
|
change_chv $PIN1 1234 >> test_manage_csv.tmp
|
||||||
|
reset
|
||||||
|
|
||||||
|
# Disable PIN1 again
|
||||||
|
disable_chv >> test_manage_csv.tmp
|
||||||
|
reset
|
||||||
5
tests/pySim-shell_test/chv/test_manage_direct.ok
Normal file
5
tests/pySim-shell_test/chv/test_manage_direct.ok
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
CHV enable successful
|
||||||
|
CHV change successful
|
||||||
|
CHV verification successful
|
||||||
|
CHV change successful
|
||||||
|
CHV disable successful
|
||||||
22
tests/pySim-shell_test/chv/test_manage_direct.template
Normal file
22
tests/pySim-shell_test/chv/test_manage_direct.template
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Enable PIN1
|
||||||
|
enable_chv $PIN1 > test_manage_direct.tmp
|
||||||
|
reset
|
||||||
|
|
||||||
|
# Change PIN1 to some arbitrary value
|
||||||
|
change_chv 1234 $PIN1 >> test_manage_direct.tmp
|
||||||
|
reset
|
||||||
|
|
||||||
|
# Verify PIN1
|
||||||
|
verify_chv 1234 >> test_manage_direct.tmp
|
||||||
|
reset
|
||||||
|
|
||||||
|
# Change PIN1 back to its original value
|
||||||
|
change_chv $PIN1 1234 >> test_manage_direct.tmp
|
||||||
|
reset
|
||||||
|
|
||||||
|
# Disable PIN1 again
|
||||||
|
disable_chv $PIN1 >> test_manage_direct.tmp
|
||||||
|
reset
|
||||||
7
tests/pySim-shell_test/chv/test_unblock_csv.ok
Normal file
7
tests/pySim-shell_test/chv/test_unblock_csv.ok
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
found PIN1 '30303030ffffffff' for ICCID '8949440000001155314'
|
||||||
|
CHV enable successful
|
||||||
|
found PIN1 '30303030ffffffff' for ICCID '8949440000001155314'
|
||||||
|
found PUK1 '3135303931393039' for ICCID '8949440000001155314'
|
||||||
|
CHV unblock successful
|
||||||
|
found PIN1 '30303030ffffffff' for ICCID '8949440000001155314'
|
||||||
|
CHV disable successful
|
||||||
21
tests/pySim-shell_test/chv/test_unblock_csv.script
Normal file
21
tests/pySim-shell_test/chv/test_unblock_csv.script
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Enable PIN1
|
||||||
|
enable_chv > test_unblock_csv.tmp
|
||||||
|
reset
|
||||||
|
|
||||||
|
# Enter the wrong PIN1 more than 3 times to block it (we will see some exceptions, which is normal)
|
||||||
|
verify_chv 2468
|
||||||
|
verify_chv 2468
|
||||||
|
verify_chv 2468
|
||||||
|
verify_chv 2468
|
||||||
|
reset
|
||||||
|
|
||||||
|
# Unblock the PIN again
|
||||||
|
unblock_chv >> test_unblock_csv.tmp
|
||||||
|
reset
|
||||||
|
|
||||||
|
# Disable PIN1
|
||||||
|
disable_chv >> test_unblock_csv.tmp
|
||||||
|
reset
|
||||||
3
tests/pySim-shell_test/chv/test_unblock_direct.ok
Normal file
3
tests/pySim-shell_test/chv/test_unblock_direct.ok
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
CHV enable successful
|
||||||
|
CHV unblock successful
|
||||||
|
CHV disable successful
|
||||||
21
tests/pySim-shell_test/chv/test_unblock_direct.template
Normal file
21
tests/pySim-shell_test/chv/test_unblock_direct.template
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Enable PIN1
|
||||||
|
enable_chv $PIN1 > test_unblock_direct.tmp
|
||||||
|
reset
|
||||||
|
|
||||||
|
# Enter the wrong PIN1 more than 3 times to block it (we will see some exceptions, which is normal)
|
||||||
|
verify_chv 2468
|
||||||
|
verify_chv 2468
|
||||||
|
verify_chv 2468
|
||||||
|
verify_chv 2468
|
||||||
|
reset
|
||||||
|
|
||||||
|
# Unblock the PIN again
|
||||||
|
unblock_chv $PUK1 $PIN1 >> test_unblock_direct.tmp
|
||||||
|
reset
|
||||||
|
|
||||||
|
# Disable PIN1
|
||||||
|
disable_chv $PIN1 >> test_unblock_direct.tmp
|
||||||
|
reset
|
||||||
16
tests/pySim-shell_test/config.yaml
Normal file
16
tests/pySim-shell_test/config.yaml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
regenerate: False
|
||||||
|
keepfiles: False
|
||||||
|
print_content: False
|
||||||
|
cards:
|
||||||
|
- name : "sysmoISIM-SJA5-S17"
|
||||||
|
atr : "3B9F96801F878031E073FE211B674A357530350265F8"
|
||||||
|
iccid : "8949440000001155314"
|
||||||
|
- name : "sysmoISIM-SJA2"
|
||||||
|
atr : "3B9F96801F878031E073FE211B674A4C753034054BA9"
|
||||||
|
iccid : "8988211000000467343"
|
||||||
|
- name : "sysmoEUICC1-C2T"
|
||||||
|
atr : "3B9F96803F87828031E073FE211F574543753130136502"
|
||||||
|
eid : "89049044900000000000000000102355"
|
||||||
|
- name : "sysmoSIM-GR1"
|
||||||
|
atr : "3B991800118822334455667760"
|
||||||
|
iccid : "2222334455667788990"
|
||||||
0
tests/pySim-shell_test/euicc/__init__.py
Normal file
0
tests/pySim-shell_test/euicc/__init__.py
Normal file
12
tests/pySim-shell_test/euicc/enable_disable_profile.ok
Normal file
12
tests/pySim-shell_test/euicc/enable_disable_profile.ok
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"disable_result": "ok"
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"enable_result": "ok"
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"disable_result": "ok"
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"enable_result": "ok"
|
||||||
|
}
|
||||||
9
tests/pySim-shell_test/euicc/euicc_info1.ok
Normal file
9
tests/pySim-shell_test/euicc/euicc_info1.ok
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"svn": "2.3.0",
|
||||||
|
"euicc_ci_pki_list_for_verification": {
|
||||||
|
"subject_key_identifier": "f54172bdf98a95d65cbeb88a38a1c11d800a85c3"
|
||||||
|
},
|
||||||
|
"euicc_ci_pki_list_for_signing": {
|
||||||
|
"subject_key_identifier": "f54172bdf98a95d65cbeb88a38a1c11d800a85c3"
|
||||||
|
}
|
||||||
|
}
|
||||||
21
tests/pySim-shell_test/euicc/euicc_info2.ok
Normal file
21
tests/pySim-shell_test/euicc/euicc_info2.ok
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"profile_version": "2.3.1",
|
||||||
|
"svn": "2.3.0",
|
||||||
|
"euicc_firmware_ver": "35.6.35",
|
||||||
|
"ext_card_resource": "810108820400045bf883022419",
|
||||||
|
"uicc_capability": "067f36f3c0",
|
||||||
|
"ts102241_version": "15.1.0",
|
||||||
|
"global_platform_version": "2.3.0",
|
||||||
|
"rsp_capability": "0398",
|
||||||
|
"euicc_ci_pki_list_for_verification": {
|
||||||
|
"subject_key_identifier": "f54172bdf98a95d65cbeb88a38a1c11d800a85c3"
|
||||||
|
},
|
||||||
|
"euicc_ci_pki_list_for_signing": {
|
||||||
|
"subject_key_identifier": "f54172bdf98a95d65cbeb88a38a1c11d800a85c3"
|
||||||
|
},
|
||||||
|
"unknown_ber_tlv_ie_99": {
|
||||||
|
"raw": "0640"
|
||||||
|
},
|
||||||
|
"pp_version": "1.0.0",
|
||||||
|
"ss_acreditation_number": "SYSMOCOM-TEST-1"
|
||||||
|
}
|
||||||
3
tests/pySim-shell_test/euicc/get_eid.ok
Normal file
3
tests/pySim-shell_test/euicc/get_eid.ok
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"eid_value": "89049044900000000000000000102355"
|
||||||
|
}
|
||||||
27
tests/pySim-shell_test/euicc/get_profiles_info.ok
Normal file
27
tests/pySim-shell_test/euicc/get_profiles_info.ok
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"profile_info_seq": [
|
||||||
|
{
|
||||||
|
"profile_info": {
|
||||||
|
"iccid": "89000123456789012341",
|
||||||
|
"isdp_aid": "a0000005591010ffffffff8900001000",
|
||||||
|
"profile_state": "enabled",
|
||||||
|
"profile_nickname": "this-is-a-testprofile",
|
||||||
|
"service_provider_name": "SP Name 1",
|
||||||
|
"profile_name": "Operational Profile Name 1",
|
||||||
|
"icon_type": "png",
|
||||||
|
"icon": "89504e470d0a1a0a0000000d49484452000000400000004008040000000060b9550000000774494d4507e00b091007364c956f97000000097048597300000b1200000b1201d2dd7efc0000000467414d410000b18f0bfc61050000021f4944415478daed99cd1583200c803d32000b3004abb00ecbb0822338578af559223f49b0a8175f2ec023e1238410db09a667e5e1e55f80bf00f686060b1e66b80420c02a32550d0e966e8cc6f0128d193460635fa66a3b7d511db48dd94788b655d7815071ba26e61b9000acc711841085eb398d84c0cd94f921ebe2ddab18db6b5005b055c3bc752b4038745c5339449cd4950248100e1d4528fac207b228e3101a4bd4ae52ba96a603808b05d44c27adab2af8807a00a6184b228014807566eca13538e5008ac890bf06be809e4dbebe0b808a842a009ffd7b010436af06b04f034c8d47ea46004703e034e4d95b90a98a447300dc353c9f07a843404d9b2d904bca84f62480a7013c39351431225b722de9f6ad591a0047c194e5ae19bd865afc1a26976f088603c0a7ac9117fce131f64200bcdfed8e290ee058906c46f2fad09dac885ab1550c68d2a8b426dcf69b8e71f76d195b15cd368207463513fd2dea6648476b2500eb999b6250fa5dc0499e0b88b921f2bbaf782e877588930370724e4d3f0dd01d49dbe7e92cb940423172008f3ed3c6011c03b1396bce6ec24800c703b862682480a20142250b8c05c081385186cd65009607d059dd772b80ae3cb963010205b054436414808abb0ff237752480a996fb3702d8334fda0bf002bc002fc0488053b5f5380005dc0a1703f03ffdfdc433a6fa010cf1ef4165c831e602b40134844c66e67fa4c1000618e5ab8f6008c03faab7028c9117e0036baf44917035af0e0000000049454e44ae426082",
|
||||||
|
"profile_class": "test"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"profile_info": {
|
||||||
|
"iccid": "8949449999999990031f",
|
||||||
|
"isdp_aid": "a0000005591010ffffffff8900001200",
|
||||||
|
"profile_state": "disabled",
|
||||||
|
"service_provider_name": "OsmocomSPN",
|
||||||
|
"profile_name": "TS48V1-B-UNIQUE",
|
||||||
|
"profile_class": "operational"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
3
tests/pySim-shell_test/euicc/notifications.ok
Normal file
3
tests/pySim-shell_test/euicc/notifications.ok
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"notification_metadata_list": null
|
||||||
|
}
|
||||||
3
tests/pySim-shell_test/euicc/set_nickname.ok
Normal file
3
tests/pySim-shell_test/euicc/set_nickname.ok
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"set_nickname_result": "ok"
|
||||||
|
}
|
||||||
95
tests/pySim-shell_test/euicc/test.py
Normal file
95
tests/pySim-shell_test/euicc/test.py
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
# 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
|
||||||
|
import json
|
||||||
|
from utils import *
|
||||||
|
|
||||||
|
# This testcase requires a sysmoEUICC1-C2T with the test prfile TS48V1-B-UNIQUE (ICCID 8949449999999990031f)
|
||||||
|
# installed, and in disabled state. Also the profile must be installed in such a way that notifications are
|
||||||
|
# generated when the profile is disabled or enabled (ProfileMetadata)
|
||||||
|
|
||||||
|
class test_case(UnittestUtils):
|
||||||
|
def test_get_eid(self):
|
||||||
|
cardname = 'sysmoEUICC1-C2T'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_get_eid.script")
|
||||||
|
self.assertEqualFiles("get_eid.tmp",
|
||||||
|
ignore_regex_list=['\"[A-Fa-f0-9]*\"'])
|
||||||
|
|
||||||
|
def test_get_euicc_info(self):
|
||||||
|
cardname = 'sysmoEUICC1-C2T'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_get_euicc_info.script")
|
||||||
|
self.assertEqualFiles("euicc_info1.tmp",
|
||||||
|
ignore_regex_list=[': \".*"'])
|
||||||
|
self.assertEqualFiles("euicc_info2.tmp", "euicc_info2.ok",
|
||||||
|
ignore_regex_list=[': \".*"'])
|
||||||
|
|
||||||
|
def test_get_profiles_info(self):
|
||||||
|
cardname = 'sysmoEUICC1-C2T'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_get_profiles_info.script")
|
||||||
|
self.assertEqualFiles("get_profiles_info.tmp")
|
||||||
|
|
||||||
|
def test_enable_disable_profile(self):
|
||||||
|
cardname = 'sysmoEUICC1-C2T'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_enable_disable_profile.script")
|
||||||
|
self.assertEqualFiles("enable_disable_profile.tmp")
|
||||||
|
|
||||||
|
def test_enable_disable_profile(self):
|
||||||
|
cardname = 'sysmoEUICC1-C2T'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_set_nickname.script")
|
||||||
|
self.assertEqualFiles("set_nickname.tmp")
|
||||||
|
|
||||||
|
def test_list_and_rm_notif(self):
|
||||||
|
cardname = 'sysmoEUICC1-C2T'
|
||||||
|
|
||||||
|
# Generate two (additional) notification
|
||||||
|
self.runPySimShell(cardname, "test_gen_notif.script")
|
||||||
|
|
||||||
|
# List notifications into a file
|
||||||
|
self.runPySimShell(cardname, "test_list_notif.script")
|
||||||
|
|
||||||
|
# Parse notifications file (JSON)
|
||||||
|
notifications_tmp = open("notifications.tmp")
|
||||||
|
notifications = json.load(notifications_tmp)
|
||||||
|
notifications_tmp.close()
|
||||||
|
|
||||||
|
# Delete notifications one by one, we expect to see at least one notification
|
||||||
|
notification_metadata_list = notifications['notification_metadata_list']
|
||||||
|
removed = 0
|
||||||
|
for nm in notification_metadata_list:
|
||||||
|
seq_number = nm['notification_metadata']['seq_number']
|
||||||
|
print("removing notification with seq_number %s:" % seq_number)
|
||||||
|
self.equipTemplate("test_rm_notif.script", SEQ_NUMBER = seq_number)
|
||||||
|
self.runPySimShell(cardname, "test_rm_notif.script")
|
||||||
|
removed = removed + 1
|
||||||
|
self.assertTrue(removed >= 2, "we expected to remove at least two notifications, but we have removed none!")
|
||||||
|
|
||||||
|
# List notifications again, require none to be present
|
||||||
|
self.runPySimShell(cardname, "test_list_notif.script")
|
||||||
|
self.assertEqualFiles("notifications.tmp")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
select ADF.ISD-R
|
||||||
|
|
||||||
|
# by ICCID (pre-installed test profile on sysmoEUICC1-C2T)
|
||||||
|
disable_profile --iccid 89000123456789012341 > enable_disable_profile.tmp
|
||||||
|
enable_profile --iccid 89000123456789012341 >> enable_disable_profile.tmp
|
||||||
|
|
||||||
|
# by ISDP AID (pre-installed test profile on sysmoEUICC1-C2T)
|
||||||
|
disable_profile --isdp-aid a0000005591010ffffffff8900001000 >> enable_disable_profile.tmp
|
||||||
|
enable_profile --isdp-aid a0000005591010ffffffff8900001000 >> enable_disable_profile.tmp
|
||||||
8
tests/pySim-shell_test/euicc/test_gen_notif.script
Normal file
8
tests/pySim-shell_test/euicc/test_gen_notif.script
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
select ADF.ISD-R
|
||||||
|
|
||||||
|
# Generate two (additional) notifications by quickly enabeling the test profile
|
||||||
|
enable_profile --iccid 8949449999999990031f
|
||||||
|
enable_profile --iccid 89000123456789012341
|
||||||
5
tests/pySim-shell_test/euicc/test_get_eid.script
Normal file
5
tests/pySim-shell_test/euicc/test_get_eid.script
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
select ADF.ISD-R
|
||||||
|
get_eid > get_eid.tmp
|
||||||
6
tests/pySim-shell_test/euicc/test_get_euicc_info.script
Normal file
6
tests/pySim-shell_test/euicc/test_get_euicc_info.script
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
select ADF.ISD-R
|
||||||
|
get_euicc_info1 > euicc_info1.tmp
|
||||||
|
get_euicc_info2 > euicc_info2.tmp
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
select ADF.ISD-R
|
||||||
|
get_profiles_info > get_profiles_info.tmp
|
||||||
7
tests/pySim-shell_test/euicc/test_list_notif.script
Normal file
7
tests/pySim-shell_test/euicc/test_list_notif.script
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
select ADF.ISD-R
|
||||||
|
|
||||||
|
# List notifications
|
||||||
|
list_notification > notifications.tmp
|
||||||
6
tests/pySim-shell_test/euicc/test_rm_notif.template
Normal file
6
tests/pySim-shell_test/euicc/test_rm_notif.template
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
select ADF.ISD-R
|
||||||
|
|
||||||
|
remove_notification_from_list $SEQ_NUMBER
|
||||||
7
tests/pySim-shell_test/euicc/test_set_nickname.script
Normal file
7
tests/pySim-shell_test/euicc/test_set_nickname.script
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
select ADF.ISD-R
|
||||||
|
|
||||||
|
# (pre-installed test profile on sysmoEUICC1-C2T)
|
||||||
|
set_nickname --profile-nickname "this-is-a-testprofile" 89000123456789012341 > set_nickname.tmp
|
||||||
0
tests/pySim-shell_test/export/__init__.py
Normal file
0
tests/pySim-shell_test/export/__init__.py
Normal file
4944
tests/pySim-shell_test/export/export.script.ok
Normal file
4944
tests/pySim-shell_test/export/export.script.ok
Normal file
File diff suppressed because it is too large
Load Diff
46
tests/pySim-shell_test/export/test.py
Normal file
46
tests/pySim-shell_test/export/test.py
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# 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_export(self):
|
||||||
|
cardname = 'sysmoISIM-SJA5-S17'
|
||||||
|
|
||||||
|
# Generate an export script and verify it
|
||||||
|
self.runPySimShell(cardname, "test_export.script")
|
||||||
|
ignore_regex_list = [
|
||||||
|
'^#.*$', # Ignore all generated comments
|
||||||
|
' [A-Fa-f0-9]*$', # Ignore hex-strings from update_record, update_binary
|
||||||
|
'^aram_store_ref_ar_do.*' # Ignore ara-m config (already covered by testcase "export_adf_ara_m")
|
||||||
|
]
|
||||||
|
self.assertEqualFiles("export.script.tmp",
|
||||||
|
ignore_regex_list=ignore_regex_list)
|
||||||
|
|
||||||
|
# Try to import the export script we have just generated. Since there are no changes in the file contents,
|
||||||
|
# we won't actually write the files, but we will verify that the generated script makes sense and can be
|
||||||
|
# executed without causing exceptions.
|
||||||
|
self.runPySimShell(cardname, "test_import.script", no_exceptions = True)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
5
tests/pySim-shell_test/export/test_export.script
Normal file
5
tests/pySim-shell_test/export/test_export.script
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Export the entire file system
|
||||||
|
export > export.script.tmp
|
||||||
5
tests/pySim-shell_test/export/test_import.script
Normal file
5
tests/pySim-shell_test/export/test_import.script
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Export the entire file system
|
||||||
|
run_script export.script.tmp
|
||||||
0
tests/pySim-shell_test/file_admin/__init__.py
Normal file
0
tests/pySim-shell_test/file_admin/__init__.py
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
{
|
||||||
|
"file_descriptor": {
|
||||||
|
"file_descriptor_byte": {
|
||||||
|
"shareable": true,
|
||||||
|
"file_type": "working_ef",
|
||||||
|
"structure": "transparent"
|
||||||
|
},
|
||||||
|
"record_len": null,
|
||||||
|
"num_of_rec": null
|
||||||
|
},
|
||||||
|
"file_identifier": "6f7e",
|
||||||
|
"proprietary_information": {
|
||||||
|
"unknown_ber_tlv_ie_d0": {
|
||||||
|
"raw": "20"
|
||||||
|
},
|
||||||
|
"toolkit_access_conditions": {
|
||||||
|
"rfm_create": true,
|
||||||
|
"rfm_delete_terminate": true,
|
||||||
|
"other_applet_create": true,
|
||||||
|
"other_applet_delete_terminate": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"life_cycle_status_integer": "operational_activated",
|
||||||
|
"security_attrib_referenced": {
|
||||||
|
"ef_arr_file_id": "6f06",
|
||||||
|
"ef_arr_record_nr": 4
|
||||||
|
},
|
||||||
|
"file_size": 11,
|
||||||
|
"short_file_identifier": 11
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"file_descriptor": {
|
||||||
|
"file_descriptor_byte": {
|
||||||
|
"shareable": true,
|
||||||
|
"file_type": "working_ef",
|
||||||
|
"structure": "transparent"
|
||||||
|
},
|
||||||
|
"record_len": null,
|
||||||
|
"num_of_rec": null
|
||||||
|
},
|
||||||
|
"file_identifier": "6f7e",
|
||||||
|
"proprietary_information": {
|
||||||
|
"unknown_ber_tlv_ie_d0": {
|
||||||
|
"raw": "20"
|
||||||
|
},
|
||||||
|
"toolkit_access_conditions": {
|
||||||
|
"rfm_create": true,
|
||||||
|
"rfm_delete_terminate": true,
|
||||||
|
"other_applet_create": true,
|
||||||
|
"other_applet_delete_terminate": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"life_cycle_status_integer": "operational_deactivated",
|
||||||
|
"security_attrib_referenced": {
|
||||||
|
"ef_arr_file_id": "6f06",
|
||||||
|
"ef_arr_record_nr": 4
|
||||||
|
},
|
||||||
|
"file_size": 11,
|
||||||
|
"short_file_identifier": 11
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"file_descriptor": {
|
||||||
|
"file_descriptor_byte": {
|
||||||
|
"shareable": true,
|
||||||
|
"file_type": "working_ef",
|
||||||
|
"structure": "transparent"
|
||||||
|
},
|
||||||
|
"record_len": null,
|
||||||
|
"num_of_rec": null
|
||||||
|
},
|
||||||
|
"file_identifier": "6f7e",
|
||||||
|
"proprietary_information": {
|
||||||
|
"unknown_ber_tlv_ie_d0": {
|
||||||
|
"raw": "20"
|
||||||
|
},
|
||||||
|
"toolkit_access_conditions": {
|
||||||
|
"rfm_create": true,
|
||||||
|
"rfm_delete_terminate": true,
|
||||||
|
"other_applet_create": true,
|
||||||
|
"other_applet_delete_terminate": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"life_cycle_status_integer": "operational_activated",
|
||||||
|
"security_attrib_referenced": {
|
||||||
|
"ef_arr_file_id": "6f06",
|
||||||
|
"ef_arr_record_nr": 4
|
||||||
|
},
|
||||||
|
"file_size": 11,
|
||||||
|
"short_file_identifier": 11
|
||||||
|
}
|
||||||
54
tests/pySim-shell_test/file_admin/test.py
Normal file
54
tests/pySim-shell_test/file_admin/test.py
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
# 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
|
||||||
|
import json
|
||||||
|
from utils import *
|
||||||
|
|
||||||
|
class test_case(UnittestUtils):
|
||||||
|
def test_activate_deactivate(self):
|
||||||
|
cardname = 'sysmoISIM-SJA5-S17'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_activate_deactivate_file.script", add_adm = True)
|
||||||
|
self.assertEqualFiles("activate_deactivate_file.tmp",
|
||||||
|
ignore_regex_list = ['.*'],
|
||||||
|
interesting_regex_list = ['.*"life_cycle_status_integer.*"'])
|
||||||
|
|
||||||
|
def test_create_delete_df(self):
|
||||||
|
cardname = 'sysmoISIM-SJA5-S17'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_create_delete_df.script",
|
||||||
|
add_adm = True, no_exceptions = True)
|
||||||
|
|
||||||
|
def test_create_resize_delete_transparent_ef(self):
|
||||||
|
cardname = 'sysmoISIM-SJA5-S17'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_create_resize_delete_transparent_ef.script",
|
||||||
|
add_adm = True, no_exceptions = True)
|
||||||
|
|
||||||
|
def test_create_resize_delete_linear_fixed_ef(self):
|
||||||
|
cardname = 'sysmoISIM-SJA5-S17'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_create_resize_delete_linear_fixed_ef.script",
|
||||||
|
add_adm = True, no_exceptions = True)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
select /ADF.USIM/EF.LOCI > activate_deactivate_file.tmp
|
||||||
|
deactivate_file
|
||||||
|
select /ADF.USIM/EF.LOCI >> activate_deactivate_file.tmp
|
||||||
|
activate_file EF.LOCI
|
||||||
|
select /ADF.USIM/EF.LOCI >> activate_deactivate_file.tmp
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Before we start, we will grant ourselves the right to delete ef-arr-record-nr 1 files at any time. For this we
|
||||||
|
# temporarily modify EF.ARR
|
||||||
|
select /EF.ARR
|
||||||
|
export --filename /EF.ARR > restore_ef_arr.script.tmp
|
||||||
|
update_record 1 800101a40683010a950108800106900080016090008401d4a40683010a950108ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||||
|
|
||||||
|
# Create a new DF and select it
|
||||||
|
select MF
|
||||||
|
create_df --ef-arr-file-id 2f06 --ef-arr-record-nr 1 1234
|
||||||
|
select 1234
|
||||||
|
|
||||||
|
# Delete the DF that we have created
|
||||||
|
select MF
|
||||||
|
delete_file --force-delete 1234
|
||||||
|
|
||||||
|
# Restore EF.ARR to its original state
|
||||||
|
run_script restore_ef_arr.script.tmp
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Before we start, we will grant ourselves the right to delete ef-arr-record-nr 1 files at any time. For this we
|
||||||
|
# temporarily modify EF.ARR
|
||||||
|
select /EF.ARR
|
||||||
|
export --filename /EF.ARR > restore_ef_arr.script.tmp
|
||||||
|
update_record 1 800101a40683010a950108800106900080016090008401d4a40683010a950108ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||||
|
|
||||||
|
# Create a new DF (10 records with 10 bytes each) and select it
|
||||||
|
select MF
|
||||||
|
create_ef --ef-arr-file-id 2f06 --ef-arr-record-nr 1 --file-size 100 --structure linear_fixed --record-length 10 4321
|
||||||
|
select 4321
|
||||||
|
|
||||||
|
# Resize the new DF (double the number of available records) and select it again
|
||||||
|
select MF
|
||||||
|
resize_ef --file-size 200 4321
|
||||||
|
select 4321
|
||||||
|
|
||||||
|
# Delete the DF that we have created
|
||||||
|
select MF
|
||||||
|
delete_file --force-delete 4321
|
||||||
|
|
||||||
|
# Restore EF.ARR to its original state
|
||||||
|
run_script restore_ef_arr.script.tmp
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Before we start, we will grant ourselves the right to delete ef-arr-record-nr 1 files at any time. For this we
|
||||||
|
# temporarily modify EF.ARR
|
||||||
|
select /EF.ARR
|
||||||
|
export --filename /EF.ARR > restore_ef_arr.script.tmp
|
||||||
|
update_record 1 800101a40683010a950108800106900080016090008401d4a40683010a950108ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||||
|
|
||||||
|
# Create a new DF and select it
|
||||||
|
select MF
|
||||||
|
create_ef --ef-arr-file-id 2f06 --ef-arr-record-nr 1 --file-size 23 --structure transparent 5678
|
||||||
|
select 5678
|
||||||
|
|
||||||
|
# Resize the new DF and select it again
|
||||||
|
select MF
|
||||||
|
resize_ef --file-size 42 5678
|
||||||
|
select 5678
|
||||||
|
|
||||||
|
# Delete the DF that we have created
|
||||||
|
select MF
|
||||||
|
delete_file --force-delete 5678
|
||||||
|
|
||||||
|
# Restore EF.ARR to its original state
|
||||||
|
run_script restore_ef_arr.script.tmp
|
||||||
0
tests/pySim-shell_test/file_content/__init__.py
Normal file
0
tests/pySim-shell_test/file_content/__init__.py
Normal file
59
tests/pySim-shell_test/file_content/test.py
Normal file
59
tests/pySim-shell_test/file_content/test.py
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
# 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
|
||||||
|
import json
|
||||||
|
from utils import *
|
||||||
|
|
||||||
|
class test_case(UnittestUtils):
|
||||||
|
def test_binary_uicc(self):
|
||||||
|
cardname = 'sysmoISIM-SJA5-S17'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_binary_uicc.script")
|
||||||
|
self.assertEqualFiles("test_binary_uicc.tmp")
|
||||||
|
|
||||||
|
def test_binary_sim(self):
|
||||||
|
cardname = 'sysmoSIM-GR1'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_binary_sim.script")
|
||||||
|
self.assertEqualFiles("test_binary_sim.tmp")
|
||||||
|
|
||||||
|
def test_record_uicc(self):
|
||||||
|
cardname = 'sysmoISIM-SJA5-S17'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_record_uicc.script")
|
||||||
|
self.assertEqualFiles("test_record_uicc.tmp")
|
||||||
|
|
||||||
|
def test_record_sim(self):
|
||||||
|
cardname = 'sysmoSIM-GR1'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_record_sim.script")
|
||||||
|
self.assertEqualFiles("test_record_sim.tmp")
|
||||||
|
|
||||||
|
def test_ber_tlv_uicc(self):
|
||||||
|
cardname = 'sysmoISIM-SJA5-S17'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_ber_tlv_uicc.script", add_adm = True)
|
||||||
|
self.assertEqualFiles("test_ber_tlv_uicc.tmp")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
7
tests/pySim-shell_test/file_content/test_ber_tlv_uicc.ok
Normal file
7
tests/pySim-shell_test/file_content/test_ber_tlv_uicc.ok
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[129, 130, 131, 132]
|
||||||
|
8106aabbccddeeff
|
||||||
|
820a11223344556677889900
|
||||||
|
830d187216fff38bbcc22110ffffff
|
||||||
|
840123
|
||||||
|
[130, 132]
|
||||||
|
[]
|
||||||
36
tests/pySim-shell_test/file_content/test_ber_tlv_uicc.script
Normal file
36
tests/pySim-shell_test/file_content/test_ber_tlv_uicc.script
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Create a backup the files we will modify
|
||||||
|
export --filename MF/ADF.ISIM/EF.IMSConfigData > restore_ef_IMSConfigData.script.tmp
|
||||||
|
|
||||||
|
select MF/ADF.ISIM/EF.IMSConfigData
|
||||||
|
|
||||||
|
# Empty the file
|
||||||
|
delete_all
|
||||||
|
retrieve_tags > test_ber_tlv_uicc.tmp
|
||||||
|
|
||||||
|
# Set some tags
|
||||||
|
set_data 129 aabbccddeeff
|
||||||
|
set_data 130 11223344556677889900
|
||||||
|
set_data 131 187216fff38bbcc22110ffffff
|
||||||
|
set_data 132 23
|
||||||
|
|
||||||
|
# Readback tags
|
||||||
|
retrieve_tags > test_ber_tlv_uicc.tmp
|
||||||
|
retrieve_data 129 >> test_ber_tlv_uicc.tmp
|
||||||
|
retrieve_data 130 >> test_ber_tlv_uicc.tmp
|
||||||
|
retrieve_data 131 >> test_ber_tlv_uicc.tmp
|
||||||
|
retrieve_data 132 >> test_ber_tlv_uicc.tmp
|
||||||
|
|
||||||
|
# Delete some tags
|
||||||
|
delete_data 131
|
||||||
|
delete_data 129
|
||||||
|
retrieve_tags >> test_ber_tlv_uicc.tmp
|
||||||
|
|
||||||
|
# Empty file again
|
||||||
|
delete_all
|
||||||
|
retrieve_tags >> test_ber_tlv_uicc.tmp
|
||||||
|
|
||||||
|
# Restore modified files to their original state
|
||||||
|
run_script restore_ef_IMSConfigData.script.tmp
|
||||||
4
tests/pySim-shell_test/file_content/test_binary_sim.ok
Normal file
4
tests/pySim-shell_test/file_content/test_binary_sim.ok
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
ffffffffffffffffffffff
|
||||||
|
01234567890abcdeffffff
|
||||||
|
01234567890abcdeffaaaa
|
||||||
|
001abcd3440abcdeffaaaa
|
||||||
27
tests/pySim-shell_test/file_content/test_binary_sim.script
Normal file
27
tests/pySim-shell_test/file_content/test_binary_sim.script
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Create a backup the files we will modify
|
||||||
|
export --filename MF/DF.GSM/EF.LOCI > restore_ef_loci.script.tmp
|
||||||
|
|
||||||
|
# Select an arbitrary file to work with
|
||||||
|
select MF/DF.GSM/EF.LOCI
|
||||||
|
|
||||||
|
# Clear file contents
|
||||||
|
update_binary ffffffffffffffffffffff
|
||||||
|
read_binary > test_binary_sim.tmp
|
||||||
|
|
||||||
|
# Write some short pattern to the file
|
||||||
|
update_binary 01234567890abcdeff
|
||||||
|
read_binary >> test_binary_sim.tmp
|
||||||
|
|
||||||
|
# Write some pattern to the file
|
||||||
|
update_binary 01234567890abcdeffaaaa
|
||||||
|
read_binary >> test_binary_sim.tmp
|
||||||
|
|
||||||
|
# Write some short pattern to the file, we expect the tail to remain unchanged
|
||||||
|
update_binary 001abcd344
|
||||||
|
read_binary >> test_binary_sim.tmp
|
||||||
|
|
||||||
|
# Restore modified files to their original state
|
||||||
|
run_script restore_ef_loci.script.tmp
|
||||||
13
tests/pySim-shell_test/file_content/test_binary_uicc.ok
Normal file
13
tests/pySim-shell_test/file_content/test_binary_uicc.ok
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
ffffffffffffffffffffff
|
||||||
|
01234567890abcdeffffff
|
||||||
|
01234567890abcdeffaaaa
|
||||||
|
001abcd3440abcdeffaaaa
|
||||||
|
{
|
||||||
|
"tmsi": "12345678",
|
||||||
|
"lai": {
|
||||||
|
"mcc_mnc": "262-42",
|
||||||
|
"lac": "9876"
|
||||||
|
},
|
||||||
|
"rfu": 0,
|
||||||
|
"lu_status": 1
|
||||||
|
}
|
||||||
33
tests/pySim-shell_test/file_content/test_binary_uicc.script
Normal file
33
tests/pySim-shell_test/file_content/test_binary_uicc.script
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Create a backup the files we will modify
|
||||||
|
export --filename MF/ADF.USIM/EF.LOCI > restore_ef_loci.script.tmp
|
||||||
|
|
||||||
|
# Select an arbitrary file to work with
|
||||||
|
select MF/ADF.USIM/EF.LOCI
|
||||||
|
|
||||||
|
# Clear file contents
|
||||||
|
update_binary ffffffffffffffffffffff
|
||||||
|
read_binary > test_binary_uicc.tmp
|
||||||
|
|
||||||
|
# Write some short pattern to the file
|
||||||
|
update_binary 01234567890abcdeff
|
||||||
|
read_binary >> test_binary_uicc.tmp
|
||||||
|
|
||||||
|
# Write some pattern to the file
|
||||||
|
update_binary 01234567890abcdeffaaaa
|
||||||
|
read_binary >> test_binary_uicc.tmp
|
||||||
|
|
||||||
|
# Write some short pattern to the file, we expect the tail to remain unchanged
|
||||||
|
update_binary 001abcd344
|
||||||
|
read_binary >> test_binary_uicc.tmp
|
||||||
|
|
||||||
|
# Write some json encoded content to the file
|
||||||
|
update_binary_decoded '{"tmsi": "12345678", "lai": { "mcc_mnc": "262-42", "lac": "9876" }, "rfu": 0, "lu_status": 1 }'
|
||||||
|
|
||||||
|
# Read the file, we expect the same json encoded content to show up again.
|
||||||
|
read_binary_decoded >> test_binary_uicc.tmp
|
||||||
|
|
||||||
|
# Restore modified files to their original state
|
||||||
|
run_script restore_ef_loci.script.tmp
|
||||||
7
tests/pySim-shell_test/file_content/test_record_sim.ok
Normal file
7
tests/pySim-shell_test/file_content/test_record_sim.ok
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
001 ffffffffffffffffffffffffffff
|
||||||
|
001 abcdefffffffffffffffffffffff
|
||||||
|
001 12345678900aabbccdd098765434
|
||||||
|
002 ffffffffffffffffffffffffffff
|
||||||
|
003 12345678900aabbccdd098765434
|
||||||
|
004 ffffffffffffffffffffffffffff
|
||||||
|
005 12345678900aabbccdd098765434
|
||||||
25
tests/pySim-shell_test/file_content/test_record_sim.script
Normal file
25
tests/pySim-shell_test/file_content/test_record_sim.script
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Create a backup the files we will modify
|
||||||
|
export --filename MF/DF.TELECOM/EF.CCP > restore_ef_ccp.script.tmp
|
||||||
|
|
||||||
|
# Select an arbitrary file to work with
|
||||||
|
select MF/DF.TELECOM/EF.CCP
|
||||||
|
|
||||||
|
# Clear file contents
|
||||||
|
update_record 1 ffffffffffffffffffffffffffff
|
||||||
|
read_record 1 > test_record_sim.tmp
|
||||||
|
|
||||||
|
# Write some short pattern to the file, expect tail to be padded with 0xff
|
||||||
|
update_record 1 abcdef
|
||||||
|
read_record 1 >> test_record_sim.tmp
|
||||||
|
|
||||||
|
# Write some pattern to three different records
|
||||||
|
update_record 1 12345678900AABBCCDD098765434
|
||||||
|
update_record 3 12345678900AABBCCDD098765434
|
||||||
|
update_record 5 12345678900AABBCCDD098765434
|
||||||
|
read_records >> test_record_sim.tmp
|
||||||
|
|
||||||
|
# Restore modified files to their original state
|
||||||
|
run_script restore_ef_ccp.script.tmp
|
||||||
146
tests/pySim-shell_test/file_content/test_record_uicc.ok
Normal file
146
tests/pySim-shell_test/file_content/test_record_uicc.ok
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
001 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||||
|
001 abcdefffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||||
|
001 0123456789abcdef0123456789abcdef0123456789abcdef0123456789
|
||||||
|
002 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||||
|
003 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||||
|
004 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||||
|
005 0123456789abcdef0123456789abcdef0123456789abcdef0123456789
|
||||||
|
006 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||||
|
007 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||||
|
008 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||||
|
009 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||||
|
010 0123456789abcdef0123456789abcdef0123456789abcdef0123456789
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"alpha_id": null,
|
||||||
|
"len_of_bcd": 7,
|
||||||
|
"ton_npi": {
|
||||||
|
"ext": true,
|
||||||
|
"type_of_number": "reserved_for_extension",
|
||||||
|
"numbering_plan_id": "reserved_for_extension"
|
||||||
|
},
|
||||||
|
"dialing_nr": "123456",
|
||||||
|
"cap_conf_id": 42,
|
||||||
|
"ext4_record_id": 23
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alpha_id": "",
|
||||||
|
"len_of_bcd": 255,
|
||||||
|
"ton_npi": {
|
||||||
|
"ext": true,
|
||||||
|
"type_of_number": "reserved_for_extension",
|
||||||
|
"numbering_plan_id": "reserved_for_extension"
|
||||||
|
},
|
||||||
|
"dialing_nr": "",
|
||||||
|
"cap_conf_id": 255,
|
||||||
|
"ext4_record_id": 255
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alpha_id": "",
|
||||||
|
"len_of_bcd": 255,
|
||||||
|
"ton_npi": {
|
||||||
|
"ext": true,
|
||||||
|
"type_of_number": "reserved_for_extension",
|
||||||
|
"numbering_plan_id": "reserved_for_extension"
|
||||||
|
},
|
||||||
|
"dialing_nr": "",
|
||||||
|
"cap_conf_id": 255,
|
||||||
|
"ext4_record_id": 255
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alpha_id": "",
|
||||||
|
"len_of_bcd": 255,
|
||||||
|
"ton_npi": {
|
||||||
|
"ext": true,
|
||||||
|
"type_of_number": "reserved_for_extension",
|
||||||
|
"numbering_plan_id": "reserved_for_extension"
|
||||||
|
},
|
||||||
|
"dialing_nr": "",
|
||||||
|
"cap_conf_id": 255,
|
||||||
|
"ext4_record_id": 255
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alpha_id": null,
|
||||||
|
"len_of_bcd": 7,
|
||||||
|
"ton_npi": {
|
||||||
|
"ext": true,
|
||||||
|
"type_of_number": "reserved_for_extension",
|
||||||
|
"numbering_plan_id": "reserved_for_extension"
|
||||||
|
},
|
||||||
|
"dialing_nr": "123456",
|
||||||
|
"cap_conf_id": 42,
|
||||||
|
"ext4_record_id": 23
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alpha_id": "",
|
||||||
|
"len_of_bcd": 255,
|
||||||
|
"ton_npi": {
|
||||||
|
"ext": true,
|
||||||
|
"type_of_number": "reserved_for_extension",
|
||||||
|
"numbering_plan_id": "reserved_for_extension"
|
||||||
|
},
|
||||||
|
"dialing_nr": "",
|
||||||
|
"cap_conf_id": 255,
|
||||||
|
"ext4_record_id": 255
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alpha_id": "",
|
||||||
|
"len_of_bcd": 255,
|
||||||
|
"ton_npi": {
|
||||||
|
"ext": true,
|
||||||
|
"type_of_number": "reserved_for_extension",
|
||||||
|
"numbering_plan_id": "reserved_for_extension"
|
||||||
|
},
|
||||||
|
"dialing_nr": "",
|
||||||
|
"cap_conf_id": 255,
|
||||||
|
"ext4_record_id": 255
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alpha_id": "",
|
||||||
|
"len_of_bcd": 255,
|
||||||
|
"ton_npi": {
|
||||||
|
"ext": true,
|
||||||
|
"type_of_number": "reserved_for_extension",
|
||||||
|
"numbering_plan_id": "reserved_for_extension"
|
||||||
|
},
|
||||||
|
"dialing_nr": "",
|
||||||
|
"cap_conf_id": 255,
|
||||||
|
"ext4_record_id": 255
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alpha_id": "",
|
||||||
|
"len_of_bcd": 255,
|
||||||
|
"ton_npi": {
|
||||||
|
"ext": true,
|
||||||
|
"type_of_number": "reserved_for_extension",
|
||||||
|
"numbering_plan_id": "reserved_for_extension"
|
||||||
|
},
|
||||||
|
"dialing_nr": "",
|
||||||
|
"cap_conf_id": 255,
|
||||||
|
"ext4_record_id": 255
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alpha_id": null,
|
||||||
|
"len_of_bcd": 7,
|
||||||
|
"ton_npi": {
|
||||||
|
"ext": true,
|
||||||
|
"type_of_number": "reserved_for_extension",
|
||||||
|
"numbering_plan_id": "reserved_for_extension"
|
||||||
|
},
|
||||||
|
"dialing_nr": "123456",
|
||||||
|
"cap_conf_id": 42,
|
||||||
|
"ext4_record_id": 23
|
||||||
|
}
|
||||||
|
]
|
||||||
|
{
|
||||||
|
"alpha_id": null,
|
||||||
|
"len_of_bcd": 7,
|
||||||
|
"ton_npi": {
|
||||||
|
"ext": true,
|
||||||
|
"type_of_number": "reserved_for_extension",
|
||||||
|
"numbering_plan_id": "reserved_for_extension"
|
||||||
|
},
|
||||||
|
"dialing_nr": "123456",
|
||||||
|
"cap_conf_id": 42,
|
||||||
|
"ext4_record_id": 23
|
||||||
|
}
|
||||||
32
tests/pySim-shell_test/file_content/test_record_uicc.script
Normal file
32
tests/pySim-shell_test/file_content/test_record_uicc.script
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Create a backup the files we will modify
|
||||||
|
export --filename MF/ADF.USIM/EF.BDN > restore_ef_bdn.script.tmp
|
||||||
|
|
||||||
|
# Select an arbitrary file to work with
|
||||||
|
select MF/ADF.USIM/EF.BDN
|
||||||
|
|
||||||
|
# Clear file contents
|
||||||
|
update_record 1 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||||
|
read_record 1 > test_record_uicc.tmp
|
||||||
|
|
||||||
|
# Write some short pattern to the file, expect tail to be padded with 0xff
|
||||||
|
update_record 1 abcdef
|
||||||
|
read_record 1 >> test_record_uicc.tmp
|
||||||
|
|
||||||
|
# Write some pattern to three different records
|
||||||
|
update_record 1 0123456789abcdef0123456789abcdef0123456789abcdef0123456789
|
||||||
|
update_record 5 0123456789abcdef0123456789abcdef0123456789abcdef0123456789
|
||||||
|
update_record 10 0123456789abcdef0123456789abcdef0123456789abcdef0123456789
|
||||||
|
read_records >> test_record_uicc.tmp
|
||||||
|
|
||||||
|
# Write some json encoded content to three different records
|
||||||
|
update_record_decoded 1 '{ "alpha_id": "", "len_of_bcd": 7, "ton_npi": { "ext": true, "type_of_number": "reserved_for_extension", "numbering_plan_id": "reserved_for_extension" }, "dialing_nr": "1234567", "cap_conf_id": 42, "ext4_record_id": 23 }'
|
||||||
|
update_record_decoded 5 '{ "alpha_id": "", "len_of_bcd": 7, "ton_npi": { "ext": true, "type_of_number": "reserved_for_extension", "numbering_plan_id": "reserved_for_extension" }, "dialing_nr": "1234567", "cap_conf_id": 42, "ext4_record_id": 23 }'
|
||||||
|
update_record_decoded 10 '{ "alpha_id": "", "len_of_bcd": 7, "ton_npi": { "ext": true, "type_of_number": "reserved_for_extension", "numbering_plan_id": "reserved_for_extension" }, "dialing_nr": "1234567", "cap_conf_id": 42, "ext4_record_id": 23 }'
|
||||||
|
read_records_decoded >> test_record_uicc.tmp
|
||||||
|
read_record_decoded 1 >> test_record_uicc.tmp
|
||||||
|
|
||||||
|
# Restore modified files to their original state
|
||||||
|
run_script restore_ef_bdn.script.tmp
|
||||||
0
tests/pySim-shell_test/file_specific/__init__.py
Normal file
0
tests/pySim-shell_test/file_specific/__init__.py
Normal file
3
tests/pySim-shell_test/file_specific/ef_imsi.ok
Normal file
3
tests/pySim-shell_test/file_specific/ef_imsi.ok
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"imsi": "262421414141414"
|
||||||
|
}
|
||||||
45
tests/pySim-shell_test/file_specific/test.py
Normal file
45
tests/pySim-shell_test/file_specific/test.py
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# 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_update_imsi_plmn(self):
|
||||||
|
cardname = 'sysmoISIM-SJA5-S17'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_update_imsi_plmn.script", add_adm = True)
|
||||||
|
self.assertEqualFiles("ef_imsi.tmp")
|
||||||
|
|
||||||
|
def test_ef_ust(self):
|
||||||
|
cardname = 'sysmoISIM-SJA5-S17'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_ef_ust.script", add_adm = True)
|
||||||
|
self.assertEqualFiles("test_ef_ust.tmp")
|
||||||
|
|
||||||
|
def test_ef_ist(self):
|
||||||
|
cardname = 'sysmoISIM-SJA5-S17'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_ef_ist.script", add_adm = True)
|
||||||
|
self.assertEqualFiles("test_ef_ist.tmp")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
16
tests/pySim-shell_test/file_specific/test_ef_ist.ok
Normal file
16
tests/pySim-shell_test/file_specific/test_ef_ist.ok
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
Checking service No 2 (inactive)
|
||||||
|
Checking service No 5 (active)
|
||||||
|
Checking service No 6 (inactive)
|
||||||
|
Checking service No 7 (inactive)
|
||||||
|
Checking service No 8 (inactive)
|
||||||
|
Checking service No 10 (active)
|
||||||
|
Checking service No 17 (inactive)
|
||||||
|
Checking service No 18 (inactive)
|
||||||
|
Checking service No 19 (inactive)
|
||||||
|
Checking service No 20 (active)
|
||||||
|
Checking service No 21 (inactive)
|
||||||
|
Checking service No 22 (inactive)
|
||||||
|
===> 7 service / file inconsistencies detected
|
||||||
|
190208
|
||||||
|
190208
|
||||||
|
190208
|
||||||
22
tests/pySim-shell_test/file_specific/test_ef_ist.script
Normal file
22
tests/pySim-shell_test/file_specific/test_ef_ist.script
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Create a backup the files we will modify
|
||||||
|
export --filename MF/ADF.ISIM/EF.IST > restore_ef_ist.script.tmp
|
||||||
|
|
||||||
|
# Write some known default
|
||||||
|
select MF/ADF.ISIM/EF.IST
|
||||||
|
update_binary 190208
|
||||||
|
|
||||||
|
# Run check
|
||||||
|
ist_service_check > test_ef_ist.tmp
|
||||||
|
|
||||||
|
# Make changes and see if they were applied
|
||||||
|
read_binary >> test_ef_ist.tmp
|
||||||
|
ust_service_activate 7
|
||||||
|
read_binary >> test_ef_ist.tmp
|
||||||
|
ust_service_deactivate 7
|
||||||
|
read_binary >> test_ef_ist.tmp
|
||||||
|
|
||||||
|
# Restore modified files to their original state
|
||||||
|
run_script restore_ef_ist.script.tmp
|
||||||
110
tests/pySim-shell_test/file_specific/test_ef_ust.ok
Normal file
110
tests/pySim-shell_test/file_specific/test_ef_ust.ok
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
Checking service No 1 (inactive)
|
||||||
|
Checking service No 2 (active)
|
||||||
|
Checking service No 3 (active)
|
||||||
|
Checking service No 4 (active)
|
||||||
|
Checking service No 5 (active)
|
||||||
|
Checking service No 6 (active)
|
||||||
|
Checking service No 7 (inactive)
|
||||||
|
Checking service No 8 (active)
|
||||||
|
Checking service No 9 (active)
|
||||||
|
Checking service No 10 (active)
|
||||||
|
Checking service No 11 (active)
|
||||||
|
Checking service No 12 (active)
|
||||||
|
Checking service No 13 (active)
|
||||||
|
Checking service No 14 (active)
|
||||||
|
Checking service No 15 (active)
|
||||||
|
Checking service No 16 (active)
|
||||||
|
Checking service No 17 (active)
|
||||||
|
Checking service No 18 (active)
|
||||||
|
Checking service No 19 (active)
|
||||||
|
Checking service No 20 (active)
|
||||||
|
Checking service No 21 (active)
|
||||||
|
Checking service No 24 (active)
|
||||||
|
Checking service No 25 (active)
|
||||||
|
Checking service No 27 (active)
|
||||||
|
Checking service No 29 (active)
|
||||||
|
Checking service No 34 (active)
|
||||||
|
Checking service No 35 (active)
|
||||||
|
Checking service No 36 (inactive)
|
||||||
|
Checking service No 37 (inactive)
|
||||||
|
Checking service No 39 (active)
|
||||||
|
Checking service No 40 (active)
|
||||||
|
Checking service No 42 (active)
|
||||||
|
Checking service No 43 (active)
|
||||||
|
Checking service No 44 (active)
|
||||||
|
Checking service No 45 (active)
|
||||||
|
Checking service No 46 (active)
|
||||||
|
Checking service No 47 (inactive)
|
||||||
|
Checking service No 48 (inactive)
|
||||||
|
Checking service No 49 (inactive)
|
||||||
|
Checking service No 51 (active)
|
||||||
|
Checking service No 52 (inactive)
|
||||||
|
Checking service No 53 (inactive)
|
||||||
|
Checking service No 55 (inactive)
|
||||||
|
Checking service No 56 (inactive)
|
||||||
|
Checking service No 57 (inactive)
|
||||||
|
Checking service No 58 (inactive)
|
||||||
|
Checking service No 59 (inactive)
|
||||||
|
Checking service No 60 (active)
|
||||||
|
Checking service No 61 (inactive)
|
||||||
|
Checking service No 62 (inactive)
|
||||||
|
Checking service No 63 (inactive)
|
||||||
|
Checking service No 64 (inactive)
|
||||||
|
Checking service No 65 (inactive)
|
||||||
|
Checking service No 66 (inactive)
|
||||||
|
Checking service No 68 (inactive)
|
||||||
|
Checking service No 69 (inactive)
|
||||||
|
Checking service No 71 (inactive)
|
||||||
|
Checking service No 73 (inactive)
|
||||||
|
Checking service No 76 (inactive)
|
||||||
|
Checking service No 78 (inactive)
|
||||||
|
Checking service No 79 (inactive)
|
||||||
|
Checking service No 80 (inactive)
|
||||||
|
Checking service No 81 (active)
|
||||||
|
Checking service No 82 (active)
|
||||||
|
Checking service No 83 (active)
|
||||||
|
Checking service No 84 (active)
|
||||||
|
Checking service No 85 (active)
|
||||||
|
Checking service No 86 (active)
|
||||||
|
Checking service No 88 (active)
|
||||||
|
Checking service No 89 (active)
|
||||||
|
Checking service No 90 (active)
|
||||||
|
Checking service No 96 (inactive)
|
||||||
|
Checking service No 97 (inactive)
|
||||||
|
Checking service No 99 (inactive)
|
||||||
|
Checking service No 101 (inactive)
|
||||||
|
Checking service No 106 (inactive)
|
||||||
|
Checking service No 107 (inactive)
|
||||||
|
Checking service No 110 (inactive)
|
||||||
|
Checking service No 111 (inactive)
|
||||||
|
Checking service No 114 (inactive)
|
||||||
|
Checking service No 115 (inactive)
|
||||||
|
Checking service No 120 (inactive)
|
||||||
|
Checking service No 122 (active)
|
||||||
|
Checking service No 123 (active)
|
||||||
|
Checking service No 124 (inactive)
|
||||||
|
Checking service No 125 (inactive)
|
||||||
|
Checking service No 126 (inactive)
|
||||||
|
Checking service No 127 (inactive)
|
||||||
|
Checking service No 129 (inactive)
|
||||||
|
Checking service No 130 (inactive)
|
||||||
|
Checking service No 132 (inactive)
|
||||||
|
Checking service No 133 (inactive)
|
||||||
|
Checking service No 134 (inactive)
|
||||||
|
Checking service No 137 (inactive)
|
||||||
|
Checking service No 138 (inactive)
|
||||||
|
Checking service No 139 (inactive)
|
||||||
|
Checking service No 140 (inactive)
|
||||||
|
Checking service No 141 (inactive)
|
||||||
|
Checking service No 142 (inactive)
|
||||||
|
Checking service No 143 (inactive)
|
||||||
|
Checking service No 144 (inactive)
|
||||||
|
Checking service No 145 (inactive)
|
||||||
|
Checking service No 146 (inactive)
|
||||||
|
Checking service No 147 (inactive)
|
||||||
|
Checking service No 148 (inactive)
|
||||||
|
Checking service No 150 (inactive)
|
||||||
|
===> 75 service / file inconsistencies detected
|
||||||
|
beff9f9de73e04080000ff730000000600000000
|
||||||
|
beff9f9de73e04080000ff730000000600002000
|
||||||
|
beff9f9de73e04080000ff730000000600000000
|
||||||
22
tests/pySim-shell_test/file_specific/test_ef_ust.script
Normal file
22
tests/pySim-shell_test/file_specific/test_ef_ust.script
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Create a backup the files we will modify
|
||||||
|
export --filename MF/ADF.USIM/EF.UST > restore_ef_ust.script.tmp
|
||||||
|
|
||||||
|
# Write some known default
|
||||||
|
select MF/ADF.USIM/EF.UST
|
||||||
|
update_binary beff9f9de73e04080000ff730000000600000000
|
||||||
|
|
||||||
|
# Run check
|
||||||
|
ust_service_check > test_ef_ust.tmp
|
||||||
|
|
||||||
|
# Make changes and see if they were applied
|
||||||
|
read_binary >> test_ef_ust.tmp
|
||||||
|
ust_service_activate 150
|
||||||
|
read_binary >> test_ef_ust.tmp
|
||||||
|
ust_service_deactivate 150
|
||||||
|
read_binary >> test_ef_ust.tmp
|
||||||
|
|
||||||
|
# Restore modified files to their original state
|
||||||
|
run_script restore_ef_ust.script.tmp
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Create a backup the files we will modify
|
||||||
|
export --filename MF/ADF.USIM/EF.IMSI > restore_ef_imsi.script.tmp
|
||||||
|
|
||||||
|
select MF/ADF.USIM/EF.IMSI
|
||||||
|
update_binary 084941414141414141
|
||||||
|
update_imsi_plmn 26242
|
||||||
|
read_binary_decoded > ef_imsi.tmp
|
||||||
|
|
||||||
|
# Restore modified files to their original state
|
||||||
|
run_script restore_ef_imsi.script.tmp
|
||||||
0
tests/pySim-shell_test/fsdump/__init__.py
Normal file
0
tests/pySim-shell_test/fsdump/__init__.py
Normal file
14468
tests/pySim-shell_test/fsdump/fsdump.json.ok
Normal file
14468
tests/pySim-shell_test/fsdump/fsdump.json.ok
Normal file
File diff suppressed because it is too large
Load Diff
45
tests/pySim-shell_test/fsdump/test.py
Normal file
45
tests/pySim-shell_test/fsdump/test.py
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# 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
|
||||||
|
import json
|
||||||
|
from utils import *
|
||||||
|
|
||||||
|
class test_case(UnittestUtils):
|
||||||
|
def test(self):
|
||||||
|
cardname = 'sysmoISIM-SJA5-S17'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test.script")
|
||||||
|
|
||||||
|
# Try to load/parse the resulting json file to verify that the resulting JSON file is well formed
|
||||||
|
fsdump_json = open("fsdump.json.tmp")
|
||||||
|
json.load(fsdump_json)
|
||||||
|
fsdump_json.close()
|
||||||
|
|
||||||
|
# TODO: create a JSON schema and validate the contents of fsdump.json.tmp against it
|
||||||
|
|
||||||
|
# Ignore hex-strings sine we are not so much interested in the actual contents
|
||||||
|
ignore_regex_list = ['\"[A-Fa-f0-9]*\",', '\"[A-Fa-f0-9]*\"']
|
||||||
|
self.assertEqualFiles("fsdump.json.tmp",
|
||||||
|
ignore_regex_list=ignore_regex_list)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
5
tests/pySim-shell_test/fsdump/test.script
Normal file
5
tests/pySim-shell_test/fsdump/test.script
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Dump the entire file system
|
||||||
|
fsdump > fsdump.json.tmp
|
||||||
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
|
||||||
|
|
||||||
0
tests/pySim-shell_test/gp/__init__.py
Normal file
0
tests/pySim-shell_test/gp/__init__.py
Normal file
34
tests/pySim-shell_test/gp/get_status_isd.ok
Normal file
34
tests/pySim-shell_test/gp/get_status_isd.ok
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"gp_registry_related_data": [
|
||||||
|
{
|
||||||
|
"application_aid": "a000000151000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"life_cycle_state": "personalized"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"privileges": {
|
||||||
|
"security_domain": true,
|
||||||
|
"dap_verification": false,
|
||||||
|
"delegated_management": false,
|
||||||
|
"card_lock": false,
|
||||||
|
"card_terminate": false,
|
||||||
|
"card_reset": false,
|
||||||
|
"cvm_management": true,
|
||||||
|
"mandated_dap_verification": false,
|
||||||
|
"trusted_path": true,
|
||||||
|
"authorized_management": true,
|
||||||
|
"token_management": false,
|
||||||
|
"global_delete": true,
|
||||||
|
"global_lock": true,
|
||||||
|
"global_registry": true,
|
||||||
|
"final_application": false,
|
||||||
|
"global_service": false,
|
||||||
|
"receipt_generation": false,
|
||||||
|
"ciphered_load_file_data_block": false,
|
||||||
|
"contactless_activation": false,
|
||||||
|
"contactless_self_activation": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
136
tests/pySim-shell_test/gp/key_information.ok
Normal file
136
tests/pySim-shell_test/gp/key_information.ok
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
{
|
||||||
|
"key_information": [
|
||||||
|
{
|
||||||
|
"key_information_data": {
|
||||||
|
"key_identifier": 3,
|
||||||
|
"key_version_number": 50,
|
||||||
|
"key_types": [
|
||||||
|
{
|
||||||
|
"type": "aes",
|
||||||
|
"length": 32
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key_information_data": {
|
||||||
|
"key_identifier": 2,
|
||||||
|
"key_version_number": 50,
|
||||||
|
"key_types": [
|
||||||
|
{
|
||||||
|
"type": "aes",
|
||||||
|
"length": 32
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key_information_data": {
|
||||||
|
"key_identifier": 1,
|
||||||
|
"key_version_number": 50,
|
||||||
|
"key_types": [
|
||||||
|
{
|
||||||
|
"type": "aes",
|
||||||
|
"length": 32
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key_information_data": {
|
||||||
|
"key_identifier": 3,
|
||||||
|
"key_version_number": 42,
|
||||||
|
"key_types": [
|
||||||
|
{
|
||||||
|
"type": "aes",
|
||||||
|
"length": 16
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key_information_data": {
|
||||||
|
"key_identifier": 2,
|
||||||
|
"key_version_number": 42,
|
||||||
|
"key_types": [
|
||||||
|
{
|
||||||
|
"type": "aes",
|
||||||
|
"length": 16
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key_information_data": {
|
||||||
|
"key_identifier": 1,
|
||||||
|
"key_version_number": 42,
|
||||||
|
"key_types": [
|
||||||
|
{
|
||||||
|
"type": "aes",
|
||||||
|
"length": 16
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key_information_data": {
|
||||||
|
"key_identifier": 2,
|
||||||
|
"key_version_number": 64,
|
||||||
|
"key_types": [
|
||||||
|
{
|
||||||
|
"type": "des",
|
||||||
|
"length": 16
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key_information_data": {
|
||||||
|
"key_identifier": 1,
|
||||||
|
"key_version_number": 64,
|
||||||
|
"key_types": [
|
||||||
|
{
|
||||||
|
"type": "tls_psk",
|
||||||
|
"length": 16
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key_information_data": {
|
||||||
|
"key_identifier": 3,
|
||||||
|
"key_version_number": 1,
|
||||||
|
"key_types": [
|
||||||
|
{
|
||||||
|
"type": "aes",
|
||||||
|
"length": 16
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key_information_data": {
|
||||||
|
"key_identifier": 2,
|
||||||
|
"key_version_number": 1,
|
||||||
|
"key_types": [
|
||||||
|
{
|
||||||
|
"type": "aes",
|
||||||
|
"length": 16
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key_information_data": {
|
||||||
|
"key_identifier": 1,
|
||||||
|
"key_version_number": 1,
|
||||||
|
"key_types": [
|
||||||
|
{
|
||||||
|
"type": "aes",
|
||||||
|
"length": 16
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
76
tests/pySim-shell_test/gp/test.py
Normal file
76
tests/pySim-shell_test/gp/test.py
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
# 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_est_scp02_direct(self):
|
||||||
|
cardnames = ['sysmoISIM-SJA5-S17', 'sysmoISIM-SJA2']
|
||||||
|
|
||||||
|
for cardname in cardnames:
|
||||||
|
key_dek = self.cards[cardname]['SCP02_DEK_1'] #kik1
|
||||||
|
key_enc = self.cards[cardname]['SCP02_ENC_1'] #kic1
|
||||||
|
key_mac = self.cards[cardname]['SCP02_MAC_1'] #kid1
|
||||||
|
self.equipTemplate("test_est_scp02_direct.script",
|
||||||
|
KEY_DEK = key_dek, KEY_ENC = key_enc, KEY_MAC = key_mac)
|
||||||
|
self.runPySimShell(cardname, "test_est_scp02_direct.script", no_exceptions = True)
|
||||||
|
|
||||||
|
def test_est_scp02_csv(self):
|
||||||
|
cardnames = ['sysmoISIM-SJA5-S17', 'sysmoISIM-SJA2']
|
||||||
|
|
||||||
|
for cardname in cardnames:
|
||||||
|
self.runPySimShell(cardname, "test_est_scp02_csv.script", no_exceptions = True, add_csv = True)
|
||||||
|
|
||||||
|
def test_est_scp03_direct(self):
|
||||||
|
cardname = 'sysmoEUICC1-C2T'
|
||||||
|
|
||||||
|
key_dek = self.cards[cardname]['SCP03_DEK_1'] #kik1
|
||||||
|
key_enc = self.cards[cardname]['SCP03_ENC_1'] #kic1
|
||||||
|
key_mac = self.cards[cardname]['SCP03_MAC_1'] #kid1
|
||||||
|
self.equipTemplate("test_est_scp03_direct.script",
|
||||||
|
KEY_DEK = key_dek, KEY_ENC = key_enc, KEY_MAC = key_mac)
|
||||||
|
self.runPySimShell(cardname, "test_est_scp03_direct.script", no_exceptions = True)
|
||||||
|
|
||||||
|
def test_est_scp03_csv(self):
|
||||||
|
cardname = 'sysmoEUICC1-C2T'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_est_scp03_csv.script", no_exceptions = True, add_csv = True)
|
||||||
|
|
||||||
|
def test_put_delete_key(self):
|
||||||
|
# TODO: It might be helpful to run this test on an sysmoISIM-SJA5-S17 uicc as well, but unfortunately those
|
||||||
|
# cards do not have enough memory for another keyset. We would have to resize the space for the key storage
|
||||||
|
# first, or we would have to delete one keyset first. Both options are not very attractive.
|
||||||
|
cardname = 'sysmoEUICC1-C2T'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_put_delete_key.script", no_exceptions = True, add_csv = True)
|
||||||
|
self.assertEqualFiles("key_information.tmp",
|
||||||
|
ignore_regex_list = ['.*'],
|
||||||
|
interesting_regex_list = ['.*42.*'])
|
||||||
|
|
||||||
|
def test_get_status(self):
|
||||||
|
cardname = 'sysmoEUICC1-C2T'
|
||||||
|
|
||||||
|
self.runPySimShell(cardname, "test_get_status.script", no_exceptions = True, add_csv = True)
|
||||||
|
self.assertEqualFiles("get_status_isd.tmp")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
7
tests/pySim-shell_test/gp/test_est_scp02_csv.script
Normal file
7
tests/pySim-shell_test/gp/test_est_scp02_csv.script
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
select ADF.ISD
|
||||||
|
establish_scp02 --key-provider-suffix 1 --key-ver 112 --security-level 3
|
||||||
|
get_data issuer_identification_number
|
||||||
|
release_scp
|
||||||
8
tests/pySim-shell_test/gp/test_est_scp02_direct.template
Normal file
8
tests/pySim-shell_test/gp/test_est_scp02_direct.template
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
select ADF.ISD
|
||||||
|
establish_scp02 --key-dek $KEY_DEK --key-enc $KEY_ENC --key-mac $KEY_MAC --key-ver 112 --security-level 3
|
||||||
|
get_data issuer_identification_number
|
||||||
|
release_scp
|
||||||
|
|
||||||
7
tests/pySim-shell_test/gp/test_est_scp03_csv.script
Normal file
7
tests/pySim-shell_test/gp/test_est_scp03_csv.script
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
select ADF.ISD-R
|
||||||
|
establish_scp03 --key-provider-suffix 1 --key-ver 50 --security-level 3
|
||||||
|
get_data issuer_identification_number
|
||||||
|
release_scp
|
||||||
7
tests/pySim-shell_test/gp/test_est_scp03_direct.template
Normal file
7
tests/pySim-shell_test/gp/test_est_scp03_direct.template
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
select ADF.ISD-R
|
||||||
|
establish_scp03 --key-dek $KEY_DEK --key-enc $KEY_ENC --key-mac $KEY_MAC --key-ver 50 --security-level 3
|
||||||
|
get_data issuer_identification_number
|
||||||
|
release_scp
|
||||||
9
tests/pySim-shell_test/gp/test_get_status.script
Normal file
9
tests/pySim-shell_test/gp/test_get_status.script
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
select ADF.ISD-R
|
||||||
|
establish_scp03 --key-provider-suffix 1 --key-ver 50 --security-level 3
|
||||||
|
|
||||||
|
get_status isd > get_status_isd.tmp
|
||||||
|
|
||||||
|
release_scp
|
||||||
20
tests/pySim-shell_test/gp/test_put_delete_key.script
Normal file
20
tests/pySim-shell_test/gp/test_put_delete_key.script
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
set debug true
|
||||||
|
set echo true
|
||||||
|
|
||||||
|
# Establish secure channel
|
||||||
|
select ADF.ISD-R
|
||||||
|
establish_scp03 --key-provider-suffix 1 --key-ver 50 --security-level 3
|
||||||
|
|
||||||
|
# Put a keyset
|
||||||
|
put_key --key-version-nr 42 --key-id 1 --key-type aes --key-data 11111111111111111111111111111111 --key-type aes --key-data 22222222222222222222222222222222 --key-type aes --key-data 33333333333333333333333333333333
|
||||||
|
|
||||||
|
# Read key information to see if the keyset was actually stored
|
||||||
|
get_data key_information > key_information.tmp
|
||||||
|
|
||||||
|
# Delete the keyset again
|
||||||
|
delete_key --key-id 1 --key-ver 42
|
||||||
|
delete_key --key-id 2 --key-ver 42
|
||||||
|
delete_key --key-id 3 --key-ver 42
|
||||||
|
|
||||||
|
# Release secure channel
|
||||||
|
release_scp
|
||||||
0
tests/pySim-shell_test/lchan/__init__.py
Normal file
0
tests/pySim-shell_test/lchan/__init__.py
Normal file
20
tests/pySim-shell_test/lchan/test.ok
Normal file
20
tests/pySim-shell_test/lchan/test.ok
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
-> 0070000100
|
||||||
|
<- 9000:
|
||||||
|
-> 0070000200
|
||||||
|
<- 9000:
|
||||||
|
-> 0070000300
|
||||||
|
<- 9000:
|
||||||
|
currently selected file: MF/DF.TELECOM/EF.MSISDN (3f00/7f10/6f40)
|
||||||
|
currently selected file: MF/ADF.USIM/EF.IMSI (3f00/a0000000871002/6f07)
|
||||||
|
currently selected file: MF/ADF.ISIM/EF.AD (3f00/a0000000871004/6fad)
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"response_all_ref_ar_do": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
-> 0070800100
|
||||||
|
<- 9000:
|
||||||
|
-> 0070800200
|
||||||
|
<- 9000:
|
||||||
|
-> 0070800300
|
||||||
|
<- 9000:
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user