mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-17 02:48:34 +03:00
Add testsuite for pySim-shell with real cards
This patch adds a comprehensive testsuite for pySim-shell. The testsuite is based on python's unittest framework in combination with pySim-shell scripts. Related: OS#6531 Change-Id: Ieae1330767a6e55e62437f5f988a0d33b727b5de
This commit is contained in:
0
tests/pySim-shell_test/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
|
||||
Reference in New Issue
Block a user