new_identity()
{
DBusGConnection *connection;
- DBusGProxy *proxy;
+ DBusGProxy *proxy = NULL;
guint id = 0;
GError *error = NULL;
{
g_warning ("%s %d returned error: %s", G_STRFUNC, __LINE__, error->message);
g_error_free (error);
+ return -1;
}
gchar *objectPath;
fail_unless (id != 0);
- identity = signon_identity_new_from_db(id, NULL, NULL);
+ identity = signon_identity_new_from_db(id);
fail_unless (identity != NULL);
fail_unless (SIGNON_IS_IDENTITY (identity),
{
g_type_init ();
- identity = signon_identity_new_from_db(G_MAXINT, NULL, NULL);
+ identity = signon_identity_new_from_db(G_MAXINT);
fail_unless (identity != NULL);
fail_unless (SIGNON_IS_IDENTITY (identity),
error = signon_identity_get_last_error(identity);
fail_unless (error != NULL);
- GQuark domain = error->domain;
-
fail_unless (error->domain == SIGNON_ERROR);
fail_unless (error->code == SIGNON_ERROR_NOT_FOUND);
START_TEST(test_remove_identity)
{
g_type_init ();
- SignonIdentity *idty = signon_identity_new(NULL, NULL);
+ SignonIdentity *idty = signon_identity_new();
fail_unless (idty != NULL);
fail_unless (SIGNON_IS_IDENTITY (idty),
"Failed to initialize the Identity.");
* */
gint id = new_identity();
- SignonIdentity *idty2 = signon_identity_new_from_db (id, NULL, NULL);
+ SignonIdentity *idty2 = signon_identity_new_from_db (id);
signon_identity_remove(idty2, identity_remove_cb, NULL);
g_main_loop_run (main_loop);
g_main_loop_quit(main_loop);
}
+static SignonIdentityInfo *create_standard_info()
+{
+ SignonIdentityInfo *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");
+
+ gchar *mechanisms[] = {
+ "mechanism1",
+ "mechanism2",
+ "mechanism3",
+ NULL
+ };
+
+ signon_identity_info_set_method (info, "method1", (const gchar **)mechanisms);
+ signon_identity_info_set_method (info, "method2", (const gchar **)mechanisms);
+ signon_identity_info_set_method (info, "method3", (const gchar **)mechanisms);
+
+ return info;
+}
+
START_TEST(test_info_identity)
{
g_type_init ();
- SignonIdentity *idty = signon_identity_new(NULL, NULL);
+ SignonIdentity *idty = signon_identity_new();
fail_unless (idty != NULL);
fail_unless (SIGNON_IS_IDENTITY (idty),
"Failed to initialize the Identity.");
g_main_loop_run (main_loop);
GHashTable *methods = create_methods_hashtable();
- gint result_id;
-
signon_identity_store_credentials_with_args (idty,
"James Bond",
"007",
g_main_loop_run (main_loop);
gint id = signon_identity_info_get_id (info);
- SignonIdentity *idty2 = signon_identity_new_from_db (id, NULL, NULL);
+ SignonIdentity *idty2 = signon_identity_new_from_db (id);
signon_identity_query_info (idty2, identity_info_cb, &info);
g_main_loop_run (main_loop);
}
END_TEST
+static void identity_signout_cb (SignonIdentity *self,
+ const GError *error,
+ gpointer user_data)
+{
+ if (error)
+ g_warning ("%s: %s", G_STRFUNC, error->message);
+ else
+ g_warning ("%s: No error", G_STRFUNC);
+
+ fail_unless (error == NULL, "There should be no error in callback");
+ g_main_loop_quit (main_loop);
+}
+
+static void identity_signout_signal_cb (gpointer instance, gpointer user_data)
+{
+ gint *incr = (gint *)user_data;
+ (*incr) = (*incr) + 1;
+ g_warning ("%s: %d", G_STRFUNC, *incr);
+}
+
START_TEST(test_signout_identity)
{
-/*
- * TODO: implement the test
- * */
+ g_type_init ();
+ SignonIdentity *idty = signon_identity_new();
+ fail_unless (idty != NULL);
+ fail_unless (SIGNON_IS_IDENTITY (idty),
+ "Failed to initialize the Identity.");
+
+ SignonIdentityInfo *info = create_standard_info();
+ main_loop = g_main_loop_new (NULL, FALSE);
+
+ signon_identity_store_credentials_with_info (idty,
+ info,
+ store_credentials_identity_cb,
+ NULL);
+ g_main_loop_run (main_loop);
+ signon_identity_query_info (idty, identity_info_cb, &info);
+ g_main_loop_run (main_loop);
+
+ gint id = signon_identity_info_get_id (info);
+ SignonIdentity *idty2 = signon_identity_new_from_db (id);
+
+ signon_identity_info_free (info);
+
+ GError *err = NULL;
+
+ SignonAuthSession *as1 = signon_identity_create_session (idty,
+ "ssotest",
+ NULL,
+ NULL,
+ &err);
+
+ fail_unless (as1 != NULL, "cannot create AuthSession");
+
+ SignonAuthSession *as2 = signon_identity_create_session (idty,
+ "ssotest",
+ NULL,
+ NULL,
+ &err);
+ fail_unless (as2 != NULL, "cannot create AuthSession");
+ SignonAuthSession *as3 = signon_identity_create_session (idty2,
+ "ssotest",
+ NULL,
+ NULL,
+ &err);
+ fail_unless (as3 != NULL, "cannot create AuthSession");
+ SignonAuthSession *as4 = signon_identity_create_session (idty2,
+ "ssotest",
+ NULL,
+ NULL,
+ &err);
+ fail_unless (as4 != NULL, "cannot create AuthSession");
+
+ gint counter = 0;
+
+ g_signal_connect (idty, "signon-identity-signout", identity_signout_signal_cb, &counter);
+ g_signal_connect (idty2, "signon-identity-signout", identity_signout_signal_cb, &counter);
+
+ signon_identity_signout (idty, identity_signout_cb, NULL);
+ g_main_loop_run (main_loop);
+
+ fail_unless (counter == 2, "Lost some of SIGNOUT signals");
+ fail_if (SIGNON_IS_AUTH_SESSION (as1), "Authsession1 was not destroyed after signout");
+ fail_if (SIGNON_IS_AUTH_SESSION (as3), "Authsession3 was not destroyed after signout");
+
+ fail_if (SIGNON_IS_AUTH_SESSION (as2), "Authsession2 was not destroyed after signout");
+ fail_if (SIGNON_IS_AUTH_SESSION (as4), "Authsession4 was not destroyed after signout");
+
+ g_object_unref (idty);
+ g_object_unref (idty2);
}
END_TEST