diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2018-01-08 13:37:24 +0100 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2018-09-12 17:17:36 +0000 |
commit | 02821232878d2a12bf248b7f2594c48076593810 (patch) | |
tree | 90a7d1cf0b0e204ac4b215f87a61c4c5cc971f49 /src/tests/test-modem-helpers.c | |
parent | 4c669d3bf46da3b4f924968e43fc2edfbfa0b5d7 (diff) |
helpers: allow 19-digit reported ICCIDs
The mm_3gpp_parse_iccid() method does validation of the ICCID string
and was originally implemented to handle +CRSM reported values. The
implementation was looking for 20-digit strings, even for 19-digit
ICCIDs (those finished with a trailing 'F').
We now extend the logic to also validate ICCID strings reported as
19-digit values directly, and when that happens we won't allow
swapping of the digits (a +CRSM specific requirement) or trailing 'F'
characters (as that is only required when reporting 19-digit ICCIDs
with 20-digit strings).
This change allows us to e.g. use the u-blox specific AT+CCID command
and validate the returned ICCID with the same helper method, which
currently fails:
(ttyACM2): --> 'AT+CCID<CR>'
(ttyACM2): <-- '<CR><LF>+CCID: 8934077700015848638<CR><LF><CR><LF>OK<CR><LF>'
couldn't load SIM identifier: 'Invalid ICCID response size (was 19, expected 20)'
Diffstat (limited to 'src/tests/test-modem-helpers.c')
-rw-r--r-- | src/tests/test-modem-helpers.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c index 4a044c68..83924051 100644 --- a/src/tests/test-modem-helpers.c +++ b/src/tests/test-modem-helpers.c @@ -2091,6 +2091,20 @@ test_iccid_parse_unquoted_unswapped_19_digit (void *f, gpointer d) } static void +test_iccid_parse_unquoted_unswapped_19_digit_no_f (void *f, gpointer d) +{ + const char *raw_iccid = "8944200053671052499"; + const char *expected = "8944200053671052499"; + char *parsed; + GError *error = NULL; + + parsed = mm_3gpp_parse_iccid (raw_iccid, &error); + g_assert_no_error (error); + g_assert_cmpstr (parsed, ==, expected); + g_free (parsed); +} + +static void test_iccid_parse_quoted_unswapped_20_digit (void *f, gpointer d) { const char *raw_iccid = "\"89324102234690160476\""; @@ -3924,6 +3938,7 @@ int main (int argc, char **argv) g_test_suite_add (suite, TESTCASE (test_iccid_parse_quoted_swap_19_digit, NULL)); g_test_suite_add (suite, TESTCASE (test_iccid_parse_unquoted_swap_20_digit, NULL)); g_test_suite_add (suite, TESTCASE (test_iccid_parse_unquoted_unswapped_19_digit, NULL)); + g_test_suite_add (suite, TESTCASE (test_iccid_parse_unquoted_unswapped_19_digit_no_f, NULL)); g_test_suite_add (suite, TESTCASE (test_iccid_parse_quoted_unswapped_20_digit, NULL)); g_test_suite_add (suite, TESTCASE (test_iccid_parse_short, NULL)); g_test_suite_add (suite, TESTCASE (test_iccid_parse_invalid_chars, NULL)); |