Thu, 23 Mar 2023 23:11:59 -0500
Fix several leaks in tests
All of these are specific to tests, not the library code.
For the moment, `protocol_xfer` still leaks connections (and anything they hold on to) because it is very difficult to disentangle them from the connection manager in the partially implemented state they are in.
This fixes leaks of options in the account option test (these two leaks occur for every test since they all leak the option):
```
61 (48 direct, 13 indirect) bytes in 1 blocks are definitely lost in loss record 133 of 276
at 0x4848464: calloc (vg_replace_malloc.c:1340)
by 0x49F75F0: g_malloc0 (gmem.c:163)
by 0x48C3B2E: purple_account_option_new (purpleaccountoption.c:78)
by 0x4014AF: test_purple_account_option_copy_int (test_account_option.c:67)
by 0x4A1CC7D: UnknownInlinedFun (gtestutils.c:2933)
by 0x4A1CC7D: g_test_run_suite_internal (gtestutils.c:3021)
by 0x4A1C9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A1C9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A1D181: g_test_run_suite (gtestutils.c:3115)
by 0x4A156EC: UnknownInlinedFun (gtestutils.c:2234)
by 0x4A156EC: g_test_run (gtestutils.c:2221)
by 0x401721: main (test_account_option.c:157)
61 (48 direct, 13 indirect) bytes in 1 blocks are definitely lost in loss record 134 of 276
at 0x4848464: calloc (vg_replace_malloc.c:1340)
by 0x49F75F0: g_malloc0 (gmem.c:163)
by 0x48C3BC7: purple_account_option_copy (purpleaccountoption.c:93)
by 0x4014BF: test_purple_account_option_copy_int (test_account_option.c:68)
by 0x4A1CC7D: UnknownInlinedFun (gtestutils.c:2933)
by 0x4A1CC7D: g_test_run_suite_internal (gtestutils.c:3021)
by 0x4A1C9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A1C9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A1D181: g_test_run_suite (gtestutils.c:3115)
by 0x4A156EC: UnknownInlinedFun (gtestutils.c:2234)
by 0x4A156EC: g_test_run (gtestutils.c:2221)
by 0x401721: main (test_account_option.c:157)
```
leaks in the credential manager test (times 3 for read/write/cancel tests):
```
69 (16 direct, 53 indirect) bytes in 1 blocks are definitely lost in loss record 2,427 of 3,503
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4A58168: g_malloc (gmem.c:130)
by 0x4A6FAB5: g_slice_alloc (gslice.c:1074)
by 0x4A700EC: g_slice_alloc0 (gslice.c:1100)
by 0x4A3BECB: g_error_allocate (gerror.c:710)
by 0x4A3C93F: UnknownInlinedFun (gerror.c:724)
by 0x4A3C93F: g_error_new_valist (gerror.c:766)
by 0x4BEE558: g_task_return_new_error (gtask.c:1941)
by 0x48D82C0: purple_credential_manager_read_password_async (purplecredentialmanager.c:492)
by 0x403634: test_purple_credential_manager_no_provider_read_password_idle (test_credential_manager.c:329)
by 0x4A4ECB1: g_idle_dispatch (gmain.c:6124)
by 0x4A4FCBE: UnknownInlinedFun (gmain.c:3444)
by 0x4A4FCBE: g_main_context_dispatch (gmain.c:4162)
by 0x4AA5597: g_main_context_iterate.constprop.0 (gmain.c:4238)
by 0x4A4F28E: g_main_loop_run (gmain.c:4438)
by 0x40369F: test_purple_credential_manager_no_provider_read_password_async (test_credential_manager.c:345)
by 0x4A7DC7D: UnknownInlinedFun (gtestutils.c:2933)
by 0x4A7DC7D: g_test_run_suite_internal (gtestutils.c:3021)
by 0x4A7D9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A7D9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A7E181: g_test_run_suite (gtestutils.c:3115)
by 0x4A766EC: UnknownInlinedFun (gtestutils.c:2234)
by 0x4A766EC: g_test_run (gtestutils.c:2221)
by 0x4048F6: main (test_credential_manager.c:695)
```
a leak in the image test:
```
161 bytes in 1 blocks are definitely lost in loss record 260 of 274
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4A55363: g_try_malloc (gmem.c:286)
by 0x4A3D630: UnknownInlinedFun (gfileutils.c:819)
by 0x4A3D630: UnknownInlinedFun (gfileutils.c:924)
by 0x4A3D630: g_file_get_contents (gfileutils.c:1027)
by 0x401890: test_image_new_from_file (test_image.c:144)
by 0x4A7DC7D: UnknownInlinedFun (gtestutils.c:2933)
by 0x4A7DC7D: g_test_run_suite_internal (gtestutils.c:3021)
by 0x4A7D9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A7E181: g_test_run_suite (gtestutils.c:3115)
by 0x4A766EC: UnknownInlinedFun (gtestutils.c:2234)
by 0x4A766EC: g_test_run (gtestutils.c:2221)
by 0x40195D: main (test_image.c:172)
```
a leak in queued output stream test:
```
72 (40 direct, 32 indirect) bytes in 1 blocks are definitely lost in loss record 219 of 396
at 0x49D51EF: g_type_create_instance (gtype.c:1909)
by 0x49BAC1F: g_object_new_internal (gobject.c:2228)
by 0x49BC247: g_object_new_with_properties (gobject.c:2391)
by 0x49BCFF0: g_object_new (gobject.c:2037)
by 0x402003: test_queued_output_stream_push_bytes_async_error (test_queued_output_stream.c:219)
by 0x4A7DC7D: UnknownInlinedFun (gtestutils.c:2933)
by 0x4A7DC7D: g_test_run_suite_internal (gtestutils.c:3021)
by 0x4A7D9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A7E181: g_test_run_suite (gtestutils.c:3115)
by 0x4A766EC: UnknownInlinedFun (gtestutils.c:2234)
by 0x4A766EC: g_test_run (gtestutils.c:2221)
by 0x402429: main (test_queued_output_stream.c:280)
```
and protocol xfer tests (times 3 for each test that creates a test protocol object):
```
112 (48 direct, 64 indirect) bytes in 1 blocks are definitely lost in loss record 3,430 of 3,698
at 0x49D51EF: g_type_create_instance (gtype.c:1909)
by 0x49BAC1F: g_object_new_internal (gobject.c:2228)
by 0x49BC247: g_object_new_with_properties (gobject.c:2391)
by 0x49BCFF0: g_object_new (gobject.c:2037)
by 0x40291C: test_purple_protocol_xfer_send_file_func (test_protocol_xfer.c:146)
by 0x4A7DC7D: UnknownInlinedFun (gtestutils.c:2933)
by 0x4A7DC7D: g_test_run_suite_internal (gtestutils.c:3021)
by 0x4A7D9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A7E181: g_test_run_suite (gtestutils.c:3115)
by 0x4A766EC: UnknownInlinedFun (gtestutils.c:2234)
by 0x4A766EC: g_test_run (gtestutils.c:2221)
by 0x402B64: main (test_protocol_xfer.c:195)
```
and util tests (times 3 for each call to `purple_text_strip_mnemonic` in the test):
```
5 bytes in 1 blocks are definitely lost in loss record 5 of 247
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x49F7168: g_malloc (gmem.c:130)
by 0x491975B: purple_text_strip_mnemonic (util.c:895)
by 0x4015B0: test_util_text_strip_mnemonic (test_util.c:49)
by 0x4A1CC7D: UnknownInlinedFun (gtestutils.c:2933)
by 0x4A1CC7D: g_test_run_suite_internal (gtestutils.c:3021)
by 0x4A1C9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A1C9E4: g_test_run_suite_internal (gtestutils.c:3038)
by 0x4A1D181: g_test_run_suite (gtestutils.c:3115)
by 0x4A156EC: UnknownInlinedFun (gtestutils.c:2234)
by 0x4A156EC: g_test_run (gtestutils.c:2221)
by 0x401901: main (test_util.c:224)
```
and these leaks in any test that initializes the test UI:
```
4,104 bytes in 1 blocks are possibly lost in loss record 3,451 of 3,457
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x5235B67: sqlite3MemMalloc.lto_priv.0 (sqlite3.c:25493)
by 0x5232797: UnknownInlinedFun (sqlite3.c:29181)
by 0x5232797: UnknownInlinedFun (sqlite3.c:29227)
by 0x5232797: sqlite3Malloc.lto_priv.0 (sqlite3.c:29221)
by 0x523BD8B: pcache1Alloc.lto_priv.0 (sqlite3.c:53546)
by 0x5249A8B: UnknownInlinedFun (sqlite3.c:53675)
by 0x5249A8B: allocateTempSpace (sqlite3.c:70848)
by 0x52625A6: sqlite3VdbeExec.lto_priv.0 (sqlite3.c:93857)
by 0x525CBEE: UnknownInlinedFun (sqlite3.c:87995)
by 0x525CBEE: UnknownInlinedFun (sqlite3.c:88056)
by 0x525CBEE: sqlite3_step (sqlite3.c:88045)
by 0x529B324: sqlite3_exec (sqlite3.c:131002)
by 0x48FD558: purple_sqlite3_run_migration (purplesqlite3.c:37)
by 0x48FDBB4: purple_sqlite3_run_migrations_from_resources (purplesqlite3.c:195)
by 0x48FDED9: purple_sqlite_history_adapter_run_migrations (purplesqlitehistoryadapter.c:69)
by 0x48FE7F0: purple_sqlite_history_adapter_activate (purplesqlitehistoryadapter.c:287)
by 0x48DB656: purple_history_adapter_activate (purplehistoryadapter.c:181)
by 0x48DC9BC: purple_history_manager_set_active (purplehistorymanager.c:308)
by 0x402BA8: test_ui_init_history (test_ui.c:132)
by 0x402C80: test_ui_purple_init (test_ui.c:167)
by 0x4027BB: main (test_contact.c:88)
4,368 bytes in 1 blocks are possibly lost in loss record 3,453 of 3,457
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x5235B67: sqlite3MemMalloc.lto_priv.0 (sqlite3.c:25493)
by 0x5232797: UnknownInlinedFun (sqlite3.c:29181)
by 0x5232797: UnknownInlinedFun (sqlite3.c:29227)
by 0x5232797: sqlite3Malloc.lto_priv.0 (sqlite3.c:29221)
by 0x523BD8B: pcache1Alloc.lto_priv.0 (sqlite3.c:53546)
by 0x5240077: UnknownInlinedFun (sqlite3.c:53634)
by 0x5240077: pcache1FetchStage2 (sqlite3.c:54104)
by 0x5243E9C: UnknownInlinedFun (sqlite3.c:52671)
by 0x5243E9C: getPageNormal.lto_priv.0 (sqlite3.c:60628)
by 0x524A510: UnknownInlinedFun (sqlite3.c:60805)
by 0x524A510: btreeGetPage.lto_priv.0 (sqlite3.c:70289)
by 0x524C2F6: UnknownInlinedFun (sqlite3.c:71257)
by 0x524C2F6: sqlite3BtreeBeginTrans.lto_priv.0 (sqlite3.c:71647)
by 0x5266B3A: sqlite3VdbeExec.lto_priv.0 (sqlite3.c:93532)
by 0x525CBEE: UnknownInlinedFun (sqlite3.c:87995)
by 0x525CBEE: UnknownInlinedFun (sqlite3.c:88056)
by 0x525CBEE: sqlite3_step (sqlite3.c:88045)
by 0x48FD715: purple_sqlite3_get_schema_version (purplesqlite3.c:79)
by 0x48FD9DD: purple_sqlite3_run_migrations_from_resources (purplesqlite3.c:146)
by 0x48FDED9: purple_sqlite_history_adapter_run_migrations (purplesqlitehistoryadapter.c:69)
by 0x48FE7F0: purple_sqlite_history_adapter_activate (purplesqlitehistoryadapter.c:287)
by 0x48DB656: purple_history_adapter_activate (purplehistoryadapter.c:181)
by 0x48DC9BC: purple_history_manager_set_active (purplehistorymanager.c:308)
by 0x402BA8: test_ui_init_history (test_ui.c:132)
by 0x402C80: test_ui_purple_init (test_ui.c:167)
by 0x4027BB: main (test_contact.c:88)
4,368 bytes in 1 blocks are possibly lost in loss record 3,454 of 3,457
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x5235B67: sqlite3MemMalloc.lto_priv.0 (sqlite3.c:25493)
by 0x5232797: UnknownInlinedFun (sqlite3.c:29181)
by 0x5232797: UnknownInlinedFun (sqlite3.c:29227)
by 0x5232797: sqlite3Malloc.lto_priv.0 (sqlite3.c:29221)
by 0x523BD8B: pcache1Alloc.lto_priv.0 (sqlite3.c:53546)
by 0x5240077: UnknownInlinedFun (sqlite3.c:53634)
by 0x5240077: pcache1FetchStage2 (sqlite3.c:54104)
by 0x5243E9C: UnknownInlinedFun (sqlite3.c:52671)
by 0x5243E9C: getPageNormal.lto_priv.0 (sqlite3.c:60628)
by 0x52499BC: UnknownInlinedFun (sqlite3.c:60805)
by 0x52499BC: UnknownInlinedFun (sqlite3.c:70289)
by 0x52499BC: btreeGetUnusedPage (sqlite3.c:70432)
by 0x524F504: allocateBtreePage.lto_priv.0 (sqlite3.c:74604)
by 0x5256209: btreeCreateTable.lto_priv.0 (sqlite3.c:77830)
by 0x5265EB2: UnknownInlinedFun (sqlite3.c:77849)
by 0x5265EB2: sqlite3VdbeExec.lto_priv.0 (sqlite3.c:96382)
by 0x525CBEE: UnknownInlinedFun (sqlite3.c:87995)
by 0x525CBEE: UnknownInlinedFun (sqlite3.c:88056)
by 0x525CBEE: sqlite3_step (sqlite3.c:88045)
by 0x529B324: sqlite3_exec (sqlite3.c:131002)
by 0x48FD558: purple_sqlite3_run_migration (purplesqlite3.c:37)
by 0x48FDBB4: purple_sqlite3_run_migrations_from_resources (purplesqlite3.c:195)
by 0x48FDED9: purple_sqlite_history_adapter_run_migrations (purplesqlitehistoryadapter.c:69)
by 0x48FE7F0: purple_sqlite_history_adapter_activate (purplesqlitehistoryadapter.c:287)
by 0x48DB656: purple_history_adapter_activate (purplehistoryadapter.c:181)
by 0x48DC9BC: purple_history_manager_set_active (purplehistorymanager.c:308)
by 0x402BA8: test_ui_init_history (test_ui.c:132)
by 0x402C80: test_ui_purple_init (test_ui.c:167)
by 0x4027BB: main (test_contact.c:88)
```
Testing Done:
Ran tests in valgrind, and all above leaks were gone except for noted `protocol_xfer` issues, and a bunch of leaks of the `PurpleBuddy`-`PurpleContact` compatibility bindings, which will go away in their entirety eventually.
Reviewed at https://reviews.imfreedom.org/r/2385/
|
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 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | G_DEFINE_TYPE(TestPurpleCredentialProvider, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | test_purple_credential_provider, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | PURPLE_TYPE_CREDENTIAL_PROVIDER) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | test_purple_credential_provider_read_password_async(PurpleCredentialProvider *p, |
|
42089
083eae91c9a8
Update the libpurple tests for the warning level 2 update
Gary Kramlich <grim@reaperworld.com>
parents:
41982
diff
changeset
|
65 | G_GNUC_UNUSED PurpleAccount *account, |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | GCancellable *cancellable, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | GAsyncReadyCallback callback, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | gpointer data) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | GTask *task = NULL; |
|
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 | task = g_task_new(p, cancellable, callback, data); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | g_task_return_pointer(task, g_strdup("password"), g_free); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | g_clear_object(&task); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | static gchar * |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | test_purple_credential_provider_read_password_finish(PurpleCredentialProvider *p, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | GAsyncResult *result, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | GError **error) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | 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
|
83 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | return g_task_propagate_pointer(G_TASK(result), error); |
|
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 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | test_purple_credential_provider_write_password_async(PurpleCredentialProvider *p, |
|
42089
083eae91c9a8
Update the libpurple tests for the warning level 2 update
Gary Kramlich <grim@reaperworld.com>
parents:
41982
diff
changeset
|
89 | G_GNUC_UNUSED PurpleAccount *account, |
|
083eae91c9a8
Update the libpurple tests for the warning level 2 update
Gary Kramlich <grim@reaperworld.com>
parents:
41982
diff
changeset
|
90 | G_GNUC_UNUSED const gchar *password, |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | GCancellable *cancellable, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | GAsyncReadyCallback callback, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | gpointer data) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | GTask *task = NULL; |
|
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 | task = g_task_new(p, cancellable, callback, data); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | g_task_return_boolean(task, TRUE); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | g_clear_object(&task); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | static gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | test_purple_credential_provider_write_password_finish(PurpleCredentialProvider *p, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
104 | GAsyncResult *result, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | GError **error) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | 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
|
108 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | return g_task_propagate_boolean(G_TASK(result), error); |
|
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 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | test_purple_credential_provider_clear_password_async(PurpleCredentialProvider *p, |
|
42089
083eae91c9a8
Update the libpurple tests for the warning level 2 update
Gary Kramlich <grim@reaperworld.com>
parents:
41982
diff
changeset
|
114 | G_GNUC_UNUSED PurpleAccount *account, |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | GCancellable *cancellable, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | GAsyncReadyCallback callback, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | gpointer data) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | GTask *task = NULL; |
|
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 | task = g_task_new(p, cancellable, callback, data); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | g_task_return_boolean(task, TRUE); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | g_clear_object(&task); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | static gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | test_purple_credential_provider_clear_password_finish(PurpleCredentialProvider *p, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | GAsyncResult *result, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | GError **error) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
131 | 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
|
132 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
133 | return g_task_propagate_boolean(G_TASK(result), error); |
|
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 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
136 | static void |
|
42089
083eae91c9a8
Update the libpurple tests for the warning level 2 update
Gary Kramlich <grim@reaperworld.com>
parents:
41982
diff
changeset
|
137 | test_purple_credential_provider_init(G_GNUC_UNUSED TestPurpleCredentialProvider *provider) { |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
139 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
140 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
141 | test_purple_credential_provider_class_init(TestPurpleCredentialProviderClass *klass) |
|
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 | PurpleCredentialProviderClass *provider_class = PURPLE_CREDENTIAL_PROVIDER_CLASS(klass); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
145 | 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
|
146 | 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
|
147 | 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
|
148 | 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
|
149 | 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
|
150 | 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
|
151 | } |
|
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 | static PurpleCredentialProvider * |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
154 | test_purple_credential_provider_new(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
155 | return g_object_new( |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
156 | TEST_PURPLE_TYPE_CREDENTIAL_PROVIDER, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
157 | "id", "test-provider", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
158 | "name", "Test Provider", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | NULL); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
160 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
161 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
162 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | * Get Default Tests |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
164 | *****************************************************************************/ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
165 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
166 | test_purple_credential_manager_get_default(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
167 | PurpleCredentialManager *manager1 = NULL, *manager2 = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
168 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
169 | manager1 = purple_credential_manager_get_default(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
170 | g_assert_true(PURPLE_IS_CREDENTIAL_MANAGER(manager1)); |
|
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 | manager2 = purple_credential_manager_get_default(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
173 | g_assert_true(PURPLE_IS_CREDENTIAL_MANAGER(manager2)); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
174 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
175 | g_assert_true(manager1 == manager2); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
176 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
177 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
178 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
179 | * Registration Tests |
|
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 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
182 | test_purple_credential_manager_registration(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
183 | PurpleCredentialManager *manager = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
184 | PurpleCredentialProvider *provider = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
185 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
186 | gboolean r = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
187 | |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
188 | manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
189 | g_assert_true(PURPLE_IS_CREDENTIAL_MANAGER(manager)); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
190 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
191 | provider = test_purple_credential_provider_new(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
192 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
193 | /* Register the first time cleanly. */ |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
194 | r = purple_credential_manager_register(manager, provider, &error); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
195 | g_assert_no_error(error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
196 | g_assert_true(r); |
|
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 | /* Register again and verify the error. */ |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
199 | r = purple_credential_manager_register(manager, provider, &error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
200 | g_assert_false(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
201 | g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
202 | g_clear_error(&error); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
203 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
204 | /* Unregister the provider. */ |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
205 | r = purple_credential_manager_unregister(manager, provider, &error); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
206 | g_assert_no_error(error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
207 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
208 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
209 | /* Unregister the provider again and verify the error. */ |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
210 | r = purple_credential_manager_unregister(manager, provider, &error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
211 | g_assert_false(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
212 | g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
213 | g_clear_error(&error); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
214 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
215 | /* Final clean ups. */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
216 | g_clear_object(&provider); |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
217 | g_clear_object(&manager); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
218 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
219 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
220 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
221 | * Set Active Tests |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
222 | *****************************************************************************/ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
223 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
224 | test_purple_credential_manager_set_active_null(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
225 | PurpleCredentialManager *manager = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
226 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
227 | gboolean ret = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
228 | |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
229 | manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
230 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
231 | ret = purple_credential_manager_set_active(manager, NULL, &error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
232 | |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
233 | g_assert_no_error(error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
234 | g_assert_true(ret); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
235 | |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
236 | g_clear_object(&manager); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
237 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
238 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
239 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
240 | test_purple_credential_manager_set_active_non_existent(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
241 | PurpleCredentialManager *manager = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
242 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
243 | gboolean ret = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
244 | |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
245 | manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
246 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
247 | ret = purple_credential_manager_set_active(manager, "foo", &error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
248 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
249 | g_assert_false(ret); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
250 | g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
251 | g_clear_error(&error); |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
252 | |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
253 | g_clear_object(&manager); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
254 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
255 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
256 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
257 | test_purple_credential_manager_set_active_normal(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
258 | PurpleCredentialManager *manager = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
259 | PurpleCredentialProvider *provider = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
260 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
261 | gboolean r = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
262 | |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
263 | manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL); |
|
40583
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 | /* Create the provider and register it in the manager. */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
266 | provider = test_purple_credential_provider_new(); |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
267 | r = purple_credential_manager_register(manager, provider, &error); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
268 | g_assert_no_error(error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
269 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
270 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
271 | /* Set the provider as active and verify it was successful. */ |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
272 | r = purple_credential_manager_set_active(manager, "test-provider", |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
273 | &error); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
274 | g_assert_no_error(error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
275 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
276 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
277 | /* Verify that unregistering the provider fails. */ |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
278 | r = purple_credential_manager_unregister(manager, provider, &error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
279 | g_assert_false(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
280 | g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
281 | g_clear_error(&error); |
|
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 | /* Now unset the active provider. */ |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
284 | r = purple_credential_manager_set_active(manager, NULL, &error); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
285 | g_assert_no_error(error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
286 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
287 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
288 | /* Finally unregister the provider now that it's no longer active. */ |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
289 | r = purple_credential_manager_unregister(manager, provider, &error); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
290 | g_assert_no_error(error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
291 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
292 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
293 | /* And our final cleanup. */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
294 | g_clear_object(&provider); |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
295 | g_clear_object(&manager); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
296 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
297 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
298 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
299 | * No Provider Tests |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
300 | *****************************************************************************/ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
301 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
302 | 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
|
303 | GAsyncResult *res, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
304 | gpointer d) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
305 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
306 | PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
307 | PurpleAccount *account = PURPLE_ACCOUNT(d); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
308 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
309 | gchar *password = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
310 | |
|
40680
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
311 | 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
|
312 | &error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
313 | g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0); |
|
42184
4e1bf25f5575
Fix several leaks in tests
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42128
diff
changeset
|
314 | g_clear_error(&error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
315 | g_assert_null(password); |
|
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 | g_clear_object(&account); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
318 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
319 | g_main_loop_quit(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
320 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
321 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
322 | static gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
323 | 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
|
324 | PurpleCredentialManager *m = PURPLE_CREDENTIAL_MANAGER(data); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
325 | PurpleAccount *account = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
326 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
327 | account = purple_account_new("test", "test"); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
328 | purple_account_set_remember_password(account, TRUE); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
329 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
330 | purple_credential_manager_read_password_async(m, account, NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
331 | test_purple_credential_manager_no_provider_read_password_cb, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
332 | account); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
333 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
334 | return FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
335 | } |
|
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 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
338 | test_purple_credential_manager_no_provider_read_password_async(void) { |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
339 | PurpleCredentialManager *m = NULL; |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
340 | |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
341 | m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
342 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
343 | 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
|
344 | 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
|
345 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
346 | g_main_loop_run(loop); |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
347 | |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
348 | g_clear_object(&m); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
349 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
350 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
351 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
352 | 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
|
353 | GAsyncResult *res, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
354 | gpointer d) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
355 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
356 | PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
357 | PurpleAccount *account = PURPLE_ACCOUNT(d); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
358 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
359 | gboolean r = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
360 | |
|
40680
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
361 | 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
|
362 | g_assert_false(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
363 | g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0); |
|
42184
4e1bf25f5575
Fix several leaks in tests
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42128
diff
changeset
|
364 | g_clear_error(&error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
365 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
366 | g_clear_object(&account); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
367 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
368 | g_main_loop_quit(loop); |
|
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 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
371 | static gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
372 | 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
|
373 | PurpleCredentialManager *m = PURPLE_CREDENTIAL_MANAGER(data); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
374 | PurpleAccount *account = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
375 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
376 | account = purple_account_new("test", "test"); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
377 | purple_account_set_remember_password(account, TRUE); |
|
40583
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 | purple_credential_manager_write_password_async(m, account, NULL, NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
380 | test_purple_credential_manager_no_provider_write_password_cb, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
381 | account); |
|
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 | return FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
384 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
385 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
386 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
387 | test_purple_credential_manager_no_provider_write_password_async(void) { |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
388 | PurpleCredentialManager *m = NULL; |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
389 | |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
390 | m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL); |
|
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 | 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
|
393 | m); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
394 | 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
|
395 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
396 | g_main_loop_run(loop); |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
397 | |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
398 | g_clear_object(&m); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
399 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
400 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
401 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
402 | 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
|
403 | GAsyncResult *res, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
404 | gpointer d) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
405 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
406 | PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
407 | PurpleAccount *account = PURPLE_ACCOUNT(d); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
408 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
409 | gboolean r = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
410 | |
|
40680
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
411 | 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
|
412 | g_assert_false(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
413 | g_assert_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0); |
|
42184
4e1bf25f5575
Fix several leaks in tests
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42128
diff
changeset
|
414 | g_clear_error(&error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
415 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
416 | g_clear_object(&account); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
417 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
418 | g_main_loop_quit(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
419 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
420 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
421 | static gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
422 | 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
|
423 | PurpleCredentialManager *m = PURPLE_CREDENTIAL_MANAGER(data); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
424 | PurpleAccount *account = NULL; |
|
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 | account = purple_account_new("test", "test"); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
427 | purple_account_set_remember_password(account, TRUE); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
428 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
429 | purple_credential_manager_clear_password_async(m, account, NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
430 | test_purple_credential_manager_no_provider_clear_password_cb, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
431 | account); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
432 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
433 | return FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
434 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
435 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
436 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
437 | test_purple_credential_manager_no_provider_clear_password_async(void) { |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
438 | PurpleCredentialManager *m = NULL; |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
439 | |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
440 | m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
441 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
442 | 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
|
443 | m); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
444 | 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
|
445 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
446 | g_main_loop_run(loop); |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
447 | |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
448 | g_clear_object(&m); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
449 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
450 | |
|
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 | * Provider Tests |
|
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 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
455 | 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
|
456 | gpointer d) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
457 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
458 | PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
459 | PurpleAccount *account = PURPLE_ACCOUNT(d); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
460 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
461 | gchar *password = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
462 | |
|
40680
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
463 | 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
|
464 | &error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
465 | g_assert_no_error(error); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
466 | g_assert_cmpstr(password, ==, "password"); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
467 | g_free(password); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
468 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
469 | g_clear_object(&account); |
|
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 | g_main_loop_quit(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
472 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
473 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
474 | static gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
475 | test_purple_credential_manager_read_password_idle(gpointer data) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
476 | PurpleCredentialManager *m = PURPLE_CREDENTIAL_MANAGER(data); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
477 | PurpleAccount *account = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
478 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
479 | account = purple_account_new("test", "test"); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
480 | purple_account_set_remember_password(account, TRUE); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
481 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
482 | purple_credential_manager_read_password_async(m, account, NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
483 | test_purple_credential_manager_read_password_cb, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
484 | account); |
|
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 | return FALSE; |
|
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 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
489 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
490 | test_purple_credential_manager_read_password_async(void) { |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
491 | PurpleCredentialManager *m = NULL; |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
492 | PurpleCredentialProvider *p = NULL; |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
493 | GError *e = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
494 | gboolean r = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
495 | |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
496 | m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL); |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
497 | p = test_purple_credential_provider_new(); |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
498 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
499 | r = purple_credential_manager_register(m, p, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
500 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
501 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
502 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
503 | r = purple_credential_manager_set_active(m, "test-provider", &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
504 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
505 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
506 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
507 | 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
|
508 | 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
|
509 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
510 | g_main_loop_run(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
511 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
512 | r = purple_credential_manager_set_active(m, NULL, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
513 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
514 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
515 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
516 | r = purple_credential_manager_unregister(m, p, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
517 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
518 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
519 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
520 | g_clear_object(&p); |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
521 | g_clear_object(&m); |
|
40583
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 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
524 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
525 | test_purple_credential_manager_write_password_cb(GObject *obj, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
526 | GAsyncResult *res, gpointer d) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
527 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
528 | PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
529 | PurpleAccount *account = PURPLE_ACCOUNT(d); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
530 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
531 | gboolean r = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
532 | |
|
40680
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
533 | 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
|
534 | g_assert_no_error(error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
535 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
536 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
537 | g_clear_object(&account); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
538 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
539 | g_main_loop_quit(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 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
542 | static gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
543 | test_purple_credential_manager_write_password_idle(gpointer data) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
544 | PurpleCredentialManager *m = PURPLE_CREDENTIAL_MANAGER(data); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
545 | PurpleAccount *account = NULL; |
|
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 | account = purple_account_new("test", "test"); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
548 | purple_account_set_remember_password(account, TRUE); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
549 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
550 | purple_credential_manager_write_password_async(m, account, NULL, NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
551 | test_purple_credential_manager_write_password_cb, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
552 | account); |
|
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 | return FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
555 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
556 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
557 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
558 | test_purple_credential_manager_write_password_async(void) { |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
559 | PurpleCredentialManager *m = NULL; |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
560 | PurpleCredentialProvider *p = NULL; |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
561 | GError *e = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
562 | gboolean r = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
563 | |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
564 | m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL); |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
565 | p = test_purple_credential_provider_new(); |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
566 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
567 | r = purple_credential_manager_register(m, p, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
568 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
569 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
570 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
571 | r = purple_credential_manager_set_active(m, "test-provider", &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
572 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
573 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
574 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
575 | 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
|
576 | 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
|
577 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
578 | g_main_loop_run(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
579 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
580 | r = purple_credential_manager_set_active(m, NULL, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
581 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
582 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
583 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
584 | r = purple_credential_manager_unregister(m, p, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
585 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
586 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
587 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
588 | g_clear_object(&p); |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
589 | g_clear_object(&m); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
590 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
591 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
592 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
593 | test_purple_credential_manager_clear_password_cb(GObject *obj, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
594 | GAsyncResult *res, gpointer d) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
595 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
596 | PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
597 | PurpleAccount *account = PURPLE_ACCOUNT(d); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
598 | GError *error = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
599 | gboolean r = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
600 | |
|
40680
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
601 | 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
|
602 | g_assert_no_error(error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
603 | g_assert_true(r); |
|
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_clear_object(&account); |
|
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 | g_main_loop_quit(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
608 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
609 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
610 | static gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
611 | test_purple_credential_manager_clear_password_idle(gpointer data) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
612 | PurpleCredentialManager *m = PURPLE_CREDENTIAL_MANAGER(data); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
613 | PurpleAccount *account = NULL; |
|
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 | account = purple_account_new("test", "test"); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
616 | purple_account_set_remember_password(account, TRUE); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
617 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
618 | purple_credential_manager_clear_password_async(m, account, NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
619 | test_purple_credential_manager_clear_password_cb, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
620 | account); |
|
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 | return FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
623 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
624 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
625 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
626 | test_purple_credential_manager_clear_password_async(void) { |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
627 | PurpleCredentialManager *m = NULL; |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
628 | PurpleCredentialProvider *p = NULL; |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
629 | GError *e = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
630 | gboolean r = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
631 | |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
632 | m = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL); |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
633 | p = test_purple_credential_provider_new(); |
|
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
634 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
635 | r = purple_credential_manager_register(m, p, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
636 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
637 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
638 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
639 | r = purple_credential_manager_set_active(m, "test-provider", &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
640 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
641 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
642 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
643 | 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
|
644 | 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
|
645 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
646 | g_main_loop_run(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
647 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
648 | r = purple_credential_manager_set_active(m, NULL, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
649 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
650 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
651 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
652 | r = purple_credential_manager_unregister(m, p, &e); |
|
40684
a0c11a532ee7
Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
40680
diff
changeset
|
653 | g_assert_no_error(e); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
654 | g_assert_true(r); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
655 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
656 | g_clear_object(&p); |
|
41809
94c31400486a
Don't use the default credential manager while unit testing aside from the default manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
657 | g_clear_object(&m); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
658 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
659 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
660 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
661 | * Main |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
662 | *****************************************************************************/ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
663 | gint |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
664 | main(gint argc, gchar *argv[]) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
665 | gint ret = 0; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
666 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
667 | g_test_init(&argc, &argv, NULL); |
|
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 | test_ui_purple_init(); |
|
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 | loop = g_main_loop_new(NULL, FALSE); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
672 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
673 | g_test_add_func("/credential-manager/get-default", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
674 | test_purple_credential_manager_get_default); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
675 | g_test_add_func("/credential-manager/registration", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
676 | test_purple_credential_manager_registration); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
677 | g_test_add_func("/credential-manager/set-active/null", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
678 | test_purple_credential_manager_set_active_null); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
679 | g_test_add_func("/credential-manager/set-active/non-existent", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
680 | test_purple_credential_manager_set_active_non_existent); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
681 | g_test_add_func("/credential-manager/set-active/normal", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
682 | test_purple_credential_manager_set_active_normal); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
683 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
684 | 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
|
685 | test_purple_credential_manager_no_provider_read_password_async); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
686 | 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
|
687 | test_purple_credential_manager_no_provider_write_password_async); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
688 | 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
|
689 | test_purple_credential_manager_no_provider_clear_password_async); |
|
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 | g_test_add_func("/credential-manager/provider/read-password-async", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
692 | test_purple_credential_manager_read_password_async); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
693 | g_test_add_func("/credential-manager/provider/write-password-async", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
694 | test_purple_credential_manager_write_password_async); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
695 | g_test_add_func("/credential-manager/provider/clear-password-async", |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
696 | test_purple_credential_manager_clear_password_async); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
697 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
698 | ret = g_test_run(); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
699 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
700 | g_main_loop_unref(loop); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
701 | |
|
42184
4e1bf25f5575
Fix several leaks in tests
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42128
diff
changeset
|
702 | test_ui_purple_uninit(); |
|
4e1bf25f5575
Fix several leaks in tests
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42128
diff
changeset
|
703 | |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
704 | return ret; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
705 | } |