mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-18 19:38: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/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
|
||||
Reference in New Issue
Block a user