diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2020-09-09 10:55:33 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2020-11-04 09:50:13 +0100 |
commit | f280573f6ded8da447f8f3bc934c4d3204a27f1c (patch) | |
tree | 44c081ab4dcebe8baf9719819516b075ad64f598 /plugins/cinterion/tests | |
parent | eb338c967f613b4de8ef2933d496e1bc0936f037 (diff) |
cinterion: setup SGAUTH response parser as a helper method
Diffstat (limited to 'plugins/cinterion/tests')
-rw-r--r-- | plugins/cinterion/tests/test-modem-helpers-cinterion.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/plugins/cinterion/tests/test-modem-helpers-cinterion.c b/plugins/cinterion/tests/test-modem-helpers-cinterion.c index 14ce4c38..bb27c6e7 100644 --- a/plugins/cinterion/tests/test-modem-helpers-cinterion.c +++ b/plugins/cinterion/tests/test-modem-helpers-cinterion.c @@ -1663,6 +1663,56 @@ test_provcfg_response (void) } /*****************************************************************************/ +/* Test ^SGAUTH responses */ + +static void +test_sgauth_response (void) +{ + gboolean result; + MMBearerAllowedAuth auth = MM_BEARER_ALLOWED_AUTH_UNKNOWN; + gchar *username = NULL; + GError *error = NULL; + + const gchar *response = + "^SGAUTH: 1,2,\"vf\"\r\n" + "^SGAUTH: 2,1,\"\"\r\n" + "^SGAUTH: 3,0\r\n"; + + /* CID 1 */ + result = mm_cinterion_parse_sgauth_response (response, 1, &auth, &username, &error); + g_assert_no_error (error); + g_assert (result); + g_assert_cmpuint (auth, ==, MM_BEARER_ALLOWED_AUTH_CHAP); + g_assert_cmpstr (username, ==, "vf"); + + auth = MM_BEARER_ALLOWED_AUTH_UNKNOWN; + g_clear_pointer (&username, g_free); + + /* CID 2 */ + result = mm_cinterion_parse_sgauth_response (response, 2, &auth, &username, &error); + g_assert_no_error (error); + g_assert (result); + g_assert_cmpuint (auth, ==, MM_BEARER_ALLOWED_AUTH_PAP); + g_assert_null (username); + + auth = MM_BEARER_ALLOWED_AUTH_UNKNOWN; + + /* CID 3 */ + result = mm_cinterion_parse_sgauth_response (response, 3, &auth, &username, &error); + g_assert_no_error (error); + g_assert (result); + g_assert_cmpuint (auth, ==, MM_BEARER_ALLOWED_AUTH_NONE); + g_assert_null (username); + + auth = MM_BEARER_ALLOWED_AUTH_UNKNOWN; + + /* CID 4 */ + result = mm_cinterion_parse_sgauth_response (response, 4, &auth, &username, &error); + g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_NOT_FOUND); + g_assert (!result); +} + +/*****************************************************************************/ int main (int argc, char **argv) { @@ -1695,6 +1745,7 @@ int main (int argc, char **argv) g_test_add_func ("/MM/cinterion/smoni/query_response", test_smoni_response); g_test_add_func ("/MM/cinterion/smoni/query_response_to_signal", test_smoni_response_to_signal); g_test_add_func ("/MM/cinterion/scfg/provcfg", test_provcfg_response); + g_test_add_func ("/MM/cinterion/sgauth", test_sgauth_response); return g_test_run (); } |