From f280573f6ded8da447f8f3bc934c4d3204a27f1c Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Wed, 9 Sep 2020 10:55:33 +0200 Subject: cinterion: setup SGAUTH response parser as a helper method --- .../cinterion/tests/test-modem-helpers-cinterion.c | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'plugins/cinterion/tests/test-modem-helpers-cinterion.c') 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 @@ -1662,6 +1662,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 (); } -- cgit v1.2.3-70-g09d2