From 49a3b9de2807793b774d11c57b5316809676c463 Mon Sep 17 00:00:00 2001 From: Jussi Laako Date: Wed, 6 Mar 2013 18:35:17 +0200 Subject: [PATCH] Fix error domain and tests --- libsignon-glib/signon-errors.c | 2 +- libsignon-glib/signon-identity.c | 14 ++++--- tests/check_signon.c | 68 ++++---------------------------- 3 files changed, 16 insertions(+), 68 deletions(-) diff --git a/libsignon-glib/signon-errors.c b/libsignon-glib/signon-errors.c index 3316884..f66e66f 100644 --- a/libsignon-glib/signon-errors.c +++ b/libsignon-glib/signon-errors.c @@ -45,7 +45,7 @@ GQuark signon_error_quark (void) { static volatile gsize quark = 0; - g_dbus_error_register_error_domain ("signon-errors", + g_dbus_error_register_error_domain ("gsignond", &quark, signon_error_entries, G_N_ELEMENTS (signon_error_entries)); diff --git a/libsignon-glib/signon-identity.c b/libsignon-glib/signon-identity.c index 5ac9c06..bcb70ab 100644 --- a/libsignon-glib/signon-identity.c +++ b/libsignon-glib/signon-identity.c @@ -1207,30 +1207,32 @@ identity_info_ready_cb(gpointer object, const GError *error, gpointer user_data) if (priv->removed == TRUE) { + DEBUG ("%s identity removed", G_STRFUNC); + GError *new_error = g_error_new (signon_error_quark(), SIGNON_ERROR_IDENTITY_NOT_FOUND, "Already removed from database."); if (cb_data->cb) - { (cb_data->cb) (self, NULL, new_error, cb_data->user_data); - } g_error_free (new_error); } else if (error || priv->id == 0) { + DEBUG ("%s identity is new", G_STRFUNC); + if (error) DEBUG ("IdentityError: %s", error->message); else DEBUG ("Identity is not stored and has no info yet"); if (cb_data->cb) - { (cb_data->cb) (self, NULL, error, cb_data->user_data); - } } else if (priv->updated == FALSE) { + DEBUG ("%s identity needs update, call daemon", G_STRFUNC); + g_return_if_fail (priv->proxy != NULL); sso_identity_call_get_info (priv->proxy, priv->cancellable, @@ -1239,10 +1241,10 @@ identity_info_ready_cb(gpointer object, const GError *error, gpointer user_data) } else { + DEBUG ("%s pass existing one", G_STRFUNC); + if (cb_data->cb) - { (cb_data->cb) (self, priv->identity_info, error, cb_data->user_data); - } } if (priv->updated == TRUE) diff --git a/tests/check_signon.c b/tests/check_signon.c index b1d0ae0..7adbdf0 100644 --- a/tests/check_signon.c +++ b/tests/check_signon.c @@ -562,7 +562,7 @@ START_TEST(test_auth_session_process_failure) g_type_init (); - identity = signon_identity_new_from_db (0, NULL); + identity = signon_identity_new_from_db (1, NULL); fail_unless (identity != NULL, "Cannot create Identity object"); auth_session = signon_auth_session_new (identity, "nonexisting-method", @@ -874,7 +874,7 @@ START_TEST(test_store_credentials_identity) "007", 1, methods, - "caption", + "MI-6", NULL, NULL, NULL, @@ -892,16 +892,6 @@ START_TEST(test_store_credentials_identity) } END_TEST -static void identity_verify_secret_cb(SignonIdentity *self, - gboolean valid, - const GError *error, - gpointer user_data) -{ - fail_unless (error == NULL, "The callback returned error for proper secret"); - fail_unless (valid == TRUE, "The callback gives FALSE for proper secret"); - g_main_loop_quit((GMainLoop *)user_data); -} - static void identity_verify_username_cb(SignonIdentity *self, gboolean valid, const GError *error, @@ -913,49 +903,6 @@ static void identity_verify_username_cb(SignonIdentity *self, g_main_loop_quit((GMainLoop *)user_data); } - -START_TEST(test_verify_secret_identity) -{ - g_type_init (); - g_debug("%s", G_STRFUNC); - SignonIdentity *idty = signon_identity_new(NULL); - fail_unless (idty != NULL); - fail_unless (SIGNON_IS_IDENTITY (idty), - "Failed to initialize the Identity."); - - GHashTable *methods = create_methods_hashtable(); - - gchar username[] = "James Bond"; - gchar secret[] = "007"; - gchar caption[] = "caption"; - - signon_identity_store_credentials_with_args (idty, - username, - secret, - 1, - methods, - caption, - NULL, - NULL, - NULL, - 0, - store_credentials_identity_cb, - NULL); - main_loop = g_main_loop_new (NULL, FALSE); - - signon_identity_verify_secret(idty, - secret, - identity_verify_secret_cb, - main_loop); - - g_main_loop_run (main_loop); - - g_hash_table_destroy (methods); - g_object_unref (idty); - end_test (); -} -END_TEST - static void identity_remove_cb(SignonIdentity *self, const GError *error, gpointer user_data) { @@ -994,7 +941,7 @@ START_TEST(test_remove_identity) gchar username[] = "James Bond"; gchar secret[] = "007"; - gchar caption[] = "caption"; + gchar caption[] = "MI-6"; signon_identity_store_credentials_with_args (idty, username, @@ -1125,7 +1072,7 @@ static SignonIdentityInfo *create_standard_info() signon_security_context_new_from_values ("*", "*")); signon_identity_info_set_username (info, "James Bond"); signon_identity_info_set_secret (info, "007", TRUE); - signon_identity_info_set_caption (info, "caption"); + signon_identity_info_set_caption (info, "MI-6"); gchar *mechanisms[] = { "mechanism1", @@ -1165,7 +1112,7 @@ START_TEST(test_info_identity) "007", 1, methods, - "caption", + "MI-6", NULL, NULL, NULL, @@ -1178,7 +1125,7 @@ START_TEST(test_info_identity) info = signon_identity_info_new (); signon_identity_info_set_username (info, "James Bond"); signon_identity_info_set_secret (info, "007", TRUE); - signon_identity_info_set_caption (info, "caption"); + signon_identity_info_set_caption (info, "MI-6"); gchar *mechanisms[] = { "mechanism1", @@ -1453,7 +1400,7 @@ START_TEST(test_regression_unref) g_type_init (); main_loop = g_main_loop_new (NULL, FALSE); - identity = signon_identity_new_from_db (0, NULL); + identity = signon_identity_new_from_db (1, NULL); fail_unless (identity != NULL); auth_session = signon_auth_session_new (identity, "ssotest", &error); fail_unless (auth_session != NULL); @@ -1502,7 +1449,6 @@ signon_suite(void) tcase_add_test (tc_core, test_auth_session_process_failure); tcase_add_test (tc_core, test_auth_session_process_after_store); tcase_add_test (tc_core, test_store_credentials_identity); - tcase_add_test (tc_core, test_verify_secret_identity); tcase_add_test (tc_core, test_remove_identity); tcase_add_test (tc_core, test_info_identity); -- 2.34.1