dexter has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/42086?usp=email )
Change subject: pySim/euicc: fix encoding/decoding of Iccid ......................................................................
pySim/euicc: fix encoding/decoding of Iccid
The class Iccid uses a BcdAdapter to encoded/decode the ICCID. This works fine for ICCIDs that have an even (20) number of digits. In case the digit count is odd (19), the ICCID the last digit requires padding.
Let's switch to PaddedBcdAdapter for encoding/decoding, to ensure that odd-length ICCIDs are padded automatically.
Change-Id: I527a44ba454656a0d682ceb590eec6d9d0ac883a Related: OS#6868 --- M pySim/euicc.py M tests/pySim-shell_test/euicc/get_profiles_info.ok M tests/pySim-shell_test/euicc/test.py M tests/pySim-shell_test/euicc/test_gen_notif.script 4 files changed, 4 insertions(+), 4 deletions(-)
Approvals: laforge: Looks good to me, but someone else must approve lynxis lazus: Looks good to me, approved Jenkins Builder: Verified
diff --git a/pySim/euicc.py b/pySim/euicc.py index ccb65be..36e2d2a 100644 --- a/pySim/euicc.py +++ b/pySim/euicc.py @@ -181,7 +181,7 @@ class NotificationAddress(BER_TLV_IE, tag=0x0c): _construct = Utf8Adapter(GreedyBytes) class Iccid(BER_TLV_IE, tag=0x5a): - _construct = BcdAdapter(GreedyBytes) + _construct = PaddedBcdAdapter(GreedyBytes) class NotificationMetadata(BER_TLV_IE, tag=0xbf2f, nested=[SeqNumber, ProfileMgmtOperation, NotificationAddress, Iccid]): pass diff --git a/tests/pySim-shell_test/euicc/get_profiles_info.ok b/tests/pySim-shell_test/euicc/get_profiles_info.ok index 8450cb2..28eeff4 100644 --- a/tests/pySim-shell_test/euicc/get_profiles_info.ok +++ b/tests/pySim-shell_test/euicc/get_profiles_info.ok @@ -15,7 +15,7 @@ }, { "profile_info": { - "iccid": "8949449999999990031f", + "iccid": "8949449999999990031", "isdp_aid": "a0000005591010ffffffff8900001200", "profile_state": "disabled", "service_provider_name": "OsmocomSPN", diff --git a/tests/pySim-shell_test/euicc/test.py b/tests/pySim-shell_test/euicc/test.py index 3cad859..654d575 100644 --- a/tests/pySim-shell_test/euicc/test.py +++ b/tests/pySim-shell_test/euicc/test.py @@ -23,7 +23,7 @@ import json from utils import *
-# This testcase requires a sysmoEUICC1-C2T with the test prfile TS48V1-B-UNIQUE (ICCID 8949449999999990031f) +# This testcase requires a sysmoEUICC1-C2T with the test prfile TS48V1-B-UNIQUE (ICCID 8949449999999990031) # 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)
diff --git a/tests/pySim-shell_test/euicc/test_gen_notif.script b/tests/pySim-shell_test/euicc/test_gen_notif.script index d97dc2b..feb7ef2 100644 --- a/tests/pySim-shell_test/euicc/test_gen_notif.script +++ b/tests/pySim-shell_test/euicc/test_gen_notif.script @@ -4,5 +4,5 @@ select ADF.ISD-R
# Generate two (additional) notifications by quickly enabeling the test profile -enable_profile --iccid 8949449999999990031f +enable_profile --iccid 8949449999999990031 enable_profile --iccid 89000123456789012341