libpurple/tests/test_credential_manager.c

Mon, 07 Aug 2023 23:21:08 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 07 Aug 2023 23:21:08 -0500
changeset 42266
f521c4c38c6e
parent 42242
09ac393d4f41
child 42576
ab1ca778ddb2
permissions
-rw-r--r--

Add PurpleProtocolContactSearchInterface to search for contacts

This interface is meant for you to be able to search for new contacts to add to
your contact list. Right now this just does keyword search, but can be extended
in the future.

Searching through your contact list is the ui's responsibility.

Testing Done:
Ran the unit tests

Reviewed at https://reviews.imfreedom.org/r/2533/

40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * Lesser General Public License for more details.
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 */
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 #include <glib.h>
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 #include <purple.h>
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "test_ui.h"
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 /******************************************************************************
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 * Globals
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 *****************************************************************************/
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 /* Since we're using GTask to test asynchronous functions, we need to use a
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 * main loop.
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 */
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 static GMainLoop *loop = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 /******************************************************************************
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 * Helpers
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 *****************************************************************************/
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 static gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 test_purple_credential_manager_timeout_cb(gpointer data) {
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
39 g_main_loop_quit(data);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 g_warning("timed out waiting for the callback function to be called");
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
43 return G_SOURCE_REMOVE;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 /******************************************************************************
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 * TestPurpleCredentialProvider Implementation
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 *****************************************************************************/
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 G_DECLARE_FINAL_TYPE(TestPurpleCredentialProvider,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 test_purple_credential_provider,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 TEST_PURPLE, CREDENTIAL_PROVIDER,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 PurpleCredentialProvider)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 struct _TestPurpleCredentialProvider {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 PurpleCredentialProvider parent;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 };
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 G_DEFINE_TYPE(TestPurpleCredentialProvider,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 test_purple_credential_provider,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 PURPLE_TYPE_CREDENTIAL_PROVIDER)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 test_purple_credential_provider_read_password_async(PurpleCredentialProvider *p,
42089
083eae91c9a8 Update the libpurple tests for the warning level 2 update
Gary Kramlich <grim@reaperworld.com>
parents: 41982
diff changeset
64 G_GNUC_UNUSED PurpleAccount *account,
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 GCancellable *cancellable,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 GAsyncReadyCallback callback,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 GTask *task = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 task = g_task_new(p, cancellable, callback, data);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 g_task_return_pointer(task, g_strdup("password"), g_free);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 g_clear_object(&task);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 static gchar *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 test_purple_credential_provider_read_password_finish(PurpleCredentialProvider *p,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 GAsyncResult *result,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 g_return_val_if_fail(g_task_is_valid(result, p), NULL);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 return g_task_propagate_pointer(G_TASK(result), error);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 test_purple_credential_provider_write_password_async(PurpleCredentialProvider *p,
42089
083eae91c9a8 Update the libpurple tests for the warning level 2 update
Gary Kramlich <grim@reaperworld.com>
parents: 41982
diff changeset
88 G_GNUC_UNUSED PurpleAccount *account,
083eae91c9a8 Update the libpurple tests for the warning level 2 update
Gary Kramlich <grim@reaperworld.com>
parents: 41982
diff changeset
89 G_GNUC_UNUSED const gchar *password,
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 GCancellable *cancellable,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 GAsyncReadyCallback callback,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 GTask *task = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 task = g_task_new(p, cancellable, callback, data);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 g_task_return_boolean(task, TRUE);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 g_clear_object(&task);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 static gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 test_purple_credential_provider_write_password_finish(PurpleCredentialProvider *p,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 GAsyncResult *result,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 g_return_val_if_fail(g_task_is_valid(result, p), FALSE);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 return g_task_propagate_boolean(G_TASK(result), error);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 test_purple_credential_provider_clear_password_async(PurpleCredentialProvider *p,
42089
083eae91c9a8 Update the libpurple tests for the warning level 2 update
Gary Kramlich <grim@reaperworld.com>
parents: 41982
diff changeset
113 G_GNUC_UNUSED PurpleAccount *account,
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 GCancellable *cancellable,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 GAsyncReadyCallback callback,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 GTask *task = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 task = g_task_new(p, cancellable, callback, data);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 g_task_return_boolean(task, TRUE);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 g_clear_object(&task);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 static gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 test_purple_credential_provider_clear_password_finish(PurpleCredentialProvider *p,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 GAsyncResult *result,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 g_return_val_if_fail(g_task_is_valid(result, p), FALSE);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 return g_task_propagate_boolean(G_TASK(result), error);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 static void
42089
083eae91c9a8 Update the libpurple tests for the warning level 2 update
Gary Kramlich <grim@reaperworld.com>
parents: 41982
diff changeset
136 test_purple_credential_provider_init(G_GNUC_UNUSED TestPurpleCredentialProvider *provider) {
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 test_purple_credential_provider_class_init(TestPurpleCredentialProviderClass *klass)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 PurpleCredentialProviderClass *provider_class = PURPLE_CREDENTIAL_PROVIDER_CLASS(klass);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 provider_class->read_password_async = test_purple_credential_provider_read_password_async;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 provider_class->read_password_finish = test_purple_credential_provider_read_password_finish;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 provider_class->write_password_async = test_purple_credential_provider_write_password_async;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 provider_class->write_password_finish = test_purple_credential_provider_write_password_finish;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 provider_class->clear_password_async = test_purple_credential_provider_clear_password_async;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 provider_class->clear_password_finish = test_purple_credential_provider_clear_password_finish;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 static PurpleCredentialProvider *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 test_purple_credential_provider_new(void) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 return g_object_new(
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
155 test_purple_credential_provider_get_type(),
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 "id", "test-provider",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 "name", "Test Provider",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 NULL);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 /******************************************************************************
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 * Get Default Tests
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 *****************************************************************************/
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 test_purple_credential_manager_get_default(void) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 PurpleCredentialManager *manager1 = NULL, *manager2 = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 manager1 = purple_credential_manager_get_default();
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 g_assert_true(PURPLE_IS_CREDENTIAL_MANAGER(manager1));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 manager2 = purple_credential_manager_get_default();
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 g_assert_true(PURPLE_IS_CREDENTIAL_MANAGER(manager2));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 g_assert_true(manager1 == manager2);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 /******************************************************************************
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 * Registration Tests
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 *****************************************************************************/
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 test_purple_credential_manager_registration(void) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 PurpleCredentialManager *manager = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 PurpleCredentialProvider *provider = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 GError *error = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 gboolean r = FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
187 manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 g_assert_true(PURPLE_IS_CREDENTIAL_MANAGER(manager));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 provider = test_purple_credential_provider_new();
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 /* Register the first time cleanly. */
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
193 r = purple_credential_manager_register(manager, provider, &error);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
194 g_assert_no_error(error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 /* Register again and verify the error. */
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
198 r = purple_credential_manager_register(manager, provider, &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 g_clear_error(&error);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
202 g_assert_false(r);
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
203
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 /* Unregister the provider. */
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
205 r = purple_credential_manager_unregister(manager, provider, &error);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
206 g_assert_no_error(error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 /* Unregister the provider again and verify the error. */
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
210 r = purple_credential_manager_unregister(manager, provider, &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 g_clear_error(&error);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
214 g_assert_false(r);
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
215
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 /* Final clean ups. */
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 g_clear_object(&provider);
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
218 g_clear_object(&manager);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 /******************************************************************************
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 * Set Active Tests
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 *****************************************************************************/
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 test_purple_credential_manager_set_active_null(void) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 PurpleCredentialManager *manager = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 GError *error = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 gboolean ret = FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
230 manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
232 ret = purple_credential_manager_set_active(manager, NULL, &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
234 g_assert_no_error(error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 g_assert_true(ret);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
237 g_clear_object(&manager);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241 test_purple_credential_manager_set_active_non_existent(void) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242 PurpleCredentialManager *manager = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 GError *error = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 gboolean ret = FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
246 manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
248 ret = purple_credential_manager_set_active(manager, "foo", &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 g_clear_error(&error);
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
252
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
253 g_assert_false(ret);
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
254
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
255 g_clear_object(&manager);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259 test_purple_credential_manager_set_active_normal(void) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260 PurpleCredentialManager *manager = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 PurpleCredentialProvider *provider = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262 GError *error = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263 gboolean r = FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
265 manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267 /* Create the provider and register it in the manager. */
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268 provider = test_purple_credential_provider_new();
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
269 r = purple_credential_manager_register(manager, provider, &error);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
270 g_assert_no_error(error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273 /* Set the provider as active and verify it was successful. */
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
274 r = purple_credential_manager_set_active(manager, "test-provider",
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
275 &error);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
276 g_assert_no_error(error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279 /* Verify that unregistering the provider fails. */
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
280 r = purple_credential_manager_unregister(manager, provider, &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281 g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282 g_clear_error(&error);
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
283 g_assert_false(r);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285 /* Now unset the active provider. */
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
286 r = purple_credential_manager_set_active(manager, NULL, &error);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
287 g_assert_no_error(error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290 /* Finally unregister the provider now that it's no longer active. */
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
291 r = purple_credential_manager_unregister(manager, provider, &error);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
292 g_assert_no_error(error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295 /* And our final cleanup. */
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 g_clear_object(&provider);
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
297 g_clear_object(&manager);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 /******************************************************************************
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 * No Provider Tests
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
302 *****************************************************************************/
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
303 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304 test_purple_credential_manager_no_provider_read_password_cb(GObject *obj,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305 GAsyncResult *res,
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
306 gpointer data)
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj);
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
309 PurpleAccount *account = data;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310 GError *error = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311 gchar *password = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
312
40680
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
313 password = purple_credential_manager_read_password_finish(manager, res,
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
314 &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
315 g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0);
42184
4e1bf25f5575 Fix several leaks in tests
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42128
diff changeset
316 g_clear_error(&error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317 g_assert_null(password);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
319 g_clear_object(&account);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
321 g_main_loop_quit(loop);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
322 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
323
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324 static gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
325 test_purple_credential_manager_no_provider_read_password_idle(gpointer data) {
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
326 PurpleCredentialManager *m = data;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
327 PurpleAccount *account = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
328
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
329 account = purple_account_new("test", "test");
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
330 purple_account_set_remember_password(account, TRUE);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
331
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
332 purple_credential_manager_read_password_async(m, account, NULL,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
333 test_purple_credential_manager_no_provider_read_password_cb,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
334 account);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
335
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
336 return G_SOURCE_REMOVE;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340 test_purple_credential_manager_no_provider_read_password_async(void) {
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
341 PurpleCredentialManager *m = NULL;
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
342
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
343 m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345 g_idle_add(test_purple_credential_manager_no_provider_read_password_idle, m);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346 g_timeout_add_seconds(10, test_purple_credential_manager_timeout_cb, loop);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348 g_main_loop_run(loop);
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
349
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
350 g_clear_object(&m);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
352
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354 test_purple_credential_manager_no_provider_write_password_cb(GObject *obj,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355 GAsyncResult *res,
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
356 gpointer data)
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
358 PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj);
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
359 PurpleAccount *account = data;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
360 GError *error = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
361 gboolean r = FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362
40680
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
363 r = purple_credential_manager_write_password_finish(manager, res, &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
364 g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0);
42184
4e1bf25f5575 Fix several leaks in tests
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42128
diff changeset
365 g_clear_error(&error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
366
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
367 g_assert_false(r);
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
368
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
369 g_clear_object(&account);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
371 g_main_loop_quit(loop);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
373
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
374 static gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
375 test_purple_credential_manager_no_provider_write_password_idle(gpointer data) {
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
376 PurpleCredentialManager *m = data;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
377 PurpleAccount *account = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
378
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
379 account = purple_account_new("test", "test");
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
380 purple_account_set_remember_password(account, TRUE);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
381
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
382 purple_credential_manager_write_password_async(m, account, NULL, NULL,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
383 test_purple_credential_manager_no_provider_write_password_cb,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
384 account);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
385
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
386 return G_SOURCE_REMOVE;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
387 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
388
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
389 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
390 test_purple_credential_manager_no_provider_write_password_async(void) {
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
391 PurpleCredentialManager *m = NULL;
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
392
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
393 m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
394
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
395 g_idle_add(test_purple_credential_manager_no_provider_write_password_idle,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
396 m);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
397 g_timeout_add_seconds(10, test_purple_credential_manager_timeout_cb, loop);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
398
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
399 g_main_loop_run(loop);
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
400
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
401 g_clear_object(&m);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
402 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
403
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
404 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
405 test_purple_credential_manager_no_provider_clear_password_cb(GObject *obj,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
406 GAsyncResult *res,
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
407 gpointer data)
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
408 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
409 PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj);
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
410 PurpleAccount *account = data;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
411 GError *error = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
412 gboolean r = FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
413
40680
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
414 r = purple_credential_manager_clear_password_finish(manager, res, &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
415 g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0);
42184
4e1bf25f5575 Fix several leaks in tests
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42128
diff changeset
416 g_clear_error(&error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
417
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
418 g_assert_false(r);
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
419
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
420 g_clear_object(&account);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
421
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
422 g_main_loop_quit(loop);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
423 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
424
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
425 static gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
426 test_purple_credential_manager_no_provider_clear_password_idle(gpointer data) {
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
427 PurpleCredentialManager *m = data;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
428 PurpleAccount *account = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
429
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
430 account = purple_account_new("test", "test");
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
431 purple_account_set_remember_password(account, TRUE);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
432
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
433 purple_credential_manager_clear_password_async(m, account, NULL,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
434 test_purple_credential_manager_no_provider_clear_password_cb,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
435 account);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
436
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
437 return G_SOURCE_REMOVE;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
438 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
439
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
440 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
441 test_purple_credential_manager_no_provider_clear_password_async(void) {
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
442 PurpleCredentialManager *m = NULL;
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
443
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
444 m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
445
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
446 g_idle_add(test_purple_credential_manager_no_provider_clear_password_idle,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
447 m);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
448 g_timeout_add_seconds(10, test_purple_credential_manager_timeout_cb, loop);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
449
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
450 g_main_loop_run(loop);
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
451
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
452 g_clear_object(&m);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
453 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
454
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
455 /******************************************************************************
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
456 * Provider Tests
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
457 *****************************************************************************/
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
458 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
459 test_purple_credential_manager_read_password_cb(GObject *obj, GAsyncResult *res,
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
460 gpointer data)
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
461 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
462 PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj);
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
463 PurpleAccount *account = data;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
464 GError *error = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
465 gchar *password = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
466
40680
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
467 password = purple_credential_manager_read_password_finish(manager, res,
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
468 &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
469 g_assert_no_error(error);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
470 g_assert_cmpstr(password, ==, "password");
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
471 g_free(password);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
472
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
473 g_clear_object(&account);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
474
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
475 g_main_loop_quit(loop);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
476 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
477
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
478 static gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
479 test_purple_credential_manager_read_password_idle(gpointer data) {
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
480 PurpleCredentialManager *m = data;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
481 PurpleAccount *account = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
482
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
483 account = purple_account_new("test", "test");
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
484 purple_account_set_remember_password(account, TRUE);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
485
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
486 purple_credential_manager_read_password_async(m, account, NULL,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
487 test_purple_credential_manager_read_password_cb,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
488 account);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
489
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
490 return G_SOURCE_REMOVE;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
491 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
492
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
493 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
494 test_purple_credential_manager_read_password_async(void) {
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
495 PurpleCredentialManager *m = NULL;
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
496 PurpleCredentialProvider *p = NULL;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
497 GError *e = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
498 gboolean r = FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
499
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
500 m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
501 p = test_purple_credential_provider_new();
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
502
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
503 r = purple_credential_manager_register(m, p, &e);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
504 g_assert_no_error(e);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
505 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
506
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
507 r = purple_credential_manager_set_active(m, "test-provider", &e);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
508 g_assert_no_error(e);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
509 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
510
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
511 g_idle_add(test_purple_credential_manager_read_password_idle, m);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
512 g_timeout_add_seconds(10, test_purple_credential_manager_timeout_cb, loop);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
513
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
514 g_main_loop_run(loop);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
515
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
516 r = purple_credential_manager_set_active(m, NULL, &e);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
517 g_assert_no_error(e);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
518 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
519
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
520 r = purple_credential_manager_unregister(m, p, &e);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
521 g_assert_no_error(e);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
522 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
523
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
524 g_clear_object(&p);
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
525 g_clear_object(&m);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
526 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
527
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
528 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
529 test_purple_credential_manager_write_password_cb(GObject *obj,
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
530 GAsyncResult *res,
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
531 gpointer data)
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
532 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
533 PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj);
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
534 PurpleAccount *account = data;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
535 GError *error = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
536 gboolean r = FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
537
40680
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
538 r = purple_credential_manager_write_password_finish(manager, res, &error);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
539 g_assert_no_error(error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
540 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
541
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
542 g_clear_object(&account);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
543
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
544 g_main_loop_quit(loop);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
545 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
546
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
547 static gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
548 test_purple_credential_manager_write_password_idle(gpointer data) {
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
549 PurpleCredentialManager *m = data;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
550 PurpleAccount *account = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
551
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
552 account = purple_account_new("test", "test");
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
553 purple_account_set_remember_password(account, TRUE);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
554
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
555 purple_credential_manager_write_password_async(m, account, NULL, NULL,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
556 test_purple_credential_manager_write_password_cb,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
557 account);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
558
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
559 return G_SOURCE_REMOVE;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
560 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
561
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
562 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
563 test_purple_credential_manager_write_password_async(void) {
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
564 PurpleCredentialManager *m = NULL;
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
565 PurpleCredentialProvider *p = NULL;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
566 GError *e = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
567 gboolean r = FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
568
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
569 m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
570 p = test_purple_credential_provider_new();
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
571
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
572 r = purple_credential_manager_register(m, p, &e);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
573 g_assert_no_error(e);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
574 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
575
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
576 r = purple_credential_manager_set_active(m, "test-provider", &e);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
577 g_assert_no_error(e);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
578 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
579
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
580 g_idle_add(test_purple_credential_manager_write_password_idle, m);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
581 g_timeout_add_seconds(10, test_purple_credential_manager_timeout_cb, loop);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
582
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
583 g_main_loop_run(loop);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
584
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
585 r = purple_credential_manager_set_active(m, NULL, &e);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
586 g_assert_no_error(e);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
587 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
588
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
589 r = purple_credential_manager_unregister(m, p, &e);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
590 g_assert_no_error(e);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
591 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
592
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
593 g_clear_object(&p);
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
594 g_clear_object(&m);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
595 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
596
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
597 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
598 test_purple_credential_manager_clear_password_cb(GObject *obj,
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
599 GAsyncResult *res,
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
600 gpointer data)
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
601 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
602 PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj);
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
603 PurpleAccount *account = data;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
604 GError *error = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
605 gboolean r = FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
606
40680
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
607 r = purple_credential_manager_clear_password_finish(manager, res, &error);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
608 g_assert_no_error(error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
609 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
610
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
611 g_clear_object(&account);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
612
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
613 g_main_loop_quit(loop);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
614 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
615
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
616 static gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
617 test_purple_credential_manager_clear_password_idle(gpointer data) {
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
618 PurpleCredentialManager *m = data;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
619 PurpleAccount *account = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
620
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
621 account = purple_account_new("test", "test");
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
622 purple_account_set_remember_password(account, TRUE);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
623
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
624 purple_credential_manager_clear_password_async(m, account, NULL,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
625 test_purple_credential_manager_clear_password_cb,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
626 account);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
627
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
628 return G_SOURCE_REMOVE;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
629 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
630
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
631 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
632 test_purple_credential_manager_clear_password_async(void) {
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
633 PurpleCredentialManager *m = NULL;
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
634 PurpleCredentialProvider *p = NULL;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
635 GError *e = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
636 gboolean r = FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
637
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
638 m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
639 p = test_purple_credential_provider_new();
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
640
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
641 r = purple_credential_manager_register(m, p, &e);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
642 g_assert_no_error(e);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
643 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
644
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
645 r = purple_credential_manager_set_active(m, "test-provider", &e);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
646 g_assert_no_error(e);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
647 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
648
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
649 g_idle_add(test_purple_credential_manager_clear_password_idle, m);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
650 g_timeout_add_seconds(10, test_purple_credential_manager_timeout_cb, loop);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
651
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
652 g_main_loop_run(loop);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
653
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
654 r = purple_credential_manager_set_active(m, NULL, &e);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
655 g_assert_no_error(e);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
656 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
657
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
658 r = purple_credential_manager_unregister(m, p, &e);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
659 g_assert_no_error(e);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
660 g_assert_true(r);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
661
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
662 g_clear_object(&p);
41809
94c31400486a Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
663 g_clear_object(&m);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
664 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
665
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
666 /******************************************************************************
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
667 * Main
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
668 *****************************************************************************/
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
669 gint
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
670 main(gint argc, gchar *argv[]) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
671 gint ret = 0;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
672
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
673 g_test_init(&argc, &argv, NULL);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
674
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
675 test_ui_purple_init();
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
676
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
677 loop = g_main_loop_new(NULL, FALSE);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
678
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
679 g_test_add_func("/credential-manager/get-default",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
680 test_purple_credential_manager_get_default);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
681 g_test_add_func("/credential-manager/registration",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
682 test_purple_credential_manager_registration);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
683 g_test_add_func("/credential-manager/set-active/null",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
684 test_purple_credential_manager_set_active_null);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
685 g_test_add_func("/credential-manager/set-active/non-existent",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
686 test_purple_credential_manager_set_active_non_existent);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
687 g_test_add_func("/credential-manager/set-active/normal",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
688 test_purple_credential_manager_set_active_normal);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
689
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
690 g_test_add_func("/credential-manager/no-provider/read-password-async",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
691 test_purple_credential_manager_no_provider_read_password_async);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
692 g_test_add_func("/credential-manager/no-provider/write-password-async",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
693 test_purple_credential_manager_no_provider_write_password_async);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
694 g_test_add_func("/credential-manager/no-provider/clear-password-async",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
695 test_purple_credential_manager_no_provider_clear_password_async);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
696
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
697 g_test_add_func("/credential-manager/provider/read-password-async",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
698 test_purple_credential_manager_read_password_async);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
699 g_test_add_func("/credential-manager/provider/write-password-async",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
700 test_purple_credential_manager_write_password_async);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
701 g_test_add_func("/credential-manager/provider/clear-password-async",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
702 test_purple_credential_manager_clear_password_async);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
703
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
704 ret = g_test_run();
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
705
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
706 g_main_loop_unref(loop);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
707
42184
4e1bf25f5575 Fix several leaks in tests
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42128
diff changeset
708 test_ui_purple_uninit();
4e1bf25f5575 Fix several leaks in tests
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42128
diff changeset
709
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
710 return ret;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
711 }

mercurial