cinterion: setup SGAUTH response parser as a helper method
This commit is contained in:
@@ -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 ();
|
||||
}
|
||||
|
Reference in New Issue
Block a user