1 /* libsecret - GLib wrapper for Secret Service
3 * Copyright 2011 Collabora Ltd.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published
7 * by the Free Software Foundation; either version 2 of the licence or (at
8 * your option) any later version.
10 * See the included COPYING file for more information.
16 #include "secret-attributes.h"
17 #include "secret-collection.h"
18 #include "secret-item.h"
19 #include "secret-paths.h"
20 #include "secret-private.h"
21 #include "secret-service.h"
23 #include "mock-service.h"
25 #include "egg/egg-testing.h"
32 static const SecretSchema MOCK_SCHEMA = {
36 { "number", SECRET_SCHEMA_ATTRIBUTE_INTEGER },
37 { "string", SECRET_SCHEMA_ATTRIBUTE_STRING },
38 { "even", SECRET_SCHEMA_ATTRIBUTE_BOOLEAN },
42 static const SecretSchema PRIME_SCHEMA = {
46 { "number", SECRET_SCHEMA_ATTRIBUTE_INTEGER },
47 { "string", SECRET_SCHEMA_ATTRIBUTE_STRING },
48 { "prime", SECRET_SCHEMA_ATTRIBUTE_BOOLEAN },
52 static const SecretSchema NO_NAME_SCHEMA = {
54 SECRET_SCHEMA_DONT_MATCH_NAME,
56 { "number", SECRET_SCHEMA_ATTRIBUTE_INTEGER },
57 { "string", SECRET_SCHEMA_ATTRIBUTE_STRING },
62 SecretService *service;
66 setup_mock (Test *test,
70 const gchar *mock_script = data;
72 mock_service_start (mock_script, &error);
73 g_assert_no_error (error);
82 setup_mock (test, data);
84 test->service = secret_service_get_sync (SECRET_SERVICE_NONE, NULL, &error);
85 g_assert_no_error (error);
89 teardown_mock (Test *test,
99 egg_test_wait_idle ();
101 g_object_unref (test->service);
102 secret_service_disconnect ();
103 egg_assert_not_object (test->service);
105 teardown_mock (test, unused);
109 on_complete_get_result (GObject *source,
110 GAsyncResult *result,
113 GAsyncResult **ret = user_data;
114 g_assert (ret != NULL);
115 g_assert (*ret == NULL);
116 *ret = g_object_ref (result);
117 egg_test_wait_stop ();
121 test_search_sync (Test *test,
124 GHashTable *attributes;
125 GError *error = NULL;
128 attributes = g_hash_table_new (g_str_hash, g_str_equal);
129 g_hash_table_insert (attributes, "number", "1");
131 items = secret_service_search_sync (test->service, &MOCK_SCHEMA, attributes,
132 SECRET_SEARCH_NONE, NULL, &error);
133 g_assert_no_error (error);
134 g_hash_table_unref (attributes);
136 g_assert (items != NULL);
137 g_assert_cmpstr (g_dbus_proxy_get_object_path (items->data), ==, "/org/freedesktop/secrets/collection/english/1");
139 g_assert (items->next == NULL);
140 g_list_free_full (items, g_object_unref);
144 test_search_async (Test *test,
147 GAsyncResult *result = NULL;
148 GHashTable *attributes;
149 GError *error = NULL;
152 attributes = g_hash_table_new (g_str_hash, g_str_equal);
153 g_hash_table_insert (attributes, "number", "1");
155 secret_service_search (test->service, &MOCK_SCHEMA, attributes,
156 SECRET_SEARCH_NONE, NULL,
157 on_complete_get_result, &result);
158 g_hash_table_unref (attributes);
159 g_assert (result == NULL);
163 g_assert (G_IS_ASYNC_RESULT (result));
164 items = secret_service_search_finish (test->service, result, &error);
165 g_assert_no_error (error);
166 g_object_unref (result);
168 g_assert (items != NULL);
169 g_assert_cmpstr (g_dbus_proxy_get_object_path (items->data), ==, "/org/freedesktop/secrets/collection/english/1");
171 g_assert (items->next == NULL);
172 g_list_free_full (items, g_object_unref);
176 test_search_all_sync (Test *test,
179 GHashTable *attributes;
180 GError *error = NULL;
183 attributes = g_hash_table_new (g_str_hash, g_str_equal);
184 g_hash_table_insert (attributes, "number", "1");
186 items = secret_service_search_sync (test->service, &MOCK_SCHEMA, attributes,
187 SECRET_SEARCH_ALL, NULL, &error);
188 g_assert_no_error (error);
189 g_hash_table_unref (attributes);
191 g_assert (items != NULL);
192 g_assert_cmpstr (g_dbus_proxy_get_object_path (items->data), ==, "/org/freedesktop/secrets/collection/english/1");
193 g_assert (secret_item_get_locked (items->data) == FALSE);
194 g_assert (secret_item_get_secret (items->data) == NULL);
196 g_assert (items->next != NULL);
197 g_assert_cmpstr (g_dbus_proxy_get_object_path (items->next->data), ==, "/org/freedesktop/secrets/collection/spanish/10");
198 g_assert (secret_item_get_locked (items->next->data) == TRUE);
199 g_assert (secret_item_get_secret (items->next->data) == NULL);
201 g_assert (items->next->next == NULL);
202 g_list_free_full (items, g_object_unref);
206 test_search_all_async (Test *test,
209 GAsyncResult *result = NULL;
210 GHashTable *attributes;
211 GError *error = NULL;
214 attributes = g_hash_table_new (g_str_hash, g_str_equal);
215 g_hash_table_insert (attributes, "number", "1");
217 secret_service_search (test->service, &MOCK_SCHEMA, attributes,
218 SECRET_SEARCH_ALL, NULL,
219 on_complete_get_result, &result);
220 g_hash_table_unref (attributes);
221 g_assert (result == NULL);
225 g_assert (G_IS_ASYNC_RESULT (result));
226 items = secret_service_search_finish (test->service, result, &error);
227 g_assert_no_error (error);
228 g_object_unref (result);
230 g_assert (items != NULL);
231 g_assert_cmpstr (g_dbus_proxy_get_object_path (items->data), ==, "/org/freedesktop/secrets/collection/english/1");
232 g_assert (secret_item_get_locked (items->data) == FALSE);
233 g_assert (secret_item_get_secret (items->data) == NULL);
235 g_assert (items->next != NULL);
236 g_assert_cmpstr (g_dbus_proxy_get_object_path (items->next->data), ==, "/org/freedesktop/secrets/collection/spanish/10");
237 g_assert (secret_item_get_locked (items->next->data) == TRUE);
238 g_assert (secret_item_get_secret (items->next->data) == NULL);
240 g_assert (items->next->next == NULL);
241 g_list_free_full (items, g_object_unref);
245 test_search_unlock_sync (Test *test,
248 GHashTable *attributes;
249 GError *error = NULL;
252 attributes = g_hash_table_new (g_str_hash, g_str_equal);
253 g_hash_table_insert (attributes, "number", "1");
255 items = secret_service_search_sync (test->service, &MOCK_SCHEMA, attributes,
256 SECRET_SEARCH_ALL | SECRET_SEARCH_UNLOCK,
258 g_assert_no_error (error);
259 g_hash_table_unref (attributes);
261 g_assert (items != NULL);
262 g_assert_cmpstr (g_dbus_proxy_get_object_path (items->data), ==, "/org/freedesktop/secrets/collection/english/1");
263 g_assert (secret_item_get_locked (items->data) == FALSE);
264 g_assert (secret_item_get_secret (items->data) == NULL);
266 g_assert (items->next != NULL);
267 g_assert_cmpstr (g_dbus_proxy_get_object_path (items->next->data), ==, "/org/freedesktop/secrets/collection/spanish/10");
268 g_assert (secret_item_get_locked (items->next->data) == FALSE);
269 g_assert (secret_item_get_secret (items->next->data) == NULL);
271 g_assert (items->next->next == NULL);
272 g_list_free_full (items, g_object_unref);
276 test_search_unlock_async (Test *test,
279 GAsyncResult *result = NULL;
280 GHashTable *attributes;
281 GError *error = NULL;
284 attributes = g_hash_table_new (g_str_hash, g_str_equal);
285 g_hash_table_insert (attributes, "number", "1");
287 secret_service_search (test->service, &MOCK_SCHEMA, attributes,
288 SECRET_SEARCH_ALL | SECRET_SEARCH_UNLOCK, NULL,
289 on_complete_get_result, &result);
290 g_hash_table_unref (attributes);
291 g_assert (result == NULL);
295 g_assert (G_IS_ASYNC_RESULT (result));
296 items = secret_service_search_finish (test->service, result, &error);
297 g_assert_no_error (error);
298 g_object_unref (result);
300 g_assert (items != NULL);
301 g_assert_cmpstr (g_dbus_proxy_get_object_path (items->data), ==, "/org/freedesktop/secrets/collection/english/1");
302 g_assert (secret_item_get_locked (items->data) == FALSE);
303 g_assert (secret_item_get_secret (items->data) == NULL);
305 g_assert (items->next != NULL);
306 g_assert_cmpstr (g_dbus_proxy_get_object_path (items->next->data), ==, "/org/freedesktop/secrets/collection/spanish/10");
307 g_assert (secret_item_get_locked (items->next->data) == FALSE);
308 g_assert (secret_item_get_secret (items->next->data) == NULL);
310 g_assert (items->next->next == NULL);
311 g_list_free_full (items, g_object_unref);
315 test_search_secrets_sync (Test *test,
318 GHashTable *attributes;
319 GError *error = NULL;
323 attributes = g_hash_table_new (g_str_hash, g_str_equal);
324 g_hash_table_insert (attributes, "number", "1");
326 items = secret_service_search_sync (test->service, &MOCK_SCHEMA, attributes,
327 SECRET_SEARCH_ALL | SECRET_SEARCH_LOAD_SECRETS,
329 g_assert_no_error (error);
330 g_hash_table_unref (attributes);
332 g_assert (items != NULL);
333 g_assert_cmpstr (g_dbus_proxy_get_object_path (items->data), ==, "/org/freedesktop/secrets/collection/english/1");
334 g_assert (secret_item_get_locked (items->data) == FALSE);
335 value = secret_item_get_secret (items->data);
336 g_assert (value != NULL);
337 secret_value_unref (value);
339 g_assert (items->next != NULL);
340 g_assert_cmpstr (g_dbus_proxy_get_object_path (items->next->data), ==, "/org/freedesktop/secrets/collection/spanish/10");
341 g_assert (secret_item_get_locked (items->next->data) == TRUE);
342 g_assert (secret_item_get_secret (items->next->data) == NULL);
344 g_assert (items->next->next == NULL);
345 g_list_free_full (items, g_object_unref);
349 test_search_secrets_async (Test *test,
352 GAsyncResult *result = NULL;
353 GHashTable *attributes;
354 GError *error = NULL;
358 attributes = g_hash_table_new (g_str_hash, g_str_equal);
359 g_hash_table_insert (attributes, "number", "1");
361 secret_service_search (test->service, &MOCK_SCHEMA, attributes,
362 SECRET_SEARCH_ALL | SECRET_SEARCH_LOAD_SECRETS, NULL,
363 on_complete_get_result, &result);
364 g_hash_table_unref (attributes);
365 g_assert (result == NULL);
369 g_assert (G_IS_ASYNC_RESULT (result));
370 items = secret_service_search_finish (test->service, result, &error);
371 g_assert_no_error (error);
372 g_object_unref (result);
374 g_assert (items != NULL);
375 g_assert_cmpstr (g_dbus_proxy_get_object_path (items->data), ==, "/org/freedesktop/secrets/collection/english/1");
376 g_assert (secret_item_get_locked (items->data) == FALSE);
377 value = secret_item_get_secret (items->data);
378 g_assert (value != NULL);
379 secret_value_unref (value);
381 g_assert (items->next != NULL);
382 g_assert_cmpstr (g_dbus_proxy_get_object_path (items->next->data), ==, "/org/freedesktop/secrets/collection/spanish/10");
383 g_assert (secret_item_get_locked (items->next->data) == TRUE);
384 g_assert (secret_item_get_secret (items->next->data) == NULL);
386 g_assert (items->next->next == NULL);
387 g_list_free_full (items, g_object_unref);
391 test_lock_sync (Test *test,
394 const gchar *collection_path = "/org/freedesktop/secrets/collection/lockone";
395 SecretCollection *collection;
396 GError *error = NULL;
401 collection = secret_collection_new_for_dbus_path_sync (test->service, collection_path,
402 SECRET_COLLECTION_NONE, NULL, &error);
403 g_assert_no_error (error);
405 objects = g_list_append (NULL, collection);
407 ret = secret_service_lock_sync (test->service, objects, NULL, &locked, &error);
408 g_assert_no_error (error);
409 g_assert (ret == TRUE);
411 g_assert (locked != NULL);
412 g_assert (locked->data == collection);
413 g_assert (locked->next == NULL);
414 g_list_free_full (locked, g_object_unref);
416 g_list_free (objects);
417 g_object_unref (collection);
421 test_unlock_sync (Test *test,
424 const gchar *collection_path = "/org/freedesktop/secrets/collection/lockone";
425 SecretCollection *collection;
426 GError *error = NULL;
431 collection = secret_collection_new_for_dbus_path_sync (test->service, collection_path,
432 SECRET_COLLECTION_NONE, NULL, &error);
433 g_assert_no_error (error);
435 objects = g_list_append (NULL, collection);
437 ret = secret_service_unlock_sync (test->service, objects, NULL, &unlocked, &error);
438 g_assert_no_error (error);
439 g_assert (ret == TRUE);
441 g_assert (unlocked != NULL);
442 g_assert (unlocked->data == collection);
443 g_assert (unlocked->next == NULL);
444 g_list_free_full (unlocked, g_object_unref);
446 g_list_free (objects);
447 g_object_unref (collection);
451 test_remove_sync (Test *test,
454 GError *error = NULL;
455 GHashTable *attributes;
458 attributes = secret_attributes_build (&MOCK_SCHEMA,
464 ret = secret_service_remove_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
466 g_assert_no_error (error);
467 g_assert (ret == TRUE);
469 g_hash_table_unref (attributes);
473 test_remove_async (Test *test,
476 GError *error = NULL;
477 GAsyncResult *result = NULL;
478 GHashTable *attributes;
481 attributes = secret_attributes_build (&MOCK_SCHEMA,
487 secret_service_remove (test->service, &MOCK_SCHEMA, attributes, NULL,
488 on_complete_get_result, &result);
490 g_hash_table_unref (attributes);
491 g_assert (result == NULL);
495 ret = secret_service_remove_finish (test->service, result, &error);
496 g_assert_no_error (error);
497 g_assert (ret == TRUE);
499 g_object_unref (result);
503 test_remove_locked (Test *test,
506 GError *error = NULL;
507 GHashTable *attributes;
510 attributes = secret_attributes_build (&MOCK_SCHEMA,
516 /* Locked items can't be removed via this API */
517 ret = secret_service_remove_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
519 g_hash_table_unref (attributes);
520 g_assert_no_error (error);
521 g_assert (ret == FALSE);
525 test_remove_no_match (Test *test,
528 GError *error = NULL;
529 GHashTable *attributes;
532 attributes = secret_attributes_build (&MOCK_SCHEMA,
537 /* Won't match anything */
538 ret = secret_service_remove_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
540 g_hash_table_unref (attributes);
541 g_assert_no_error (error);
542 g_assert (ret == FALSE);
546 test_remove_no_name (Test *test,
549 const gchar *paths[] = { "/org/freedesktop/secrets/collection/german", NULL };
550 GError *error = NULL;
551 GHashTable *attributes;
554 attributes = secret_attributes_build (&MOCK_SCHEMA,
558 /* Shouldn't match anything, because no item with 5 in mock schema */
559 ret = secret_service_remove_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
560 g_assert_no_error (error);
561 g_assert (ret == FALSE);
563 /* We need this collection unlocked for the next test */
564 secret_service_unlock_dbus_paths_sync (test->service, paths, NULL, NULL, &error);
565 g_assert_no_error (error);
567 /* We have an item with 5 in prime schema, but should match anyway becase of flags */
568 ret = secret_service_remove_sync (test->service, &NO_NAME_SCHEMA, attributes, NULL, &error);
569 g_assert_no_error (error);
570 g_assert (ret == TRUE);
572 g_hash_table_unref (attributes);
576 test_lookup_sync (Test *test,
579 GError *error = NULL;
580 GHashTable *attributes;
584 attributes = secret_attributes_build (&MOCK_SCHEMA,
590 value = secret_service_lookup_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
592 g_assert_no_error (error);
593 g_hash_table_unref (attributes);
595 g_assert (value != NULL);
596 g_assert_cmpstr (secret_value_get (value, &length), ==, "111");
597 g_assert_cmpuint (length, ==, 3);
599 secret_value_unref (value);
603 test_lookup_async (Test *test,
606 GError *error = NULL;
607 GHashTable *attributes;
608 GAsyncResult *result = NULL;
612 attributes = secret_attributes_build (&MOCK_SCHEMA,
618 secret_service_lookup (test->service, &MOCK_SCHEMA, attributes, NULL,
619 on_complete_get_result, &result);
621 g_assert (result == NULL);
622 g_hash_table_unref (attributes);
626 value = secret_service_lookup_finish (test->service, result, &error);
627 g_assert_no_error (error);
629 g_assert (value != NULL);
630 g_assert_cmpstr (secret_value_get (value, &length), ==, "111");
631 g_assert_cmpuint (length, ==, 3);
633 secret_value_unref (value);
634 g_object_unref (result);
638 test_lookup_locked (Test *test,
641 GError *error = NULL;
642 GHashTable *attributes;
646 attributes = secret_attributes_build (&MOCK_SCHEMA,
652 value = secret_service_lookup_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
654 g_assert_no_error (error);
655 g_hash_table_unref (attributes);
657 g_assert (value != NULL);
658 g_assert_cmpstr (secret_value_get (value, &length), ==, "3333");
659 g_assert_cmpuint (length, ==, 4);
661 secret_value_unref (value);
665 test_lookup_no_match (Test *test,
668 GError *error = NULL;
669 GHashTable *attributes;
672 attributes = secret_attributes_build (&MOCK_SCHEMA,
677 /* Won't match anything */
678 value = secret_service_lookup_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
680 g_assert_no_error (error);
681 g_assert (value == NULL);
682 g_hash_table_unref (attributes);
686 test_lookup_no_name (Test *test,
689 GError *error = NULL;
690 GHashTable *attributes;
694 attributes = secret_attributes_build (&MOCK_SCHEMA,
698 /* should return null, because nothing with mock schema and 5 */
699 value = secret_service_lookup_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
700 g_assert_no_error (error);
701 g_assert (value == NULL);
703 /* should return an item, because we have a prime schema with 5, and flags not to match name */
704 value = secret_service_lookup_sync (test->service, &NO_NAME_SCHEMA, attributes, NULL, &error);
706 g_assert_no_error (error);
708 g_assert (value != NULL);
709 g_assert_cmpstr (secret_value_get (value, &length), ==, "555");
710 g_assert_cmpuint (length, ==, 3);
712 secret_value_unref (value);
713 g_hash_table_unref (attributes);
717 test_store_sync (Test *test,
720 const gchar *collection_path = "/org/freedesktop/secrets/collection/english";
721 SecretValue *value = secret_value_new ("apassword", -1, "text/plain");
722 GHashTable *attributes;
723 GError *error = NULL;
728 attributes = secret_attributes_build (&MOCK_SCHEMA,
730 "string", "seventeen",
734 ret = secret_service_store_sync (test->service, &MOCK_SCHEMA, attributes, collection_path,
735 "New Item Label", value, NULL, &error);
736 g_assert_no_error (error);
737 secret_value_unref (value);
738 g_hash_table_unref (attributes);
740 attributes = g_hash_table_new (g_str_hash, g_str_equal);
741 g_hash_table_insert (attributes, "even", "false");
742 g_hash_table_insert (attributes, "string", "seventeen");
743 g_hash_table_insert (attributes, "number", "17");
745 ret = secret_service_search_for_dbus_paths_sync (test->service, &MOCK_SCHEMA, attributes,
746 NULL, &paths, NULL, &error);
747 g_hash_table_unref (attributes);
748 g_assert (ret == TRUE);
750 g_assert (paths != NULL);
751 g_assert (paths[0] != NULL);
752 g_assert (paths[1] == NULL);
754 value = secret_service_get_secret_for_dbus_path_sync (test->service, paths[0],
756 g_assert_no_error (error);
758 g_assert (value != NULL);
759 g_assert_cmpstr (secret_value_get (value, &length), ==, "apassword");
760 g_assert_cmpuint (length, ==, 9);
762 secret_value_unref (value);
767 test_store_replace (Test *test,
770 const gchar *collection_path = "/org/freedesktop/secrets/collection/english";
771 SecretValue *value = secret_value_new ("apassword", -1, "text/plain");
772 GHashTable *attributes;
773 GError *error = NULL;
777 attributes = secret_attributes_build (&MOCK_SCHEMA,
779 "string", "seventeen",
783 ret = secret_service_store_sync (test->service, &MOCK_SCHEMA, attributes, collection_path,
784 "New Item Label", value, NULL, &error);
785 g_assert_no_error (error);
787 ret = secret_service_store_sync (test->service, &MOCK_SCHEMA, attributes, collection_path,
788 "Another Label", value, NULL, &error);
789 g_assert_no_error (error);
790 secret_value_unref (value);
791 g_hash_table_unref (attributes);
793 attributes = g_hash_table_new (g_str_hash, g_str_equal);
794 g_hash_table_insert (attributes, "even", "false");
795 g_hash_table_insert (attributes, "string", "seventeen");
796 g_hash_table_insert (attributes, "number", "17");
798 ret = secret_service_search_for_dbus_paths_sync (test->service, &MOCK_SCHEMA, attributes,
799 NULL, &paths, NULL, &error);
800 g_hash_table_unref (attributes);
801 g_assert (ret == TRUE);
803 g_assert (paths != NULL);
804 g_assert (paths[0] != NULL);
805 g_assert (paths[1] == NULL);
811 test_store_async (Test *test,
814 const gchar *collection_path = "/org/freedesktop/secrets/collection/english";
815 SecretValue *value = secret_value_new ("apassword", -1, "text/plain");
816 GAsyncResult *result = NULL;
817 GHashTable *attributes;
818 GError *error = NULL;
823 attributes = secret_attributes_build (&MOCK_SCHEMA,
825 "string", "seventeen",
829 secret_service_store (test->service, &MOCK_SCHEMA, attributes, collection_path,
830 "New Item Label", value, NULL, on_complete_get_result, &result);
831 g_assert (result == NULL);
832 secret_value_unref (value);
833 g_hash_table_unref (attributes);
837 ret = secret_service_store_finish (test->service, result, &error);
838 g_assert_no_error (error);
839 g_object_unref (result);
841 attributes = g_hash_table_new (g_str_hash, g_str_equal);
842 g_hash_table_insert (attributes, "even", "false");
843 g_hash_table_insert (attributes, "string", "seventeen");
844 g_hash_table_insert (attributes, "number", "17");
846 ret = secret_service_search_for_dbus_paths_sync (test->service, &MOCK_SCHEMA, attributes,
847 NULL, &paths, NULL, &error);
848 g_hash_table_unref (attributes);
849 g_assert (ret == TRUE);
851 g_assert (paths != NULL);
852 g_assert (paths[0] != NULL);
853 g_assert (paths[1] == NULL);
855 value = secret_service_get_secret_for_dbus_path_sync (test->service, paths[0],
857 g_assert_no_error (error);
859 g_assert (value != NULL);
860 g_assert_cmpstr (secret_value_get (value, &length), ==, "apassword");
861 g_assert_cmpuint (length, ==, 9);
863 secret_value_unref (value);
868 test_set_alias_sync (Test *test,
871 SecretCollection *collection;
873 GError *error = NULL;
876 blah = secret_service_read_alias_dbus_path_sync (test->service, "blah", NULL, &error);
877 g_assert_no_error (error);
878 g_assert (blah == NULL);
880 collection = secret_collection_new_for_dbus_path_sync (test->service,
881 "/org/freedesktop/secrets/collection/english",
882 SECRET_COLLECTION_NONE, NULL, &error);
883 g_assert_no_error (error);
884 g_assert (SECRET_IS_COLLECTION (collection));
886 ret = secret_service_set_alias_sync (test->service, "blah", collection, NULL, &error);
887 g_assert_no_error (error);
888 g_assert (ret == TRUE);
890 blah = secret_service_read_alias_dbus_path_sync (test->service, "blah", NULL, &error);
891 g_assert_no_error (error);
892 g_assert_cmpstr (blah, ==, g_dbus_proxy_get_object_path (G_DBUS_PROXY (collection)));
895 ret = secret_service_set_alias_sync (test->service, "blah", NULL, NULL, &error);
896 g_assert_no_error (error);
897 g_assert (ret == TRUE);
899 blah = secret_service_read_alias_dbus_path_sync (test->service, "blah", NULL, &error);
900 g_assert_no_error (error);
901 g_assert (blah == NULL);
903 g_object_unref (collection);
907 main (int argc, char **argv)
909 g_test_init (&argc, &argv, NULL);
910 g_set_prgname ("test-service");
913 g_test_add ("/service/search-sync", Test, "mock-service-normal.py", setup, test_search_sync, teardown);
914 g_test_add ("/service/search-async", Test, "mock-service-normal.py", setup, test_search_async, teardown);
915 g_test_add ("/service/search-all-sync", Test, "mock-service-normal.py", setup, test_search_all_sync, teardown);
916 g_test_add ("/service/search-all-async", Test, "mock-service-normal.py", setup, test_search_all_async, teardown);
917 g_test_add ("/service/search-unlock-sync", Test, "mock-service-normal.py", setup, test_search_unlock_sync, teardown);
918 g_test_add ("/service/search-unlock-async", Test, "mock-service-normal.py", setup, test_search_unlock_async, teardown);
919 g_test_add ("/service/search-secrets-sync", Test, "mock-service-normal.py", setup, test_search_secrets_sync, teardown);
920 g_test_add ("/service/search-secrets-async", Test, "mock-service-normal.py", setup, test_search_secrets_async, teardown);
922 g_test_add ("/service/lock-sync", Test, "mock-service-lock.py", setup, test_lock_sync, teardown);
924 g_test_add ("/service/unlock-sync", Test, "mock-service-lock.py", setup, test_unlock_sync, teardown);
926 g_test_add ("/service/lookup-sync", Test, "mock-service-normal.py", setup, test_lookup_sync, teardown);
927 g_test_add ("/service/lookup-async", Test, "mock-service-normal.py", setup, test_lookup_async, teardown);
928 g_test_add ("/service/lookup-locked", Test, "mock-service-normal.py", setup, test_lookup_locked, teardown);
929 g_test_add ("/service/lookup-no-match", Test, "mock-service-normal.py", setup, test_lookup_no_match, teardown);
930 g_test_add ("/service/lookup-no-name", Test, "mock-service-normal.py", setup, test_lookup_no_name, teardown);
932 g_test_add ("/service/remove-sync", Test, "mock-service-delete.py", setup, test_remove_sync, teardown);
933 g_test_add ("/service/remove-async", Test, "mock-service-delete.py", setup, test_remove_async, teardown);
934 g_test_add ("/service/remove-locked", Test, "mock-service-delete.py", setup, test_remove_locked, teardown);
935 g_test_add ("/service/remove-no-match", Test, "mock-service-delete.py", setup, test_remove_no_match, teardown);
936 g_test_add ("/service/remove-no-name", Test, "mock-service-delete.py", setup, test_remove_no_name, teardown);
938 g_test_add ("/service/store-sync", Test, "mock-service-normal.py", setup, test_store_sync, teardown);
939 g_test_add ("/service/store-async", Test, "mock-service-normal.py", setup, test_store_async, teardown);
940 g_test_add ("/service/store-replace", Test, "mock-service-normal.py", setup, test_store_replace, teardown);
942 g_test_add ("/service/set-alias-sync", Test, "mock-service-normal.py", setup, test_set_alias_sync, teardown);
944 return egg_tests_run_with_loop ();