static void uoa_get_account_password (TpAccount *tp_account, GSimpleAsyncResult *result) { AgAccountService *service; AgAuthData *auth_data; guint cred_id; SignonIdentity *identity; SignonAuthSession *session; GError *error = NULL; DEBUG ("Store password for %s in signond", tp_account_get_path_suffix (tp_account)); service = uoa_password_common (tp_account, result, &auth_data); if (service == NULL) return; cred_id = ag_auth_data_get_credentials_id (auth_data); if (cred_id == 0) { g_simple_async_result_set_error (result, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "AgAccount has no CredentialsId"); g_simple_async_result_complete_in_idle (result); goto out; } identity = signon_identity_new_from_db (cred_id); session = signon_identity_create_session (identity, ag_auth_data_get_method (auth_data), &error); g_object_unref (identity); if (session == NULL) { g_simple_async_result_set_from_error (result, error); g_simple_async_result_complete_in_idle (result); goto out; } signon_auth_session_process (session, ag_auth_data_get_parameters (auth_data), ag_auth_data_get_mechanism (auth_data), uoa_session_process_cb, g_object_ref (result)); out: ag_auth_data_unref (auth_data); g_object_unref (service); }
END_TEST START_TEST(test_auth_session_process) { g_type_init(); gint state_counter = 0; GError *err = NULL; g_debug("%s", G_STRFUNC); SignonIdentity *idty = signon_identity_new(NULL, NULL); fail_unless (idty != NULL, "Cannot create Iddentity object"); SignonAuthSession *auth_session = signon_identity_create_session(idty, "ssotest", &err); fail_unless (auth_session != NULL, "Cannot create AuthSession object"); g_clear_error(&err); g_signal_connect(auth_session, "state-changed", G_CALLBACK(test_auth_session_states_cb), &state_counter); GHashTable* sessionData = g_hash_table_new(g_str_hash, g_str_equal); GValue* usernameVa = g_new0(GValue, 1); gchar* usernameKey = g_strdup(SIGNON_SESSION_DATA_USERNAME); g_value_init (usernameVa, G_TYPE_STRING); g_value_set_static_string(usernameVa, "test_username"); g_hash_table_insert (sessionData, usernameKey, usernameVa); GValue* passwordVa = g_new0(GValue, 1); gchar* passwordKey = g_strdup(SIGNON_SESSION_DATA_SECRET); g_value_init (passwordVa, G_TYPE_STRING); g_value_set_static_string(passwordVa, "test_username"); g_hash_table_insert (sessionData, passwordKey, passwordVa); signon_auth_session_process(auth_session, sessionData, "mech1", test_auth_session_process_cb, sessionData); if(!main_loop) main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (main_loop); fail_unless (state_counter == 12, "Wrong numer of state change signals: %d", state_counter); state_counter = 0; signon_auth_session_process(auth_session, sessionData, "mech1", test_auth_session_process_cb, sessionData); g_main_loop_run (main_loop); fail_unless (state_counter == 12, "Wrong numer of state change signals: %d", state_counter); state_counter = 0; signon_auth_session_process(auth_session, sessionData, "mech1", test_auth_session_process_cb, sessionData); g_main_loop_run (main_loop); fail_unless (state_counter == 12, "Wrong numer of state change signals: %d", state_counter); state_counter = 0; g_object_unref (auth_session); g_object_unref (idty); g_value_unset(usernameVa); g_free(usernameVa); g_free(usernameKey); g_value_unset(passwordVa); g_free(passwordVa); g_free(passwordKey); }