Sat, 02 Jan 2021 23:24:44 -0600
Fix some broken unit tests
* Output the account username instead of the display name in an error message
that causes the tests to fail because the account has no connection.
* Move all `g_assert_no_error` checks **BEFORE** we check the any other results
that we're checking. If we're not supposed to get an error and we have one,
that error helps us find the issue which therefore makes unit test failures
actionable instead of a message to debug.
Testing Done:
Compiled and made sure the tests pass.
Reviewed at https://reviews.imfreedom.org/r/326/
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * This library is free software; you can redistribute it and/or |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * modify it under the terms of the GNU Lesser General Public |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * License as published by the Free Software Foundation; either |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * version 2 of the License, or (at your option) any later version. |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * This library is distributed in the hope that it will be useful, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * Lesser General Public License for more details. |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU Lesser General Public |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * License along with this library; if not, see <https://www.gnu.org/licenses/>. |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | #include <glib.h> |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | #include <purple.h> |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include "test_ui.h" |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | * Globals |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | *****************************************************************************/ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | /* Since we're using GTask to test asynchronous functions, we need to use a |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | * main loop. |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | static GMainLoop *loop = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | * Helpers |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | *****************************************************************************/ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | static gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | test_purple_credential_manager_timeout_cb(gpointer data) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | g_main_loop_quit((GMainLoop *)data); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | g_warning("timed out waiting for the callback function to be called"); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | return FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | * TestPurpleCredentialProvider Implementation |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | *****************************************************************************/ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | #define TEST_PURPLE_TYPE_CREDENTIAL_PROVIDER (test_purple_credential_provider_get_type()) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | G_DECLARE_FINAL_TYPE(TestPurpleCredentialProvider, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | test_purple_credential_provider, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | TEST_PURPLE, CREDENTIAL_PROVIDER, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | PurpleCredentialProvider) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | struct _TestPurpleCredentialProvider { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | PurpleCredentialProvider parent; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | PurpleRequestFields *fields; |
|
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 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | G_DEFINE_TYPE(TestPurpleCredentialProvider, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | test_purple_credential_provider, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | PURPLE_TYPE_CREDENTIAL_PROVIDER) |
|
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_read_password_async(PurpleCredentialProvider *p, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | PurpleAccount *account, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | GCancellable *cancellable, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | GAsyncReadyCallback callback, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | gpointer data) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | GTask *task = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | task = g_task_new(p, cancellable, callback, data); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | g_task_return_pointer(task, g_strdup("password"), g_free); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | g_clear_object(&task); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | } |
|
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 | static gchar * |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | test_purple_credential_provider_read_password_finish(PurpleCredentialProvider *p, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | GAsyncResult *result, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | GError **error) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | 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
|
85 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | return g_task_propagate_pointer(G_TASK(result), error); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | } |
|
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 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | test_purple_credential_provider_write_password_async(PurpleCredentialProvider *p, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | PurpleAccount *account, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | const gchar *password, |
|
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_write_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 |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | test_purple_credential_provider_clear_password_async(PurpleCredentialProvider *p, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | PurpleAccount *account, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | GCancellable *cancellable, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | GAsyncReadyCallback callback, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | gpointer data) |
|
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 | GTask *task = NULL; |
|
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 | task = g_task_new(p, cancellable, callback, data); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | g_task_return_boolean(task, TRUE); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | g_clear_object(&task); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | static gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | test_purple_credential_provider_clear_password_finish(PurpleCredentialProvider *p, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | GAsyncResult *result, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
131 | GError **error) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
132 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
133 | 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
|
134 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
135 | return g_task_propagate_boolean(G_TASK(result), error); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
136 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
137 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | static PurpleRequestFields * |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
139 | test_purple_credential_provider_read_settings(PurpleCredentialProvider *p) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
140 | return purple_request_fields_new(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
141 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
142 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
143 | static gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | test_purple_credential_provider_write_settings(PurpleCredentialProvider *p, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
145 | PurpleRequestFields *fields) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
146 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
147 | TestPurpleCredentialProvider *tp = TEST_PURPLE_CREDENTIAL_PROVIDER(p); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
148 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
149 | tp->fields = fields; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
150 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
151 | return TRUE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
152 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
153 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
154 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
155 | test_purple_credential_provider_init(TestPurpleCredentialProvider *provider) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
156 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
157 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
158 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | test_purple_credential_provider_class_init(TestPurpleCredentialProviderClass *klass) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
160 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
161 | PurpleCredentialProviderClass *provider_class = PURPLE_CREDENTIAL_PROVIDER_CLASS(klass); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
162 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | 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
|
164 | 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
|
165 | 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
|
166 | 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
|
167 | 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
|
168 | 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
|
169 | provider_class->read_settings = test_purple_credential_provider_read_settings; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
170 | provider_class->write_settings = test_purple_credential_provider_write_settings; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
171 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
172 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
173 | static PurpleCredentialProvider * |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
174 | test_purple_credential_provider_new(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
175 | return g_object_new( |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
176 | TEST_PURPLE_TYPE_CREDENTIAL_PROVIDER, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
177 | "id", "test-provider", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
178 | "name", "Test Provider", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
179 | NULL); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
180 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
181 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
182 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
183 | * Get Default Tests |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
184 | *****************************************************************************/ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
185 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
186 | test_purple_credential_manager_get_default(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
187 | PurpleCredentialManager *manager1 = NULL, *manager2 = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
189 | manager1 = purple_credential_manager_get_default(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
190 | g_assert_true(PURPLE_IS_CREDENTIAL_MANAGER(manager1)); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
191 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
192 | manager2 = purple_credential_manager_get_default(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
193 | g_assert_true(PURPLE_IS_CREDENTIAL_MANAGER(manager2)); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
194 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
195 | g_assert_true(manager1 == manager2); |
|
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 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
198 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
199 | * Registration Tests |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
200 | *****************************************************************************/ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
201 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
202 | test_purple_credential_manager_registration(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
203 | PurpleCredentialManager *manager = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
204 | PurpleCredentialProvider *provider = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
205 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
206 | gboolean r = FALSE; |
|
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 | manager = purple_credential_manager_get_default(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
209 | g_assert_true(PURPLE_IS_CREDENTIAL_MANAGER(manager)); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
210 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
211 | provider = test_purple_credential_provider_new(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
212 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
213 | /* Register the first time cleanly. */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
214 | r = purple_credential_manager_register_provider(manager, provider, &error); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
215 | g_assert_no_error(error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
216 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
217 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
218 | /* Register again and verify the error. */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
219 | r = purple_credential_manager_register_provider(manager, provider, &error); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
220 | g_assert_false(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
221 | g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
222 | g_clear_error(&error); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
223 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
224 | /* Unregister the provider. */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
225 | r = purple_credential_manager_unregister_provider(manager, provider, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
226 | &error); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
227 | g_assert_no_error(error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
228 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
229 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
230 | /* Unregister the provider again and verify the error. */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
231 | r = purple_credential_manager_unregister_provider(manager, provider, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
232 | &error); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
233 | g_assert_false(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
234 | g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
235 | g_clear_error(&error); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
236 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
237 | /* Final clean ups. */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
238 | g_clear_object(&provider); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
239 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
240 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
241 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
242 | * Set Active Tests |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
243 | *****************************************************************************/ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
244 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
245 | test_purple_credential_manager_set_active_null(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
246 | PurpleCredentialManager *manager = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
247 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
248 | gboolean ret = FALSE; |
|
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 | manager = purple_credential_manager_get_default(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
251 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
252 | ret = purple_credential_manager_set_active_provider(manager, NULL, &error); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
253 | |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
254 | g_assert_no_error(error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
255 | g_assert_true(ret); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
256 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
257 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
258 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
259 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
260 | test_purple_credential_manager_set_active_non_existent(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
261 | PurpleCredentialManager *manager = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
262 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
263 | gboolean ret = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
264 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
265 | manager = purple_credential_manager_get_default(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
266 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
267 | ret = purple_credential_manager_set_active_provider(manager, "foo", &error); |
|
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 | g_assert_false(ret); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
270 | g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
271 | g_clear_error(&error); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
272 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
273 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
274 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
275 | test_purple_credential_manager_set_active_normal(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
276 | PurpleCredentialManager *manager = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
277 | PurpleCredentialProvider *provider = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
278 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
279 | gboolean r = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
280 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
281 | manager = purple_credential_manager_get_default(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
282 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
283 | /* Create the provider and register it in the manager. */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
284 | provider = test_purple_credential_provider_new(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
285 | r = purple_credential_manager_register_provider(manager, provider, &error); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
286 | g_assert_no_error(error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
287 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
288 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
289 | /* Set the provider as active and verify it was successful. */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
290 | r = purple_credential_manager_set_active_provider(manager, "test-provider", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
291 | &error); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
292 | g_assert_no_error(error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
293 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
294 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
295 | /* Verify that unregistering the provider fails. */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
296 | r = purple_credential_manager_unregister_provider(manager, provider, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
297 | &error); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
298 | g_assert_false(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
299 | g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
300 | g_clear_error(&error); |
|
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 | /* Now unset the active provider. */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
303 | r = purple_credential_manager_set_active_provider(manager, NULL, &error); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
304 | g_assert_no_error(error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
305 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
306 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
307 | /* Finally unregister the provider now that it's no longer active. */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
308 | r = purple_credential_manager_unregister_provider(manager, provider, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
309 | &error); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
310 | g_assert_no_error(error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
311 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
312 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
313 | /* And our final cleanup. */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
314 | g_clear_object(&provider); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
315 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
316 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
317 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
318 | * No Provider Tests |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
319 | *****************************************************************************/ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
320 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
321 | 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
|
322 | GAsyncResult *res, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
323 | gpointer d) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
324 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
325 | PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
326 | PurpleAccount *account = PURPLE_ACCOUNT(d); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
327 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
328 | gchar *password = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
329 | |
|
40680
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
330 | 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
|
331 | &error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
332 | g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
333 | g_assert_null(password); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
334 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
335 | g_clear_object(&account); |
|
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 | g_main_loop_quit(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
338 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
339 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
340 | static gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
341 | test_purple_credential_manager_no_provider_read_password_idle(gpointer data) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
342 | PurpleCredentialManager *m = PURPLE_CREDENTIAL_MANAGER(data); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
343 | PurpleAccount *account = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
344 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
345 | account = purple_account_new("test", "test"); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
346 | purple_account_set_remember_password(account, TRUE); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
347 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
348 | purple_credential_manager_read_password_async(m, account, NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
349 | test_purple_credential_manager_no_provider_read_password_cb, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
350 | account); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
351 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
352 | return FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
353 | } |
|
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 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
356 | test_purple_credential_manager_no_provider_read_password_async(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
357 | PurpleCredentialManager *m = purple_credential_manager_get_default(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
358 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
359 | g_idle_add(test_purple_credential_manager_no_provider_read_password_idle, m); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
360 | g_timeout_add_seconds(10, test_purple_credential_manager_timeout_cb, loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
361 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
362 | g_main_loop_run(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
363 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
364 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
365 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
366 | 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
|
367 | GAsyncResult *res, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
368 | gpointer d) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
369 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
370 | PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
371 | PurpleAccount *account = PURPLE_ACCOUNT(d); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
372 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
373 | gboolean r = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
374 | |
|
40680
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
375 | r = purple_credential_manager_write_password_finish(manager, res, &error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
376 | g_assert_false(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
377 | g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
378 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
379 | g_clear_object(&account); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
380 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
381 | g_main_loop_quit(loop); |
|
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 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
384 | static gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
385 | test_purple_credential_manager_no_provider_write_password_idle(gpointer data) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
386 | PurpleCredentialManager *m = PURPLE_CREDENTIAL_MANAGER(data); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
387 | PurpleAccount *account = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
388 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
389 | account = purple_account_new("test", "test"); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
390 | purple_account_set_remember_password(account, TRUE); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
391 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
392 | purple_credential_manager_write_password_async(m, account, NULL, NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
393 | test_purple_credential_manager_no_provider_write_password_cb, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
394 | account); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
395 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
396 | return FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
397 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
398 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
399 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
400 | test_purple_credential_manager_no_provider_write_password_async(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
401 | PurpleCredentialManager *m = purple_credential_manager_get_default(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
402 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
403 | g_idle_add(test_purple_credential_manager_no_provider_write_password_idle, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
404 | m); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
405 | g_timeout_add_seconds(10, test_purple_credential_manager_timeout_cb, loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
406 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
407 | g_main_loop_run(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
408 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
409 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
410 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
411 | 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
|
412 | GAsyncResult *res, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
413 | gpointer d) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
414 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
415 | PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
416 | PurpleAccount *account = PURPLE_ACCOUNT(d); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
417 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
418 | gboolean r = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
419 | |
|
40680
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
420 | r = purple_credential_manager_clear_password_finish(manager, res, &error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
421 | g_assert_false(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
422 | g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
423 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
424 | g_clear_object(&account); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
425 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
426 | g_main_loop_quit(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
427 | } |
|
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 | static gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
430 | test_purple_credential_manager_no_provider_clear_password_idle(gpointer data) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
431 | PurpleCredentialManager *m = PURPLE_CREDENTIAL_MANAGER(data); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
432 | PurpleAccount *account = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
433 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
434 | account = purple_account_new("test", "test"); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
435 | purple_account_set_remember_password(account, TRUE); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
436 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
437 | purple_credential_manager_clear_password_async(m, account, NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
438 | test_purple_credential_manager_no_provider_clear_password_cb, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
439 | account); |
|
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 | return FALSE; |
|
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 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
444 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
445 | test_purple_credential_manager_no_provider_clear_password_async(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
446 | PurpleCredentialManager *m = purple_credential_manager_get_default(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
447 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
448 | g_idle_add(test_purple_credential_manager_no_provider_clear_password_idle, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
449 | m); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
450 | g_timeout_add_seconds(10, test_purple_credential_manager_timeout_cb, loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
451 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
452 | g_main_loop_run(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
453 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
454 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
455 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
456 | test_purple_credential_manager_no_provider_read_settings(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
457 | PurpleCredentialManager *manager = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
458 | PurpleRequestFields *fields = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
459 | GError *error = NULL; |
|
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 | manager = purple_credential_manager_get_default(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
462 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
463 | fields = purple_credential_manager_read_settings(manager, &error); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
464 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
465 | g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
466 | g_clear_error(&error); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
467 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
468 | g_assert_null(fields); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
469 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
470 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
471 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
472 | test_purple_credential_manager_no_provider_write_settings(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
473 | PurpleCredentialManager *manager = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
474 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
475 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
476 | manager = purple_credential_manager_get_default(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
477 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
478 | purple_credential_manager_write_settings(manager, NULL, &error); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
479 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
480 | g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
481 | g_clear_error(&error); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
482 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
483 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
484 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
485 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
486 | * Provider Tests |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
487 | *****************************************************************************/ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
488 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
489 | test_purple_credential_manager_read_password_cb(GObject *obj, GAsyncResult *res, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
490 | gpointer d) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
491 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
492 | PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
493 | PurpleAccount *account = PURPLE_ACCOUNT(d); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
494 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
495 | gchar *password = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
496 | |
|
40680
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
497 | 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
|
498 | &error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
499 | g_assert_no_error(error); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
500 | g_assert_cmpstr(password, ==, "password"); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
501 | g_free(password); |
|
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 | g_clear_object(&account); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
504 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
505 | g_main_loop_quit(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
506 | } |
|
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 | static gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
509 | test_purple_credential_manager_read_password_idle(gpointer data) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
510 | PurpleCredentialManager *m = PURPLE_CREDENTIAL_MANAGER(data); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
511 | PurpleAccount *account = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
512 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
513 | account = purple_account_new("test", "test"); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
514 | purple_account_set_remember_password(account, TRUE); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
515 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
516 | purple_credential_manager_read_password_async(m, account, NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
517 | test_purple_credential_manager_read_password_cb, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
518 | account); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
519 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
520 | return FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
521 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
522 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
523 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
524 | test_purple_credential_manager_read_password_async(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
525 | PurpleCredentialManager *m = purple_credential_manager_get_default(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
526 | PurpleCredentialProvider *p = test_purple_credential_provider_new(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
527 | GError *e = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
528 | gboolean r = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
529 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
530 | r = purple_credential_manager_register_provider(m, p, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
531 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
532 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
533 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
534 | r = purple_credential_manager_set_active_provider(m, "test-provider", &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
535 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
536 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
537 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
538 | g_idle_add(test_purple_credential_manager_read_password_idle, m); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
539 | g_timeout_add_seconds(10, test_purple_credential_manager_timeout_cb, loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
540 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
541 | g_main_loop_run(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
542 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
543 | r = purple_credential_manager_set_active_provider(m, NULL, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
544 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
545 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
546 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
547 | r = purple_credential_manager_unregister_provider(m, p, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
548 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
549 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
550 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
551 | g_clear_object(&p); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
552 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
553 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
554 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
555 | test_purple_credential_manager_write_password_cb(GObject *obj, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
556 | GAsyncResult *res, gpointer d) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
557 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
558 | PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
559 | PurpleAccount *account = PURPLE_ACCOUNT(d); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
560 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
561 | gboolean r = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
562 | |
|
40680
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
563 | r = purple_credential_manager_write_password_finish(manager, res, &error); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
564 | g_assert_no_error(error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
565 | g_assert_true(r); |
|
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 | g_clear_object(&account); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
568 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
569 | g_main_loop_quit(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
570 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
571 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
572 | static gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
573 | test_purple_credential_manager_write_password_idle(gpointer data) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
574 | PurpleCredentialManager *m = PURPLE_CREDENTIAL_MANAGER(data); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
575 | PurpleAccount *account = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
576 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
577 | account = purple_account_new("test", "test"); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
578 | purple_account_set_remember_password(account, TRUE); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
579 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
580 | purple_credential_manager_write_password_async(m, account, NULL, NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
581 | test_purple_credential_manager_write_password_cb, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
582 | account); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
583 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
584 | return FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
585 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
586 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
587 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
588 | test_purple_credential_manager_write_password_async(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
589 | PurpleCredentialManager *m = purple_credential_manager_get_default(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
590 | PurpleCredentialProvider *p = test_purple_credential_provider_new(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
591 | GError *e = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
592 | gboolean r = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
593 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
594 | r = purple_credential_manager_register_provider(m, p, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
595 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
596 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
597 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
598 | r = purple_credential_manager_set_active_provider(m, "test-provider", &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
599 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
600 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
601 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
602 | g_idle_add(test_purple_credential_manager_write_password_idle, m); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
603 | g_timeout_add_seconds(10, test_purple_credential_manager_timeout_cb, loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
604 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
605 | g_main_loop_run(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
606 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
607 | r = purple_credential_manager_set_active_provider(m, NULL, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
608 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
609 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
610 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
611 | r = purple_credential_manager_unregister_provider(m, p, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
612 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
613 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
614 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
615 | g_clear_object(&p); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
616 | } |
|
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 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
619 | test_purple_credential_manager_clear_password_cb(GObject *obj, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
620 | GAsyncResult *res, gpointer d) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
621 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
622 | PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
623 | PurpleAccount *account = PURPLE_ACCOUNT(d); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
624 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
625 | gboolean r = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
626 | |
|
40680
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
627 | r = purple_credential_manager_clear_password_finish(manager, res, &error); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
628 | g_assert_no_error(error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
629 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
630 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
631 | g_clear_object(&account); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
632 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
633 | g_main_loop_quit(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
634 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
635 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
636 | static gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
637 | test_purple_credential_manager_clear_password_idle(gpointer data) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
638 | PurpleCredentialManager *m = PURPLE_CREDENTIAL_MANAGER(data); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
639 | PurpleAccount *account = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
640 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
641 | account = purple_account_new("test", "test"); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
642 | purple_account_set_remember_password(account, TRUE); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
643 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
644 | purple_credential_manager_clear_password_async(m, account, NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
645 | test_purple_credential_manager_clear_password_cb, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
646 | account); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
647 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
648 | return FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
649 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
650 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
651 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
652 | test_purple_credential_manager_clear_password_async(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
653 | PurpleCredentialManager *m = purple_credential_manager_get_default(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
654 | PurpleCredentialProvider *p = test_purple_credential_provider_new(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
655 | GError *e = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
656 | gboolean r = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
657 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
658 | r = purple_credential_manager_register_provider(m, p, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
659 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
660 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
661 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
662 | r = purple_credential_manager_set_active_provider(m, "test-provider", &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
663 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
664 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
665 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
666 | g_idle_add(test_purple_credential_manager_clear_password_idle, m); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
667 | g_timeout_add_seconds(10, test_purple_credential_manager_timeout_cb, loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
668 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
669 | g_main_loop_run(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
670 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
671 | r = purple_credential_manager_set_active_provider(m, NULL, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
672 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
673 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
674 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
675 | r = purple_credential_manager_unregister_provider(m, p, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
676 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
677 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
678 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
679 | g_clear_object(&p); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
680 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
681 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
682 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
683 | test_purple_credential_manager_settings(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
684 | PurpleCredentialManager *m = purple_credential_manager_get_default(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
685 | PurpleCredentialProvider *p = test_purple_credential_provider_new(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
686 | TestPurpleCredentialProvider *tp = TEST_PURPLE_CREDENTIAL_PROVIDER(p); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
687 | PurpleRequestFields *fields = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
688 | GError *e = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
689 | gboolean r = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
690 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
691 | r = purple_credential_manager_register_provider(m, p, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
692 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
693 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
694 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
695 | r = purple_credential_manager_set_active_provider(m, "test-provider", &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
696 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
697 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
698 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
699 | fields = purple_credential_manager_read_settings(m, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
700 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
701 | g_assert_nonnull(fields); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
702 | purple_request_fields_destroy(fields); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
703 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
704 | fields = purple_request_fields_new(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
705 | r = purple_credential_manager_write_settings(m, fields, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
706 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
707 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
708 | g_assert_true(tp->fields == fields); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
709 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
710 | purple_request_fields_destroy(fields); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
711 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
712 | g_clear_object(&p); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
713 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
714 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
715 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
716 | * Main |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
717 | *****************************************************************************/ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
718 | gint |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
719 | main(gint argc, gchar *argv[]) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
720 | gint ret = 0; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
721 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
722 | g_test_init(&argc, &argv, NULL); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
723 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
724 | test_ui_purple_init(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
725 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
726 | loop = g_main_loop_new(NULL, FALSE); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
727 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
728 | g_test_add_func("/credential-manager/get-default", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
729 | test_purple_credential_manager_get_default); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
730 | g_test_add_func("/credential-manager/registration", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
731 | test_purple_credential_manager_registration); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
732 | g_test_add_func("/credential-manager/set-active/null", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
733 | test_purple_credential_manager_set_active_null); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
734 | g_test_add_func("/credential-manager/set-active/non-existent", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
735 | test_purple_credential_manager_set_active_non_existent); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
736 | g_test_add_func("/credential-manager/set-active/normal", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
737 | test_purple_credential_manager_set_active_normal); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
738 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
739 | 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
|
740 | test_purple_credential_manager_no_provider_read_password_async); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
741 | 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
|
742 | test_purple_credential_manager_no_provider_write_password_async); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
743 | 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
|
744 | test_purple_credential_manager_no_provider_clear_password_async); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
745 | g_test_add_func("/credential-manager/no-provider/read-settings", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
746 | test_purple_credential_manager_no_provider_read_settings); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
747 | g_test_add_func("/credential-manager/no-provider/write-settings", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
748 | test_purple_credential_manager_no_provider_write_settings); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
749 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
750 | g_test_add_func("/credential-manager/provider/read-password-async", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
751 | test_purple_credential_manager_read_password_async); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
752 | g_test_add_func("/credential-manager/provider/write-password-async", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
753 | test_purple_credential_manager_write_password_async); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
754 | g_test_add_func("/credential-manager/provider/clear-password-async", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
755 | test_purple_credential_manager_clear_password_async); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
756 | g_test_add_func("/credential-manager/provider/settings", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
757 | test_purple_credential_manager_settings); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
758 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
759 | ret = g_test_run(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
760 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
761 | g_main_loop_unref(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
762 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
763 | return ret; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
764 | } |