libpurple/tests/test_credential_manager.c

Sat, 09 Aug 2025 17:37:27 +0800

author
Gong Zhile <gongzl@stu.hebust.edu.cn>
date
Sat, 09 Aug 2025 17:37:27 +0800
branch
bird-header-fix
changeset 43304
2599d35e9750
parent 43265
7960b5f85729
permissions
-rw-r--r--

Fix the birb header path

The birb header referred would only work with birb provided by wrap casuing
build to fail because of system-installed birb dependency. The commit points
it to the correct path <birb.h>.

See: https://keep.imfreedom.org/birb/birb/file/5bf00c7d7f80/birb/meson.build#l77

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
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43048
diff changeset
21 #include <birb.h>
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43048
diff changeset
22
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <purple.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 * TestPurpleCredentialProvider Implementation
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 G_DECLARE_FINAL_TYPE(TestPurpleCredentialProvider,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 test_purple_credential_provider,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 TEST_PURPLE, CREDENTIAL_PROVIDER,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 PurpleCredentialProvider)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 struct _TestPurpleCredentialProvider {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 PurpleCredentialProvider parent;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 };
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36
42576
ab1ca778ddb2 Make sure all of the final types in libpurple are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42242
diff changeset
37 G_DEFINE_FINAL_TYPE(TestPurpleCredentialProvider,
ab1ca778ddb2 Make sure all of the final types in libpurple are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42242
diff changeset
38 test_purple_credential_provider,
ab1ca778ddb2 Make sure all of the final types in libpurple are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42242
diff changeset
39 PURPLE_TYPE_CREDENTIAL_PROVIDER)
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 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 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
43 G_GNUC_UNUSED PurpleAccount *account,
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 GCancellable *cancellable,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 GAsyncReadyCallback callback,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 GTask *task = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 task = g_task_new(p, cancellable, callback, data);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 g_task_return_pointer(task, g_strdup("password"), g_free);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 g_clear_object(&task);
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
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
55 static char *
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 test_purple_credential_provider_read_password_finish(PurpleCredentialProvider *p,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 GAsyncResult *result,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 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
61
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 return g_task_propagate_pointer(G_TASK(result), error);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 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
67 G_GNUC_UNUSED PurpleAccount *account,
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
68 G_GNUC_UNUSED const char *password,
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 GCancellable *cancellable,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 GAsyncReadyCallback callback,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 GTask *task = NULL;
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 task = g_task_new(p, cancellable, callback, data);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 g_task_return_boolean(task, TRUE);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 g_clear_object(&task);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 static gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 test_purple_credential_provider_write_password_finish(PurpleCredentialProvider *p,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 GAsyncResult *result,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 GError **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 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
86
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 return g_task_propagate_boolean(G_TASK(result), error);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 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
92 G_GNUC_UNUSED PurpleAccount *account,
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 GCancellable *cancellable,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 GAsyncReadyCallback callback,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 GTask *task = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 task = g_task_new(p, cancellable, callback, data);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 g_task_return_boolean(task, TRUE);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 g_clear_object(&task);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 static gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 test_purple_credential_provider_clear_password_finish(PurpleCredentialProvider *p,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 GAsyncResult *result,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 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
110
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 return g_task_propagate_boolean(G_TASK(result), error);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 static void
42089
083eae91c9a8 Update the libpurple tests for the warning level 2 update
Gary Kramlich <grim@reaperworld.com>
parents: 41982
diff changeset
115 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
116 }
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 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 test_purple_credential_provider_class_init(TestPurpleCredentialProviderClass *klass)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 PurpleCredentialProviderClass *provider_class = PURPLE_CREDENTIAL_PROVIDER_CLASS(klass);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 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
124 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
125 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
126 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
127 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
128 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
129 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 static PurpleCredentialProvider *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 test_purple_credential_provider_new(void) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 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
134 test_purple_credential_provider_get_type(),
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 "id", "test-provider",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 "name", "Test Provider",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 NULL);
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
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 /******************************************************************************
43048
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
141 * Callbacks
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 *****************************************************************************/
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 static void
43048
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
144 test_purple_credential_provider_added_removed_cb(PurpleCredentialManager *manager,
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
145 PurpleCredentialProvider *provider,
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
146 gpointer data)
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
147 {
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
148 guint *counter = data;
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
149
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
150 g_assert_true(PURPLE_IS_CREDENTIAL_MANAGER(manager));
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
151 g_assert_true(PURPLE_IS_CREDENTIAL_PROVIDER(provider));
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
152
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
153 *counter = *counter + 1;
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
154 }
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
155
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
156 /******************************************************************************
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
157 * New Tests
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
158 *****************************************************************************/
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
159 static void
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
160 test_purple_credential_manager_new(void) {
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
161 PurpleCredentialManager *manager = NULL;
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
162
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
163 manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
164
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
165 g_assert_true(PURPLE_IS_CREDENTIAL_MANAGER(manager));
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
166 g_assert_true(G_IS_LIST_MODEL(manager));
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
167
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
168 g_assert_finalize_object(manager);
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
169 }
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
170
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
171 /******************************************************************************
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
172 * Add/Remove Tests
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
173 *****************************************************************************/
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
174 static void
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
175 test_purple_credential_manager_add_remove(void) {
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 PurpleCredentialManager *manager = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 PurpleCredentialProvider *provider = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 GError *error = NULL;
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
179 gboolean result = FALSE;
43048
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
180 guint added = 0;
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
181 guint removed = 0;
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
182 guint changed = 0;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183
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
184 manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 g_assert_true(PURPLE_IS_CREDENTIAL_MANAGER(manager));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186
43048
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
187 g_signal_connect(manager, "added",
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
188 G_CALLBACK(test_purple_credential_provider_added_removed_cb),
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
189 &added);
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
190 g_signal_connect(manager, "removed",
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
191 G_CALLBACK(test_purple_credential_provider_added_removed_cb),
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
192 &removed);
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43048
diff changeset
193 birb_count_list_model_items_changed(G_LIST_MODEL(manager), &changed);
43048
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
194
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 provider = test_purple_credential_provider_new();
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 the first time cleanly. */
43048
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
198 added = 0;
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
199 removed = 0;
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
200 changed = 0;
43027
581af7cd0603 Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42865
diff changeset
201 result = purple_credential_manager_add(manager, provider, &error);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
202 g_assert_no_error(error);
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
203 g_assert_true(result);
43048
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
204 g_assert_cmpuint(added, ==, 1);
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
205 g_assert_cmpuint(removed, ==, 0);
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
206 g_assert_cmpuint(changed, ==, 1);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 /* Register again and verify the error. */
43048
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
209 added = 0;
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
210 removed = 0;
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
211 changed = 0;
43027
581af7cd0603 Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42865
diff changeset
212 result = purple_credential_manager_add(manager, provider, &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 g_clear_error(&error);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
216 g_assert_false(result);
43048
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
217 g_assert_cmpuint(added, ==, 0);
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
218 g_assert_cmpuint(removed, ==, 0);
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
219 g_assert_cmpuint(changed, ==, 0);
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
220
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 /* Unregister the provider. */
43048
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
222 added = 0;
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
223 removed = 0;
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
224 changed = 0;
43027
581af7cd0603 Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42865
diff changeset
225 result = purple_credential_manager_remove(manager, provider, &error);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
226 g_assert_no_error(error);
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
227 g_assert_true(result);
43048
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
228 g_assert_cmpuint(added, ==, 0);
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
229 g_assert_cmpuint(removed, ==, 1);
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
230 g_assert_cmpuint(changed, ==, 1);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 /* Unregister the provider again and verify the error. */
43048
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
233 added = 0;
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
234 removed = 0;
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
235 changed = 0;
43027
581af7cd0603 Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42865
diff changeset
236 result = purple_credential_manager_remove(manager, provider, &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238 g_clear_error(&error);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
240 g_assert_false(result);
43048
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
241 g_assert_cmpuint(added, ==, 0);
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
242 g_assert_cmpuint(removed, ==, 0);
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
243 g_assert_cmpuint(changed, ==, 0);
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
244
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 /* Final clean ups. */
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 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
247 g_clear_object(&manager);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 }
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 /******************************************************************************
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 * Set Active Tests
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 *****************************************************************************/
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 test_purple_credential_manager_set_active_null(void) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 PurpleCredentialManager *manager = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 GError *error = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 gboolean ret = FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258
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
259 manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
261 ret = purple_credential_manager_set_active(manager, NULL, &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
263 g_assert_no_error(error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 g_assert_true(ret);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265
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
266 g_clear_object(&manager);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 test_purple_credential_manager_set_active_non_existent(void) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271 PurpleCredentialManager *manager = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 GError *error = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273 gboolean ret = FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274
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
275 manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
277 ret = purple_credential_manager_set_active(manager, "foo", &error);
40583
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 g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 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
281
42242
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
282 g_assert_false(ret);
09ac393d4f41 Fix a number of issues with the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
283
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
284 g_clear_object(&manager);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 test_purple_credential_manager_set_active_normal(void) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289 PurpleCredentialManager *manager = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290 PurpleCredentialProvider *provider = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291 GError *error = NULL;
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
292 gboolean result = FALSE;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293
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
294 manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 /* Create the provider and register it in the manager. */
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297 provider = test_purple_credential_provider_new();
43027
581af7cd0603 Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42865
diff changeset
298 result = purple_credential_manager_add(manager, provider, &error);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
299 g_assert_no_error(error);
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
300 g_assert_true(result);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
302 /* Set the provider as active and verify it was successful. */
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
303 result = purple_credential_manager_set_active(manager, "test-provider",
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
304 &error);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
305 g_assert_no_error(error);
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
306 g_assert_true(result);
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 /* Verify that unregistering the provider fails. */
43027
581af7cd0603 Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42865
diff changeset
309 result = purple_credential_manager_remove(manager, provider, &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310 g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311 g_clear_error(&error);
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
312 g_assert_false(result);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
313
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
314 /* Now unset the active provider. */
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
315 result = purple_credential_manager_set_active(manager, NULL, &error);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
316 g_assert_no_error(error);
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
317 g_assert_true(result);
40583
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 /* Finally unregister the provider now that it's no longer active. */
43027
581af7cd0603 Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42865
diff changeset
320 result = purple_credential_manager_remove(manager, provider, &error);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
321 g_assert_no_error(error);
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
322 g_assert_true(result);
40583
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 /* And our final cleanup. */
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
325 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
326 g_clear_object(&manager);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
327 }
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 /******************************************************************************
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
330 * No Provider Tests
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 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
333 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
334 GAsyncResult *res,
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
335 G_GNUC_UNUSED gpointer data)
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337 PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338 GError *error = NULL;
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
339 char *password = NULL;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340
40680
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
341 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
342 &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343 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
344 g_clear_error(&error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345 g_assert_null(password);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
348 static void
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
349 test_purple_credential_manager_no_provider_read_password_async(void) {
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
350 PurpleAccount *account = NULL;
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
351 PurpleCredentialManager *manager = NULL;
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
352
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
353 manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355 account = purple_account_new("test", "test");
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
356 purple_account_set_remember_password(account, TRUE);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
358 purple_credential_manager_read_password_async(manager, account, NULL,
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
359 test_purple_credential_manager_no_provider_read_password_cb,
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
360 NULL);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
361 g_main_context_iteration(NULL, FALSE);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
363 g_assert_finalize_object(manager);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
364 g_clear_object(&account);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
365 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
366
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
368 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
369 GAsyncResult *res,
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
370 G_GNUC_UNUSED gpointer data)
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
371 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
373 GError *error = NULL;
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
374 gboolean result = FALSE;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
375
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
376 result = purple_credential_manager_write_password_finish(manager, res,
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
377 &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
378 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
379 g_clear_error(&error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
380
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
381 g_assert_false(result);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
382 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
383
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
384 static void
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
385 test_purple_credential_manager_no_provider_write_password_async(void) {
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
386 PurpleAccount *account = NULL;
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
387 PurpleCredentialManager *manager = NULL;
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
388
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
389 manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
390
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
391 account = purple_account_new("test", "test");
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
392 purple_account_set_remember_password(account, TRUE);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
393
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
394 purple_credential_manager_write_password_async(manager, account, NULL,
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
395 NULL,
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
396 test_purple_credential_manager_no_provider_write_password_cb,
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
397 NULL);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
398
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
399 g_main_context_iteration(NULL, FALSE);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
400
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
401 g_assert_finalize_object(manager);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
402 g_clear_object(&account);
40583
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
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
405 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
406 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
407 GAsyncResult *res,
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
408 G_GNUC_UNUSED gpointer data)
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
409 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
410 PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
411 GError *error = NULL;
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
412 gboolean result = FALSE;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
413
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
414 result = purple_credential_manager_clear_password_finish(manager, res,
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
415 &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
416 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
417 g_clear_error(&error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
418
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
419 g_assert_false(result);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
420 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
421
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
422 static void
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
423 test_purple_credential_manager_no_provider_clear_password_async(void) {
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
424 PurpleAccount *account = NULL;
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
425 PurpleCredentialManager *manager = NULL;
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
426
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
427 manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
428
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
429 account = purple_account_new("test", "test");
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
430 purple_account_set_remember_password(account, TRUE);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
431
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
432 purple_credential_manager_clear_password_async(manager, account, NULL,
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
433 test_purple_credential_manager_no_provider_clear_password_cb,
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
434 NULL);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
435
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
436 g_main_context_iteration(NULL, FALSE);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
437
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
438 g_assert_finalize_object(manager);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
439 g_clear_object(&account);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
440 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
441
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
442 /******************************************************************************
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
443 * Provider Tests
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
444 *****************************************************************************/
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
445 static void
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
446 test_purple_credential_manager_read_password_cb(GObject *obj,
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
447 GAsyncResult *res,
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
448 G_GNUC_UNUSED gpointer data)
40583
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 PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
451 GError *error = NULL;
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
452 char *password = NULL;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
453
40680
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
454 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
455 &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
456 g_assert_no_error(error);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
457 g_assert_cmpstr(password, ==, "password");
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
458 g_free(password);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
459 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
460
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
461 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
462 test_purple_credential_manager_read_password_async(void) {
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
463 PurpleAccount *account = NULL;
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
464 PurpleCredentialManager *manager = NULL;
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
465 PurpleCredentialProvider *provider = NULL;
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
466 GError *error = NULL;
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
467 gboolean result = FALSE;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
468
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
469 manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
470 provider = test_purple_credential_provider_new();
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
471
43027
581af7cd0603 Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42865
diff changeset
472 result = purple_credential_manager_add(manager, provider, &error);
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
473 g_assert_no_error(error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
474 g_assert_true(result);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
475
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
476 result = purple_credential_manager_set_active(manager, "test-provider",
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
477 &error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
478 g_assert_no_error(error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
479 g_assert_true(result);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
480
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
481 account = purple_account_new("test", "test");
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
482 purple_account_set_remember_password(account, TRUE);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
483
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
484 purple_credential_manager_read_password_async(manager, account, NULL,
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
485 test_purple_credential_manager_read_password_cb,
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
486 NULL);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
487
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
488 g_main_context_iteration(NULL, FALSE);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
489
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
490 result = purple_credential_manager_set_active(manager, NULL, &error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
491 g_assert_no_error(error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
492 g_assert_true(result);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
493
43027
581af7cd0603 Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42865
diff changeset
494 result = purple_credential_manager_remove(manager, provider, &error);
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
495 g_assert_no_error(error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
496 g_assert_true(result);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
497
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
498 g_assert_finalize_object(provider);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
499 g_assert_finalize_object(manager);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
500 g_clear_object(&account);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
501 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
502
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
503 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
504 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
505 GAsyncResult *res,
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
506 G_GNUC_UNUSED gpointer data)
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
507 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
508 PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
509 GError *error = NULL;
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
510 gboolean result = FALSE;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
511
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
512 result = purple_credential_manager_write_password_finish(manager, res,
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
513 &error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
514
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
515 g_assert_no_error(error);
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
516 g_assert_true(result);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
517 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
518
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
519 static void
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
520 test_purple_credential_manager_write_password_async(void) {
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
521 PurpleAccount *account = NULL;
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
522 PurpleCredentialManager *manager = NULL;
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
523 PurpleCredentialProvider *provider = NULL;
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
524 GError *error = NULL;
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
525 gboolean result = FALSE;
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
526
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
527 manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
528 provider = test_purple_credential_provider_new();
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
529
43027
581af7cd0603 Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42865
diff changeset
530 result = purple_credential_manager_add(manager, provider, &error);
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
531 g_assert_no_error(error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
532 g_assert_true(result);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
533
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
534 result = purple_credential_manager_set_active(manager, "test-provider",
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
535 &error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
536 g_assert_no_error(error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
537 g_assert_true(result);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
538
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
539 account = purple_account_new("test", "test");
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
540 purple_account_set_remember_password(account, TRUE);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
541
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
542 purple_credential_manager_write_password_async(manager, account, NULL,
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
543 NULL,
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
544 test_purple_credential_manager_write_password_cb,
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
545 NULL);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
546
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
547 g_main_context_iteration(NULL, FALSE);
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
548
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
549 result = purple_credential_manager_set_active(manager, NULL, &error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
550 g_assert_no_error(error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
551 g_assert_true(result);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
552
43027
581af7cd0603 Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42865
diff changeset
553 result = purple_credential_manager_remove(manager, provider, &error);
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
554 g_assert_no_error(error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
555 g_assert_true(result);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
556
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
557 g_assert_finalize_object(provider);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
558 g_assert_finalize_object(manager);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
559 g_clear_object(&account);
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_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
564 GAsyncResult *res,
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
565 G_GNUC_UNUSED gpointer data)
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
566 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
567 PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
568 GError *error = NULL;
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
569 gboolean result = FALSE;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
570
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
571 result = purple_credential_manager_clear_password_finish(manager, res,
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
572 &error);
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
573 g_assert_no_error(error);
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
574 g_assert_true(result);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
575 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
576
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
577 static void
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
578 test_purple_credential_manager_clear_password_async(void) {
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
579 PurpleAccount *account = NULL;
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
580 PurpleCredentialManager *manager = NULL;
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
581 PurpleCredentialProvider *provider = NULL;
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
582 GError *error = NULL;
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
583 gboolean result = FALSE;
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
584
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
585 manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
586 provider = test_purple_credential_provider_new();
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
587
43027
581af7cd0603 Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42865
diff changeset
588 result = purple_credential_manager_add(manager, provider, &error);
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
589 g_assert_no_error(error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
590 g_assert_true(result);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
591
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
592 result = purple_credential_manager_set_active(manager, "test-provider",
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
593 &error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
594 g_assert_no_error(error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
595 g_assert_true(result);
40583
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 account = purple_account_new("test", "test");
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
598 purple_account_set_remember_password(account, TRUE);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
599
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
600 purple_credential_manager_clear_password_async(manager, account, NULL,
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
601 test_purple_credential_manager_clear_password_cb,
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
602 NULL);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
603
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
604 g_main_context_iteration(NULL, FALSE);
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
605
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
606 result = purple_credential_manager_set_active(manager, NULL, &error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
607 g_assert_no_error(error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
608 g_assert_true(result);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
609
43027
581af7cd0603 Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents: 42865
diff changeset
610 result = purple_credential_manager_remove(manager, provider, &error);
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
611 g_assert_no_error(error);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
612 g_assert_true(result);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
613
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
614 g_assert_finalize_object(provider);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
615 g_assert_finalize_object(manager);
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
616 g_clear_object(&account);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
617 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
618
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
619 /******************************************************************************
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
620 * Main
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
621 *****************************************************************************/
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
622 int
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
623 main(int argc, char *argv[]) {
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
624 g_test_init(&argc, &argv, NULL);
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
625 g_test_set_nonfatal_assertions();
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
626
43048
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
627 g_test_add_func("/credential-manager/new",
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
628 test_purple_credential_manager_new);
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
629 g_test_add_func("/credential-manager/add-remove",
45a4e977eff7 Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents: 43027
diff changeset
630 test_purple_credential_manager_add_remove);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
631 g_test_add_func("/credential-manager/set-active/null",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
632 test_purple_credential_manager_set_active_null);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
633 g_test_add_func("/credential-manager/set-active/non-existent",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
634 test_purple_credential_manager_set_active_non_existent);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
635 g_test_add_func("/credential-manager/set-active/normal",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
636 test_purple_credential_manager_set_active_normal);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
637
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
638 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
639 test_purple_credential_manager_no_provider_read_password_async);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
640 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
641 test_purple_credential_manager_no_provider_write_password_async);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
642 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
643 test_purple_credential_manager_no_provider_clear_password_async);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
644
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
645 g_test_add_func("/credential-manager/provider/read-password-async",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
646 test_purple_credential_manager_read_password_async);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
647 g_test_add_func("/credential-manager/provider/write-password-async",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
648 test_purple_credential_manager_write_password_async);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
649 g_test_add_func("/credential-manager/provider/clear-password-async",
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
650 test_purple_credential_manager_clear_password_async);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
651
42865
42a6367d2154 Modernize the credential manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
652 return g_test_run();
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
653 }

mercurial