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:
Philipp Maier
2024-08-12 17:56:43 +02:00
parent d7032955c5
commit f87a00c04f
114 changed files with 22424 additions and 0 deletions

View File

View 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"
}
}
]
}
]
}
]
}
]

View 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

View File

@@ -0,0 +1,5 @@
[
{
"response_all_ref_ar_do": null
}
]

View 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()

View 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