LCOV - code coverage report
Current view: top level - libsecret - test-methods.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 499 499 100.0 %
Date: 2024-02-08 14:44:34 Functions: 31 31 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 201 402 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* libsecret - GLib wrapper for Secret Service
       2                 :            :  *
       3                 :            :  * Copyright 2011 Collabora Ltd.
       4                 :            :  *
       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.
       9                 :            :  *
      10                 :            :  * See the included COPYING file for more information.
      11                 :            :  */
      12                 :            : 
      13                 :            : 
      14                 :            : #include "config.h"
      15                 :            : 
      16                 :            : #undef G_DISABLE_ASSERT
      17                 :            : 
      18                 :            : #include "secret-attributes.h"
      19                 :            : #include "secret-collection.h"
      20                 :            : #include "secret-item.h"
      21                 :            : #include "secret-paths.h"
      22                 :            : #include "secret-private.h"
      23                 :            : #include "secret-service.h"
      24                 :            : 
      25                 :            : #include "mock-service.h"
      26                 :            : 
      27                 :            : #include "egg/egg-testing.h"
      28                 :            : 
      29                 :            : #include <glib.h>
      30                 :            : 
      31                 :            : #include <errno.h>
      32                 :            : #include <stdlib.h>
      33                 :            : 
      34                 :            : static const SecretSchema MOCK_SCHEMA = {
      35                 :            :         "org.mock.Schema",
      36                 :            :         SECRET_SCHEMA_NONE,
      37                 :            :         {
      38                 :            :                 { "number", SECRET_SCHEMA_ATTRIBUTE_INTEGER },
      39                 :            :                 { "string", SECRET_SCHEMA_ATTRIBUTE_STRING },
      40                 :            :                 { "even", SECRET_SCHEMA_ATTRIBUTE_BOOLEAN },
      41                 :            :         }
      42                 :            : };
      43                 :            : 
      44                 :            : static const SecretSchema NO_NAME_SCHEMA = {
      45                 :            :         "unused.Schema.Name",
      46                 :            :         SECRET_SCHEMA_DONT_MATCH_NAME,
      47                 :            :         {
      48                 :            :                 { "number", SECRET_SCHEMA_ATTRIBUTE_INTEGER },
      49                 :            :                 { "string", SECRET_SCHEMA_ATTRIBUTE_STRING },
      50                 :            :         }
      51                 :            : };
      52                 :            : 
      53                 :            : typedef struct {
      54                 :            :         SecretService *service;
      55                 :            : } Test;
      56                 :            : 
      57                 :            : static void
      58                 :         25 : setup_mock (Test *test,
      59                 :            :             gconstpointer data)
      60                 :            : {
      61                 :         25 :         GError *error = NULL;
      62                 :         25 :         const gchar *mock_script = data;
      63                 :            : 
      64                 :         25 :         mock_service_start (mock_script, &error);
      65         [ -  + ]:         25 :         g_assert_no_error (error);
      66                 :         25 : }
      67                 :            : 
      68                 :            : static void
      69                 :         25 : setup (Test *test,
      70                 :            :        gconstpointer data)
      71                 :            : {
      72                 :         25 :         GError *error = NULL;
      73                 :            : 
      74                 :         25 :         setup_mock (test, data);
      75                 :            : 
      76                 :         25 :         test->service = secret_service_get_sync (SECRET_SERVICE_NONE, NULL, &error);
      77         [ -  + ]:         25 :         g_assert_no_error (error);
      78                 :         25 :         g_object_add_weak_pointer (G_OBJECT (test->service), (gpointer *)&test->service);
      79                 :         25 : }
      80                 :            : 
      81                 :            : static void
      82                 :         25 : teardown_mock (Test *test,
      83                 :            :                gconstpointer unused)
      84                 :            : {
      85                 :         25 :         secret_service_disconnect ();
      86                 :         25 :         mock_service_stop ();
      87                 :         25 : }
      88                 :            : 
      89                 :            : static void
      90                 :         25 : teardown (Test *test,
      91                 :            :           gconstpointer unused)
      92                 :            : {
      93                 :         25 :         egg_test_wait_idle ();
      94                 :            : 
      95                 :         25 :         g_object_unref (test->service);
      96                 :         25 :         secret_service_disconnect ();
      97         [ -  + ]:         25 :         g_assert_null (test->service);
      98                 :            : 
      99                 :         25 :         teardown_mock (test, unused);
     100                 :         25 : }
     101                 :            : 
     102                 :            : static void
     103                 :          7 : on_complete_get_result (GObject *source,
     104                 :            :                         GAsyncResult *result,
     105                 :            :                         gpointer user_data)
     106                 :            : {
     107                 :          7 :         GAsyncResult **ret = user_data;
     108         [ -  + ]:          7 :         g_assert_nonnull (ret);
     109         [ -  + ]:          7 :         g_assert_null (*ret);
     110                 :          7 :         *ret = g_object_ref (result);
     111                 :          7 :         egg_test_wait_stop ();
     112                 :          7 : }
     113                 :            : 
     114                 :            : static void
     115                 :          1 : test_search_sync (Test *test,
     116                 :            :                   gconstpointer used)
     117                 :            : {
     118                 :            :         GHashTable *attributes;
     119                 :          1 :         GError *error = NULL;
     120                 :            :         GList *items;
     121                 :            : 
     122                 :          1 :         attributes = g_hash_table_new (g_str_hash, g_str_equal);
     123                 :          1 :         g_hash_table_insert (attributes, "number", "1");
     124                 :            : 
     125                 :          1 :         items = secret_service_search_sync (test->service, &MOCK_SCHEMA, attributes,
     126                 :            :                                             SECRET_SEARCH_NONE, NULL, &error);
     127         [ -  + ]:          1 :         g_assert_no_error (error);
     128                 :          1 :         g_hash_table_unref (attributes);
     129                 :            : 
     130         [ -  + ]:          1 :         g_assert_nonnull (items);
     131         [ -  + ]:          1 :         g_assert_cmpstr (g_dbus_proxy_get_object_path (items->data), ==, "/org/freedesktop/secrets/collection/english/1");
     132                 :            : 
     133         [ -  + ]:          1 :         g_assert_null (items->next);
     134                 :          1 :         g_list_free_full (items, g_object_unref);
     135                 :          1 : }
     136                 :            : 
     137                 :            : static void
     138                 :          1 : test_search_async (Test *test,
     139                 :            :                    gconstpointer used)
     140                 :            : {
     141                 :          1 :         GAsyncResult *result = NULL;
     142                 :            :         GHashTable *attributes;
     143                 :          1 :         GError *error = NULL;
     144                 :            :         GList *items;
     145                 :            : 
     146                 :          1 :         attributes = g_hash_table_new (g_str_hash, g_str_equal);
     147                 :          1 :         g_hash_table_insert (attributes, "number", "1");
     148                 :            : 
     149                 :          1 :         secret_service_search (test->service, &MOCK_SCHEMA, attributes,
     150                 :            :                                SECRET_SEARCH_NONE, NULL,
     151                 :            :                                on_complete_get_result, &result);
     152                 :          1 :         g_hash_table_unref (attributes);
     153         [ -  + ]:          1 :         g_assert_null (result);
     154                 :            : 
     155         [ -  + ]:          1 :         egg_test_wait ();
     156                 :            : 
     157   [ -  +  +  -  :          1 :         g_assert_true (G_IS_ASYNC_RESULT (result));
             -  +  -  + ]
     158                 :          1 :         items = secret_service_search_finish (test->service, result, &error);
     159         [ -  + ]:          1 :         g_assert_no_error (error);
     160                 :          1 :         g_object_unref (result);
     161                 :            : 
     162         [ -  + ]:          1 :         g_assert_nonnull (items);
     163         [ -  + ]:          1 :         g_assert_cmpstr (g_dbus_proxy_get_object_path (items->data), ==, "/org/freedesktop/secrets/collection/english/1");
     164                 :            : 
     165         [ -  + ]:          1 :         g_assert_null (items->next);
     166                 :          1 :         g_list_free_full (items, g_object_unref);
     167                 :          1 : }
     168                 :            : 
     169                 :            : static void
     170                 :          1 : test_search_all_sync (Test *test,
     171                 :            :                   gconstpointer used)
     172                 :            : {
     173                 :            :         GHashTable *attributes;
     174                 :          1 :         GError *error = NULL;
     175                 :            :         GList *items;
     176                 :            : 
     177                 :          1 :         attributes = g_hash_table_new (g_str_hash, g_str_equal);
     178                 :          1 :         g_hash_table_insert (attributes, "number", "1");
     179                 :            : 
     180                 :          1 :         items = secret_service_search_sync (test->service, &MOCK_SCHEMA, attributes,
     181                 :            :                                             SECRET_SEARCH_ALL, NULL, &error);
     182         [ -  + ]:          1 :         g_assert_no_error (error);
     183                 :          1 :         g_hash_table_unref (attributes);
     184                 :            : 
     185         [ -  + ]:          1 :         g_assert_nonnull (items);
     186         [ -  + ]:          1 :         g_assert_cmpstr (g_dbus_proxy_get_object_path (items->data), ==, "/org/freedesktop/secrets/collection/english/1");
     187         [ -  + ]:          1 :         g_assert_false (secret_item_get_locked (items->data));
     188         [ -  + ]:          1 :         g_assert_null (secret_item_get_secret (items->data));
     189                 :            : 
     190         [ -  + ]:          1 :         g_assert_nonnull (items->next);
     191         [ -  + ]:          1 :         g_assert_cmpstr (g_dbus_proxy_get_object_path (items->next->data), ==, "/org/freedesktop/secrets/collection/spanish/10");
     192         [ -  + ]:          1 :         g_assert_true (secret_item_get_locked (items->next->data));
     193         [ -  + ]:          1 :         g_assert_null (secret_item_get_secret (items->next->data));
     194                 :            : 
     195         [ -  + ]:          1 :         g_assert_null (items->next->next);
     196                 :          1 :         g_list_free_full (items, g_object_unref);
     197                 :          1 : }
     198                 :            : 
     199                 :            : static void
     200                 :          1 : test_search_all_async (Test *test,
     201                 :            :                    gconstpointer used)
     202                 :            : {
     203                 :          1 :         GAsyncResult *result = NULL;
     204                 :            :         GHashTable *attributes;
     205                 :          1 :         GError *error = NULL;
     206                 :            :         GList *items;
     207                 :            : 
     208                 :          1 :         attributes = g_hash_table_new (g_str_hash, g_str_equal);
     209                 :          1 :         g_hash_table_insert (attributes, "number", "1");
     210                 :            : 
     211                 :          1 :         secret_service_search (test->service, &MOCK_SCHEMA, attributes,
     212                 :            :                                SECRET_SEARCH_ALL, NULL,
     213                 :            :                                on_complete_get_result, &result);
     214                 :          1 :         g_hash_table_unref (attributes);
     215         [ -  + ]:          1 :         g_assert_null (result);
     216                 :            : 
     217         [ -  + ]:          1 :         egg_test_wait ();
     218                 :            : 
     219   [ -  +  +  -  :          1 :         g_assert_true (G_IS_ASYNC_RESULT (result));
             -  +  -  + ]
     220                 :          1 :         items = secret_service_search_finish (test->service, result, &error);
     221         [ -  + ]:          1 :         g_assert_no_error (error);
     222                 :          1 :         g_object_unref (result);
     223                 :            : 
     224         [ -  + ]:          1 :         g_assert_nonnull (items);
     225         [ -  + ]:          1 :         g_assert_cmpstr (g_dbus_proxy_get_object_path (items->data), ==, "/org/freedesktop/secrets/collection/english/1");
     226         [ -  + ]:          1 :         g_assert_false (secret_item_get_locked (items->data));
     227         [ -  + ]:          1 :         g_assert_null (secret_item_get_secret (items->data));
     228                 :            : 
     229         [ -  + ]:          1 :         g_assert_nonnull (items->next);
     230         [ -  + ]:          1 :         g_assert_cmpstr (g_dbus_proxy_get_object_path (items->next->data), ==, "/org/freedesktop/secrets/collection/spanish/10");
     231         [ -  + ]:          1 :         g_assert_true (secret_item_get_locked (items->next->data));
     232         [ -  + ]:          1 :         g_assert_null (secret_item_get_secret (items->next->data));
     233                 :            : 
     234         [ -  + ]:          1 :         g_assert_null (items->next->next);
     235                 :          1 :         g_list_free_full (items, g_object_unref);
     236                 :          1 : }
     237                 :            : 
     238                 :            : static void
     239                 :          1 : test_search_unlock_sync (Test *test,
     240                 :            :                          gconstpointer used)
     241                 :            : {
     242                 :            :         GHashTable *attributes;
     243                 :          1 :         GError *error = NULL;
     244                 :            :         GList *items;
     245                 :            : 
     246                 :          1 :         attributes = g_hash_table_new (g_str_hash, g_str_equal);
     247                 :          1 :         g_hash_table_insert (attributes, "number", "1");
     248                 :            : 
     249                 :          1 :         items = secret_service_search_sync (test->service, &MOCK_SCHEMA, attributes,
     250                 :            :                                             SECRET_SEARCH_ALL | SECRET_SEARCH_UNLOCK,
     251                 :            :                                             NULL, &error);
     252         [ -  + ]:          1 :         g_assert_no_error (error);
     253                 :          1 :         g_hash_table_unref (attributes);
     254                 :            : 
     255         [ -  + ]:          1 :         g_assert_nonnull (items);
     256         [ -  + ]:          1 :         g_assert_cmpstr (g_dbus_proxy_get_object_path (items->data), ==, "/org/freedesktop/secrets/collection/english/1");
     257         [ -  + ]:          1 :         g_assert_false (secret_item_get_locked (items->data));
     258         [ -  + ]:          1 :         g_assert_null (secret_item_get_secret (items->data));
     259                 :            : 
     260         [ -  + ]:          1 :         g_assert_nonnull (items->next);
     261         [ -  + ]:          1 :         g_assert_cmpstr (g_dbus_proxy_get_object_path (items->next->data), ==, "/org/freedesktop/secrets/collection/spanish/10");
     262         [ -  + ]:          1 :         g_assert_false (secret_item_get_locked (items->next->data));
     263         [ -  + ]:          1 :         g_assert_null (secret_item_get_secret (items->next->data));
     264                 :            : 
     265         [ -  + ]:          1 :         g_assert_null (items->next->next);
     266                 :          1 :         g_list_free_full (items, g_object_unref);
     267                 :          1 : }
     268                 :            : 
     269                 :            : static void
     270                 :          1 : test_search_unlock_async (Test *test,
     271                 :            :                           gconstpointer used)
     272                 :            : {
     273                 :          1 :         GAsyncResult *result = NULL;
     274                 :            :         GHashTable *attributes;
     275                 :          1 :         GError *error = NULL;
     276                 :            :         GList *items;
     277                 :            : 
     278                 :          1 :         attributes = g_hash_table_new (g_str_hash, g_str_equal);
     279                 :          1 :         g_hash_table_insert (attributes, "number", "1");
     280                 :            : 
     281                 :          1 :         secret_service_search (test->service, &MOCK_SCHEMA, attributes,
     282                 :            :                                SECRET_SEARCH_ALL | SECRET_SEARCH_UNLOCK, NULL,
     283                 :            :                                on_complete_get_result, &result);
     284                 :          1 :         g_hash_table_unref (attributes);
     285         [ -  + ]:          1 :         g_assert_null (result);
     286                 :            : 
     287         [ -  + ]:          1 :         egg_test_wait ();
     288                 :            : 
     289   [ -  +  +  -  :          1 :         g_assert_true (G_IS_ASYNC_RESULT (result));
             -  +  -  + ]
     290                 :          1 :         items = secret_service_search_finish (test->service, result, &error);
     291         [ -  + ]:          1 :         g_assert_no_error (error);
     292                 :          1 :         g_object_unref (result);
     293                 :            : 
     294         [ -  + ]:          1 :         g_assert_nonnull (items);
     295         [ -  + ]:          1 :         g_assert_cmpstr (g_dbus_proxy_get_object_path (items->data), ==, "/org/freedesktop/secrets/collection/english/1");
     296         [ -  + ]:          1 :         g_assert_false (secret_item_get_locked (items->data));
     297         [ -  + ]:          1 :         g_assert_null (secret_item_get_secret (items->data));
     298                 :            : 
     299         [ -  + ]:          1 :         g_assert_nonnull (items->next);
     300         [ -  + ]:          1 :         g_assert_cmpstr (g_dbus_proxy_get_object_path (items->next->data), ==, "/org/freedesktop/secrets/collection/spanish/10");
     301         [ -  + ]:          1 :         g_assert_false (secret_item_get_locked (items->next->data));
     302         [ -  + ]:          1 :         g_assert_null (secret_item_get_secret (items->next->data));
     303                 :            : 
     304         [ -  + ]:          1 :         g_assert_null (items->next->next);
     305                 :          1 :         g_list_free_full (items, g_object_unref);
     306                 :          1 : }
     307                 :            : 
     308                 :            : static void
     309                 :          1 : test_search_secrets_sync (Test *test,
     310                 :            :                           gconstpointer used)
     311                 :            : {
     312                 :            :         GHashTable *attributes;
     313                 :          1 :         GError *error = NULL;
     314                 :            :         SecretValue *value;
     315                 :            :         GList *items;
     316                 :            : 
     317                 :          1 :         attributes = g_hash_table_new (g_str_hash, g_str_equal);
     318                 :          1 :         g_hash_table_insert (attributes, "number", "1");
     319                 :            : 
     320                 :          1 :         items = secret_service_search_sync (test->service, &MOCK_SCHEMA, attributes,
     321                 :            :                                             SECRET_SEARCH_ALL | SECRET_SEARCH_LOAD_SECRETS,
     322                 :            :                                             NULL, &error);
     323         [ -  + ]:          1 :         g_assert_no_error (error);
     324                 :          1 :         g_hash_table_unref (attributes);
     325                 :            : 
     326         [ -  + ]:          1 :         g_assert_nonnull (items);
     327         [ -  + ]:          1 :         g_assert_cmpstr (g_dbus_proxy_get_object_path (items->data), ==, "/org/freedesktop/secrets/collection/english/1");
     328         [ -  + ]:          1 :         g_assert_false (secret_item_get_locked (items->data));
     329                 :          1 :         value = secret_item_get_secret (items->data);
     330         [ -  + ]:          1 :         g_assert_nonnull (value);
     331                 :          1 :         secret_value_unref (value);
     332                 :            : 
     333         [ -  + ]:          1 :         g_assert_nonnull (items->next);
     334         [ -  + ]:          1 :         g_assert_cmpstr (g_dbus_proxy_get_object_path (items->next->data), ==, "/org/freedesktop/secrets/collection/spanish/10");
     335         [ -  + ]:          1 :         g_assert_true (secret_item_get_locked (items->next->data));
     336         [ -  + ]:          1 :         g_assert_null (secret_item_get_secret (items->next->data));
     337                 :            : 
     338         [ -  + ]:          1 :         g_assert_null (items->next->next);
     339                 :          1 :         g_list_free_full (items, g_object_unref);
     340                 :          1 : }
     341                 :            : 
     342                 :            : static void
     343                 :          1 : test_search_secrets_async (Test *test,
     344                 :            :                            gconstpointer used)
     345                 :            : {
     346                 :          1 :         GAsyncResult *result = NULL;
     347                 :            :         GHashTable *attributes;
     348                 :          1 :         GError *error = NULL;
     349                 :            :         SecretValue *value;
     350                 :            :         GList *items;
     351                 :            : 
     352                 :          1 :         attributes = g_hash_table_new (g_str_hash, g_str_equal);
     353                 :          1 :         g_hash_table_insert (attributes, "number", "1");
     354                 :            : 
     355                 :          1 :         secret_service_search (test->service, &MOCK_SCHEMA, attributes,
     356                 :            :                                SECRET_SEARCH_ALL | SECRET_SEARCH_LOAD_SECRETS, NULL,
     357                 :            :                                on_complete_get_result, &result);
     358                 :          1 :         g_hash_table_unref (attributes);
     359         [ -  + ]:          1 :         g_assert_null (result);
     360                 :            : 
     361         [ -  + ]:          1 :         egg_test_wait ();
     362                 :            : 
     363   [ -  +  +  -  :          1 :         g_assert_true (G_IS_ASYNC_RESULT (result));
             -  +  -  + ]
     364                 :          1 :         items = secret_service_search_finish (test->service, result, &error);
     365         [ -  + ]:          1 :         g_assert_no_error (error);
     366                 :          1 :         g_object_unref (result);
     367                 :            : 
     368         [ -  + ]:          1 :         g_assert_nonnull (items);
     369         [ -  + ]:          1 :         g_assert_cmpstr (g_dbus_proxy_get_object_path (items->data), ==, "/org/freedesktop/secrets/collection/english/1");
     370         [ -  + ]:          1 :         g_assert_false (secret_item_get_locked (items->data));
     371                 :          1 :         value = secret_item_get_secret (items->data);
     372         [ -  + ]:          1 :         g_assert_nonnull (value);
     373                 :          1 :         secret_value_unref (value);
     374                 :            : 
     375         [ -  + ]:          1 :         g_assert_nonnull (items->next);
     376         [ -  + ]:          1 :         g_assert_cmpstr (g_dbus_proxy_get_object_path (items->next->data), ==, "/org/freedesktop/secrets/collection/spanish/10");
     377         [ -  + ]:          1 :         g_assert_true (secret_item_get_locked (items->next->data));
     378         [ -  + ]:          1 :         g_assert_null (secret_item_get_secret (items->next->data));
     379                 :            : 
     380         [ -  + ]:          1 :         g_assert_null (items->next->next);
     381                 :          1 :         g_list_free_full (items, g_object_unref);
     382                 :          1 : }
     383                 :            : 
     384                 :            : static void
     385                 :          1 : test_lock_sync (Test *test,
     386                 :            :                 gconstpointer used)
     387                 :            : {
     388                 :          1 :         const gchar *collection_path = "/org/freedesktop/secrets/collection/lockone";
     389                 :            :         SecretCollection *collection;
     390                 :          1 :         GError *error = NULL;
     391                 :            :         GList *locked;
     392                 :            :         GList *objects;
     393                 :            :         gboolean ret;
     394                 :            : 
     395                 :          1 :         collection = secret_collection_new_for_dbus_path_sync (test->service, collection_path,
     396                 :            :                                                                SECRET_COLLECTION_NONE, NULL, &error);
     397         [ -  + ]:          1 :         g_assert_no_error (error);
     398                 :            : 
     399                 :          1 :         objects = g_list_append (NULL, collection);
     400                 :            : 
     401                 :          1 :         ret = secret_service_lock_sync (test->service, objects, NULL, &locked, &error);
     402         [ -  + ]:          1 :         g_assert_no_error (error);
     403         [ -  + ]:          1 :         g_assert_true (ret);
     404                 :            : 
     405         [ -  + ]:          1 :         g_assert_nonnull (locked);
     406         [ -  + ]:          1 :         g_assert_true (locked->data == collection);
     407         [ -  + ]:          1 :         g_assert_null (locked->next);
     408                 :          1 :         g_list_free_full (locked, g_object_unref);
     409                 :            : 
     410                 :          1 :         g_list_free (objects);
     411                 :          1 :         g_object_unref (collection);
     412                 :          1 : }
     413                 :            : 
     414                 :            : static void
     415                 :          1 : test_unlock_sync (Test *test,
     416                 :            :                   gconstpointer used)
     417                 :            : {
     418                 :          1 :         const gchar *collection_path = "/org/freedesktop/secrets/collection/lockone";
     419                 :            :         SecretCollection *collection;
     420                 :          1 :         GError *error = NULL;
     421                 :            :         GList *unlocked;
     422                 :            :         GList *objects;
     423                 :            :         gboolean ret;
     424                 :            : 
     425                 :          1 :         collection = secret_collection_new_for_dbus_path_sync (test->service, collection_path,
     426                 :            :                                                                SECRET_COLLECTION_NONE, NULL, &error);
     427         [ -  + ]:          1 :         g_assert_no_error (error);
     428                 :            : 
     429                 :          1 :         objects = g_list_append (NULL, collection);
     430                 :            : 
     431                 :          1 :         ret = secret_service_unlock_sync (test->service, objects, NULL, &unlocked, &error);
     432         [ -  + ]:          1 :         g_assert_no_error (error);
     433         [ -  + ]:          1 :         g_assert_true (ret);
     434                 :            : 
     435         [ -  + ]:          1 :         g_assert_nonnull (unlocked);
     436         [ -  + ]:          1 :         g_assert_true (unlocked->data == collection);
     437         [ -  + ]:          1 :         g_assert_null (unlocked->next);
     438                 :          1 :         g_list_free_full (unlocked, g_object_unref);
     439                 :            : 
     440                 :          1 :         g_list_free (objects);
     441                 :          1 :         g_object_unref (collection);
     442                 :          1 : }
     443                 :            : 
     444                 :            : static void
     445                 :          1 : test_clear_sync (Test *test,
     446                 :            :                  gconstpointer used)
     447                 :            : {
     448                 :          1 :         GError *error = NULL;
     449                 :            :         GHashTable *attributes;
     450                 :            :         gboolean ret;
     451                 :            : 
     452                 :          1 :         attributes = secret_attributes_build (&MOCK_SCHEMA,
     453                 :            :                                               "even", FALSE,
     454                 :            :                                               "string", "one",
     455                 :            :                                               "number", 1,
     456                 :            :                                               NULL);
     457                 :            : 
     458                 :          1 :         ret = secret_service_clear_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
     459                 :            : 
     460         [ -  + ]:          1 :         g_assert_no_error (error);
     461         [ -  + ]:          1 :         g_assert_true (ret);
     462                 :            : 
     463                 :          1 :         g_hash_table_unref (attributes);
     464                 :          1 : }
     465                 :            : 
     466                 :            : static void
     467                 :          1 : test_clear_async (Test *test,
     468                 :            :                   gconstpointer used)
     469                 :            : {
     470                 :          1 :         GError *error = NULL;
     471                 :          1 :         GAsyncResult *result = NULL;
     472                 :            :         GHashTable *attributes;
     473                 :            :         gboolean ret;
     474                 :            : 
     475                 :          1 :         attributes = secret_attributes_build (&MOCK_SCHEMA,
     476                 :            :                                               "even", FALSE,
     477                 :            :                                               "string", "one",
     478                 :            :                                               "number", 1,
     479                 :            :                                               NULL);
     480                 :            : 
     481                 :          1 :         secret_service_clear (test->service, &MOCK_SCHEMA, attributes, NULL,
     482                 :            :                               on_complete_get_result, &result);
     483                 :            : 
     484                 :          1 :         g_hash_table_unref (attributes);
     485         [ -  + ]:          1 :         g_assert_null (result);
     486                 :            : 
     487         [ -  + ]:          1 :         egg_test_wait ();
     488                 :            : 
     489                 :          1 :         ret = secret_service_clear_finish (test->service, result, &error);
     490         [ -  + ]:          1 :         g_assert_no_error (error);
     491         [ -  + ]:          1 :         g_assert_true (ret);
     492                 :            : 
     493                 :          1 :         g_object_unref (result);
     494                 :          1 : }
     495                 :            : 
     496                 :            : static void
     497                 :          1 : test_clear_locked (Test *test,
     498                 :            :                    gconstpointer used)
     499                 :            : {
     500                 :          1 :         GError *error = NULL;
     501                 :            :         GHashTable *attributes;
     502                 :            :         gboolean ret;
     503                 :            : 
     504                 :          1 :         attributes = secret_attributes_build (&MOCK_SCHEMA,
     505                 :            :                                               "even", FALSE,
     506                 :            :                                               "string", "tres",
     507                 :            :                                               "number", 3,
     508                 :            :                                               NULL);
     509                 :            : 
     510                 :            :         /* Locked items can't be removed via this API */
     511                 :          1 :         ret = secret_service_clear_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
     512                 :            : 
     513                 :          1 :         g_hash_table_unref (attributes);
     514         [ -  + ]:          1 :         g_assert_no_error (error);
     515         [ -  + ]:          1 :         g_assert_false (ret);
     516                 :          1 : }
     517                 :            : 
     518                 :            : static void
     519                 :          1 : test_clear_no_match (Test *test,
     520                 :            :                      gconstpointer used)
     521                 :            : {
     522                 :          1 :         GError *error = NULL;
     523                 :            :         GHashTable *attributes;
     524                 :            :         gboolean ret;
     525                 :            : 
     526                 :          1 :         attributes = secret_attributes_build (&MOCK_SCHEMA,
     527                 :            :                                               "even", TRUE,
     528                 :            :                                               "string", "one",
     529                 :            :                                               NULL);
     530                 :            : 
     531                 :            :         /* Won't match anything */
     532                 :          1 :         ret = secret_service_clear_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
     533                 :            : 
     534                 :          1 :         g_hash_table_unref (attributes);
     535         [ -  + ]:          1 :         g_assert_no_error (error);
     536         [ -  + ]:          1 :         g_assert_false (ret);
     537                 :          1 : }
     538                 :            : 
     539                 :            : static void
     540                 :          1 : test_clear_no_name (Test *test,
     541                 :            :                     gconstpointer used)
     542                 :            : {
     543                 :          1 :         const gchar *paths[] = { "/org/freedesktop/secrets/collection/german", NULL };
     544                 :          1 :         GError *error = NULL;
     545                 :            :         GHashTable *attributes;
     546                 :            :         gboolean ret;
     547                 :            : 
     548                 :          1 :         attributes = secret_attributes_build (&MOCK_SCHEMA,
     549                 :            :                                               "number", 5,
     550                 :            :                                               NULL);
     551                 :            : 
     552                 :            :         /* Shouldn't match anything, because no item with 5 in mock schema */
     553                 :          1 :         ret = secret_service_clear_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
     554         [ -  + ]:          1 :         g_assert_no_error (error);
     555         [ -  + ]:          1 :         g_assert_false (ret);
     556                 :            : 
     557                 :            :         /* We need this collection unlocked for the next test */
     558                 :          1 :         secret_service_unlock_dbus_paths_sync (test->service, paths, NULL, NULL, &error);
     559         [ -  + ]:          1 :         g_assert_no_error (error);
     560                 :            : 
     561                 :            :         /* We have an item with 5 in prime schema, but should match anyway becase of flags */
     562                 :          1 :         ret = secret_service_clear_sync (test->service, &NO_NAME_SCHEMA, attributes, NULL, &error);
     563         [ -  + ]:          1 :         g_assert_no_error (error);
     564         [ -  + ]:          1 :         g_assert_true (ret);
     565                 :            : 
     566                 :          1 :         g_hash_table_unref (attributes);
     567                 :          1 : }
     568                 :            : 
     569                 :            : static void
     570                 :          1 : test_lookup_sync (Test *test,
     571                 :            :                   gconstpointer used)
     572                 :            : {
     573                 :          1 :         GError *error = NULL;
     574                 :            :         GHashTable *attributes;
     575                 :            :         SecretValue *value;
     576                 :            :         gsize length;
     577                 :            : 
     578                 :          1 :         attributes = secret_attributes_build (&MOCK_SCHEMA,
     579                 :            :                                               "even", FALSE,
     580                 :            :                                               "string", "one",
     581                 :            :                                               "number", 1,
     582                 :            :                                               NULL);
     583                 :            : 
     584                 :          1 :         value = secret_service_lookup_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
     585                 :            : 
     586         [ -  + ]:          1 :         g_assert_no_error (error);
     587                 :          1 :         g_hash_table_unref (attributes);
     588                 :            : 
     589         [ -  + ]:          1 :         g_assert_nonnull (value);
     590         [ -  + ]:          1 :         g_assert_cmpstr (secret_value_get (value, &length), ==, "111");
     591         [ -  + ]:          1 :         g_assert_cmpuint (length, ==, 3);
     592                 :            : 
     593                 :          1 :         secret_value_unref (value);
     594                 :          1 : }
     595                 :            : 
     596                 :            : static void
     597                 :          1 : test_lookup_async (Test *test,
     598                 :            :                    gconstpointer used)
     599                 :            : {
     600                 :          1 :         GError *error = NULL;
     601                 :            :         GHashTable *attributes;
     602                 :          1 :         GAsyncResult *result = NULL;
     603                 :            :         SecretValue *value;
     604                 :            :         gsize length;
     605                 :            : 
     606                 :          1 :         attributes = secret_attributes_build (&MOCK_SCHEMA,
     607                 :            :                                               "even", FALSE,
     608                 :            :                                               "string", "one",
     609                 :            :                                               "number", 1,
     610                 :            :                                               NULL);
     611                 :            : 
     612                 :          1 :         secret_service_lookup (test->service, &MOCK_SCHEMA, attributes, NULL,
     613                 :            :                                 on_complete_get_result, &result);
     614                 :            : 
     615         [ -  + ]:          1 :         g_assert_null (result);
     616                 :          1 :         g_hash_table_unref (attributes);
     617                 :            : 
     618         [ -  + ]:          1 :         egg_test_wait ();
     619                 :            : 
     620                 :          1 :         value = secret_service_lookup_finish (test->service, result, &error);
     621         [ -  + ]:          1 :         g_assert_no_error (error);
     622                 :            : 
     623         [ -  + ]:          1 :         g_assert_nonnull (value);
     624         [ -  + ]:          1 :         g_assert_cmpstr (secret_value_get (value, &length), ==, "111");
     625         [ -  + ]:          1 :         g_assert_cmpuint (length, ==, 3);
     626                 :            : 
     627                 :          1 :         secret_value_unref (value);
     628                 :          1 :         g_object_unref (result);
     629                 :          1 : }
     630                 :            : 
     631                 :            : static void
     632                 :          1 : test_lookup_locked (Test *test,
     633                 :            :                     gconstpointer used)
     634                 :            : {
     635                 :          1 :         GError *error = NULL;
     636                 :            :         GHashTable *attributes;
     637                 :            :         SecretValue *value;
     638                 :            :         gsize length;
     639                 :            : 
     640                 :          1 :         attributes = secret_attributes_build (&MOCK_SCHEMA,
     641                 :            :                                               "even", FALSE,
     642                 :            :                                               "string", "tres",
     643                 :            :                                               "number", 3,
     644                 :            :                                               NULL);
     645                 :            : 
     646                 :          1 :         value = secret_service_lookup_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
     647                 :            : 
     648         [ -  + ]:          1 :         g_assert_no_error (error);
     649                 :          1 :         g_hash_table_unref (attributes);
     650                 :            : 
     651         [ -  + ]:          1 :         g_assert_nonnull (value);
     652         [ -  + ]:          1 :         g_assert_cmpstr (secret_value_get (value, &length), ==, "3333");
     653         [ -  + ]:          1 :         g_assert_cmpuint (length, ==, 4);
     654                 :            : 
     655                 :          1 :         secret_value_unref (value);
     656                 :          1 : }
     657                 :            : 
     658                 :            : static void
     659                 :          1 : test_lookup_no_match (Test *test,
     660                 :            :                       gconstpointer used)
     661                 :            : {
     662                 :          1 :         GError *error = NULL;
     663                 :            :         GHashTable *attributes;
     664                 :            :         SecretValue *value;
     665                 :            : 
     666                 :          1 :         attributes = secret_attributes_build (&MOCK_SCHEMA,
     667                 :            :                                               "even", TRUE,
     668                 :            :                                               "string", "one",
     669                 :            :                                               NULL);
     670                 :            : 
     671                 :            :         /* Won't match anything */
     672                 :          1 :         value = secret_service_lookup_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
     673                 :            : 
     674         [ -  + ]:          1 :         g_assert_no_error (error);
     675         [ -  + ]:          1 :         g_assert_null (value);
     676                 :          1 :         g_hash_table_unref (attributes);
     677                 :          1 : }
     678                 :            : 
     679                 :            : static void
     680                 :          1 : test_lookup_no_name (Test *test,
     681                 :            :                      gconstpointer used)
     682                 :            : {
     683                 :          1 :         GError *error = NULL;
     684                 :            :         GHashTable *attributes;
     685                 :            :         SecretValue *value;
     686                 :            :         gsize length;
     687                 :            : 
     688                 :          1 :         attributes = secret_attributes_build (&MOCK_SCHEMA,
     689                 :            :                                               "number", 5,
     690                 :            :                                               NULL);
     691                 :            : 
     692                 :            :         /* should return null, because nothing with mock schema and 5 */
     693                 :          1 :         value = secret_service_lookup_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
     694         [ -  + ]:          1 :         g_assert_no_error (error);
     695         [ -  + ]:          1 :         g_assert_null (value);
     696                 :            : 
     697                 :            :         /* should return an item, because we have a prime schema with 5, and flags not to match name */
     698                 :          1 :         value = secret_service_lookup_sync (test->service, &NO_NAME_SCHEMA, attributes, NULL, &error);
     699                 :            : 
     700         [ -  + ]:          1 :         g_assert_no_error (error);
     701                 :            : 
     702         [ -  + ]:          1 :         g_assert_nonnull (value);
     703         [ -  + ]:          1 :         g_assert_cmpstr (secret_value_get (value, &length), ==, "555");
     704         [ -  + ]:          1 :         g_assert_cmpuint (length, ==, 3);
     705                 :            : 
     706                 :          1 :         secret_value_unref (value);
     707                 :          1 :         g_hash_table_unref (attributes);
     708                 :          1 : }
     709                 :            : 
     710                 :            : static void
     711                 :          1 : test_store_sync (Test *test,
     712                 :            :                  gconstpointer used)
     713                 :            : {
     714                 :          1 :         const gchar *collection_path = "/org/freedesktop/secrets/collection/english";
     715                 :          1 :         SecretValue *value = secret_value_new ("apassword", -1, "text/plain");
     716                 :            :         GHashTable *attributes;
     717                 :          1 :         GError *error = NULL;
     718                 :            :         gchar **paths;
     719                 :            :         gboolean ret;
     720                 :            :         gsize length;
     721                 :            : 
     722                 :          1 :         attributes = secret_attributes_build (&MOCK_SCHEMA,
     723                 :            :                                               "even", FALSE,
     724                 :            :                                               "string", "seventeen",
     725                 :            :                                               "number", 17,
     726                 :            :                                               NULL);
     727                 :            : 
     728                 :          1 :         ret = secret_service_store_sync (test->service, &MOCK_SCHEMA, attributes, collection_path,
     729                 :            :                                          "New Item Label", value, NULL, &error);
     730         [ -  + ]:          1 :         g_assert_true (ret);
     731         [ -  + ]:          1 :         g_assert_no_error (error);
     732                 :          1 :         secret_value_unref (value);
     733                 :          1 :         g_hash_table_unref (attributes);
     734                 :            : 
     735                 :          1 :         attributes = g_hash_table_new (g_str_hash, g_str_equal);
     736                 :          1 :         g_hash_table_insert (attributes, "even", "false");
     737                 :          1 :         g_hash_table_insert (attributes, "string", "seventeen");
     738                 :          1 :         g_hash_table_insert (attributes, "number", "17");
     739                 :            : 
     740                 :          1 :         ret = secret_service_search_for_dbus_paths_sync (test->service, &MOCK_SCHEMA, attributes,
     741                 :            :                                                          NULL, &paths, NULL, &error);
     742                 :          1 :         g_hash_table_unref (attributes);
     743         [ -  + ]:          1 :         g_assert_true (ret);
     744                 :            : 
     745         [ -  + ]:          1 :         g_assert_nonnull (paths);
     746         [ -  + ]:          1 :         g_assert_nonnull (paths[0]);
     747         [ -  + ]:          1 :         g_assert_null (paths[1]);
     748                 :            : 
     749                 :          1 :         value = secret_service_get_secret_for_dbus_path_sync (test->service, paths[0],
     750                 :            :                                                               NULL, &error);
     751         [ -  + ]:          1 :         g_assert_no_error (error);
     752                 :            : 
     753         [ -  + ]:          1 :         g_assert_nonnull (value);
     754         [ -  + ]:          1 :         g_assert_cmpstr (secret_value_get (value, &length), ==, "apassword");
     755         [ -  + ]:          1 :         g_assert_cmpuint (length, ==, 9);
     756                 :            : 
     757                 :          1 :         secret_value_unref (value);
     758                 :          1 :         g_strfreev (paths);
     759                 :          1 : }
     760                 :            : 
     761                 :            : static void
     762                 :          1 : test_store_replace (Test *test,
     763                 :            :                     gconstpointer used)
     764                 :            : {
     765                 :          1 :         const gchar *collection_path = "/org/freedesktop/secrets/collection/english";
     766                 :          1 :         SecretValue *value = secret_value_new ("apassword", -1, "text/plain");
     767                 :            :         GHashTable *attributes;
     768                 :          1 :         GError *error = NULL;
     769                 :            :         gchar **paths;
     770                 :            :         gboolean ret;
     771                 :            : 
     772                 :          1 :         attributes = secret_attributes_build (&MOCK_SCHEMA,
     773                 :            :                                               "even", FALSE,
     774                 :            :                                               "string", "seventeen",
     775                 :            :                                               "number", 17,
     776                 :            :                                               NULL);
     777                 :            : 
     778                 :          1 :         ret = secret_service_store_sync (test->service, &MOCK_SCHEMA, attributes, collection_path,
     779                 :            :                                           "New Item Label", value, NULL, &error);
     780         [ -  + ]:          1 :         g_assert_true (ret);
     781         [ -  + ]:          1 :         g_assert_no_error (error);
     782                 :            : 
     783                 :          1 :         ret = secret_service_store_sync (test->service, &MOCK_SCHEMA, attributes, collection_path,
     784                 :            :                                           "Another Label", value, NULL, &error);
     785         [ -  + ]:          1 :         g_assert_true (ret);
     786         [ -  + ]:          1 :         g_assert_no_error (error);
     787                 :          1 :         secret_value_unref (value);
     788                 :          1 :         g_hash_table_unref (attributes);
     789                 :            : 
     790                 :          1 :         attributes = g_hash_table_new (g_str_hash, g_str_equal);
     791                 :          1 :         g_hash_table_insert (attributes, "even", "false");
     792                 :          1 :         g_hash_table_insert (attributes, "string", "seventeen");
     793                 :          1 :         g_hash_table_insert (attributes, "number", "17");
     794                 :            : 
     795                 :          1 :         ret = secret_service_search_for_dbus_paths_sync (test->service, &MOCK_SCHEMA, attributes,
     796                 :            :                                                          NULL, &paths, NULL, &error);
     797                 :          1 :         g_hash_table_unref (attributes);
     798         [ -  + ]:          1 :         g_assert_true (ret);
     799                 :            : 
     800         [ -  + ]:          1 :         g_assert_nonnull (paths);
     801         [ -  + ]:          1 :         g_assert_nonnull (paths[0]);
     802         [ -  + ]:          1 :         g_assert_null (paths[1]);
     803                 :            : 
     804                 :          1 :         g_strfreev (paths);
     805                 :          1 : }
     806                 :            : 
     807                 :            : static void
     808                 :          1 : test_store_async (Test *test,
     809                 :            :                   gconstpointer used)
     810                 :            : {
     811                 :          1 :         const gchar *collection_path = "/org/freedesktop/secrets/collection/english";
     812                 :          1 :         SecretValue *value = secret_value_new ("apassword", -1, "text/plain");
     813                 :          1 :         GAsyncResult *result = NULL;
     814                 :            :         GHashTable *attributes;
     815                 :          1 :         GError *error = NULL;
     816                 :            :         gchar **paths;
     817                 :            :         gboolean ret;
     818                 :            :         gsize length;
     819                 :            : 
     820                 :          1 :         attributes = secret_attributes_build (&MOCK_SCHEMA,
     821                 :            :                                               "even", FALSE,
     822                 :            :                                               "string", "seventeen",
     823                 :            :                                               "number", 17,
     824                 :            :                                               NULL);
     825                 :            : 
     826                 :          1 :         secret_service_store (test->service, &MOCK_SCHEMA, attributes, collection_path,
     827                 :            :                                "New Item Label", value, NULL, on_complete_get_result, &result);
     828         [ -  + ]:          1 :         g_assert_null (result);
     829                 :          1 :         secret_value_unref (value);
     830                 :          1 :         g_hash_table_unref (attributes);
     831                 :            : 
     832         [ -  + ]:          1 :         egg_test_wait ();
     833                 :            : 
     834                 :          1 :         ret = secret_service_store_finish (test->service, result, &error);
     835         [ -  + ]:          1 :         g_assert_true (ret);
     836         [ -  + ]:          1 :         g_assert_no_error (error);
     837                 :          1 :         g_object_unref (result);
     838                 :            : 
     839                 :          1 :         attributes = g_hash_table_new (g_str_hash, g_str_equal);
     840                 :          1 :         g_hash_table_insert (attributes, "even", "false");
     841                 :          1 :         g_hash_table_insert (attributes, "string", "seventeen");
     842                 :          1 :         g_hash_table_insert (attributes, "number", "17");
     843                 :            : 
     844                 :          1 :         ret = secret_service_search_for_dbus_paths_sync (test->service, &MOCK_SCHEMA, attributes,
     845                 :            :                                                          NULL, &paths, NULL, &error);
     846                 :          1 :         g_hash_table_unref (attributes);
     847         [ -  + ]:          1 :         g_assert_true (ret);
     848                 :            : 
     849         [ -  + ]:          1 :         g_assert_nonnull (paths);
     850         [ -  + ]:          1 :         g_assert_nonnull (paths[0]);
     851         [ -  + ]:          1 :         g_assert_null (paths[1]);
     852                 :            : 
     853                 :          1 :         value = secret_service_get_secret_for_dbus_path_sync (test->service, paths[0],
     854                 :            :                                                               NULL, &error);
     855         [ -  + ]:          1 :         g_assert_no_error (error);
     856                 :            : 
     857         [ -  + ]:          1 :         g_assert_nonnull (value);
     858         [ -  + ]:          1 :         g_assert_cmpstr (secret_value_get (value, &length), ==, "apassword");
     859         [ -  + ]:          1 :         g_assert_cmpuint (length, ==, 9);
     860                 :            : 
     861                 :          1 :         secret_value_unref (value);
     862                 :          1 :         g_strfreev (paths);
     863                 :          1 : }
     864                 :            : 
     865                 :            : static void
     866                 :          1 : test_store_no_default (Test *test,
     867                 :            :                        gconstpointer used)
     868                 :            : {
     869                 :          1 :         SecretValue *value = secret_value_new ("apassword", -1, "text/plain");
     870                 :            :         GHashTable *attributes;
     871                 :          1 :         GError *error = NULL;
     872                 :            :         gchar **paths;
     873                 :            :         gboolean ret;
     874                 :            :         gsize length;
     875                 :            : 
     876                 :          1 :         attributes = secret_attributes_build (&MOCK_SCHEMA,
     877                 :            :                                               "even", FALSE,
     878                 :            :                                               "string", "seventeen",
     879                 :            :                                               "number", 17,
     880                 :            :                                               NULL);
     881                 :            : 
     882                 :          1 :         ret = secret_service_store_sync (test->service, &MOCK_SCHEMA, attributes, SECRET_COLLECTION_DEFAULT,
     883                 :            :                                          "New Item Label", value, NULL, &error);
     884         [ -  + ]:          1 :         g_assert_true (ret);
     885         [ -  + ]:          1 :         g_assert_no_error (error);
     886                 :          1 :         secret_value_unref (value);
     887                 :          1 :         g_hash_table_unref (attributes);
     888                 :            : 
     889                 :          1 :         attributes = g_hash_table_new (g_str_hash, g_str_equal);
     890                 :          1 :         g_hash_table_insert (attributes, "even", "false");
     891                 :          1 :         g_hash_table_insert (attributes, "string", "seventeen");
     892                 :          1 :         g_hash_table_insert (attributes, "number", "17");
     893                 :            : 
     894                 :          1 :         ret = secret_service_search_for_dbus_paths_sync (test->service, &MOCK_SCHEMA, attributes,
     895                 :            :                                                          NULL, &paths, NULL, &error);
     896                 :          1 :         g_hash_table_unref (attributes);
     897         [ -  + ]:          1 :         g_assert_true (ret);
     898                 :            : 
     899         [ -  + ]:          1 :         g_assert_nonnull (paths);
     900         [ -  + ]:          1 :         g_assert_nonnull (paths[0]);
     901         [ -  + ]:          1 :         g_assert_null (paths[1]);
     902                 :            : 
     903                 :          1 :         value = secret_service_get_secret_for_dbus_path_sync (test->service, paths[0],
     904                 :            :                                                               NULL, &error);
     905         [ -  + ]:          1 :         g_assert_no_error (error);
     906                 :            : 
     907         [ -  + ]:          1 :         g_assert_nonnull (value);
     908         [ -  + ]:          1 :         g_assert_cmpstr (secret_value_get (value, &length), ==, "apassword");
     909         [ -  + ]:          1 :         g_assert_cmpuint (length, ==, 9);
     910                 :            : 
     911                 :          1 :         secret_value_unref (value);
     912                 :          1 :         g_strfreev (paths);
     913                 :          1 : }
     914                 :            : 
     915                 :            : static void
     916                 :          1 : test_set_alias_sync (Test *test,
     917                 :            :                      gconstpointer used)
     918                 :            : {
     919                 :            :         SecretCollection *collection;
     920                 :            :         gchar *blah;
     921                 :          1 :         GError *error = NULL;
     922                 :            :         gboolean ret;
     923                 :            : 
     924                 :          1 :         blah = secret_service_read_alias_dbus_path_sync (test->service, "blah", NULL, &error);
     925         [ -  + ]:          1 :         g_assert_no_error (error);
     926         [ -  + ]:          1 :         g_assert_null (blah);
     927                 :            : 
     928                 :          1 :         collection = secret_collection_new_for_dbus_path_sync (test->service,
     929                 :            :                                                                "/org/freedesktop/secrets/collection/english",
     930                 :            :                                                                SECRET_COLLECTION_NONE, NULL, &error);
     931         [ -  + ]:          1 :         g_assert_no_error (error);
     932   [ -  +  +  -  :          1 :         g_assert_true (SECRET_IS_COLLECTION (collection));
             +  -  -  + ]
     933                 :            : 
     934                 :          1 :         ret = secret_service_set_alias_sync (test->service, "blah", collection, NULL, &error);
     935         [ -  + ]:          1 :         g_assert_no_error (error);
     936         [ -  + ]:          1 :         g_assert_true (ret);
     937                 :            : 
     938                 :          1 :         blah = secret_service_read_alias_dbus_path_sync (test->service, "blah", NULL, &error);
     939         [ -  + ]:          1 :         g_assert_no_error (error);
     940         [ -  + ]:          1 :         g_assert_cmpstr (blah, ==, g_dbus_proxy_get_object_path (G_DBUS_PROXY (collection)));
     941                 :          1 :         g_free (blah);
     942                 :            : 
     943                 :          1 :         ret = secret_service_set_alias_sync (test->service, "blah", NULL, NULL, &error);
     944         [ -  + ]:          1 :         g_assert_no_error (error);
     945         [ -  + ]:          1 :         g_assert_true (ret);
     946                 :            : 
     947                 :          1 :         blah = secret_service_read_alias_dbus_path_sync (test->service, "blah", NULL, &error);
     948         [ -  + ]:          1 :         g_assert_no_error (error);
     949         [ -  + ]:          1 :         g_assert_null (blah);
     950                 :            : 
     951                 :          1 :         g_object_unref (collection);
     952                 :          1 : }
     953                 :            : 
     954                 :            : int
     955                 :          1 : main (int argc, char **argv)
     956                 :            : {
     957                 :          1 :         g_test_init (&argc, &argv, NULL);
     958                 :          1 :         g_set_prgname ("test-service");
     959                 :            : 
     960                 :          1 :         g_test_add ("/service/search-sync", Test, "mock-service-normal.py", setup, test_search_sync, teardown);
     961                 :          1 :         g_test_add ("/service/search-async", Test, "mock-service-normal.py", setup, test_search_async, teardown);
     962                 :          1 :         g_test_add ("/service/search-all-sync", Test, "mock-service-normal.py", setup, test_search_all_sync, teardown);
     963                 :          1 :         g_test_add ("/service/search-all-async", Test, "mock-service-normal.py", setup, test_search_all_async, teardown);
     964                 :          1 :         g_test_add ("/service/search-unlock-sync", Test, "mock-service-normal.py", setup, test_search_unlock_sync, teardown);
     965                 :          1 :         g_test_add ("/service/search-unlock-async", Test, "mock-service-normal.py", setup, test_search_unlock_async, teardown);
     966                 :          1 :         g_test_add ("/service/search-secrets-sync", Test, "mock-service-normal.py", setup, test_search_secrets_sync, teardown);
     967                 :          1 :         g_test_add ("/service/search-secrets-async", Test, "mock-service-normal.py", setup, test_search_secrets_async, teardown);
     968                 :            : 
     969                 :          1 :         g_test_add ("/service/lock-sync", Test, "mock-service-lock.py", setup, test_lock_sync, teardown);
     970                 :            : 
     971                 :          1 :         g_test_add ("/service/unlock-sync", Test, "mock-service-lock.py", setup, test_unlock_sync, teardown);
     972                 :            : 
     973                 :          1 :         g_test_add ("/service/lookup-sync", Test, "mock-service-normal.py", setup, test_lookup_sync, teardown);
     974                 :          1 :         g_test_add ("/service/lookup-async", Test, "mock-service-normal.py", setup, test_lookup_async, teardown);
     975                 :          1 :         g_test_add ("/service/lookup-locked", Test, "mock-service-normal.py", setup, test_lookup_locked, teardown);
     976                 :          1 :         g_test_add ("/service/lookup-no-match", Test, "mock-service-normal.py", setup, test_lookup_no_match, teardown);
     977                 :          1 :         g_test_add ("/service/lookup-no-name", Test, "mock-service-normal.py", setup, test_lookup_no_name, teardown);
     978                 :            : 
     979                 :          1 :         g_test_add ("/service/clear-sync", Test, "mock-service-delete.py", setup, test_clear_sync, teardown);
     980                 :          1 :         g_test_add ("/service/clear-async", Test, "mock-service-delete.py", setup, test_clear_async, teardown);
     981                 :          1 :         g_test_add ("/service/clear-locked", Test, "mock-service-delete.py", setup, test_clear_locked, teardown);
     982                 :          1 :         g_test_add ("/service/clear-no-match", Test, "mock-service-delete.py", setup, test_clear_no_match, teardown);
     983                 :          1 :         g_test_add ("/service/clear-no-name", Test, "mock-service-delete.py", setup, test_clear_no_name, teardown);
     984                 :            : 
     985                 :          1 :         g_test_add ("/service/store-sync", Test, "mock-service-normal.py", setup, test_store_sync, teardown);
     986                 :          1 :         g_test_add ("/service/store-async", Test, "mock-service-normal.py", setup, test_store_async, teardown);
     987                 :          1 :         g_test_add ("/service/store-replace", Test, "mock-service-normal.py", setup, test_store_replace, teardown);
     988                 :          1 :         g_test_add ("/service/store-no-default", Test, "mock-service-empty.py", setup, test_store_no_default, teardown);
     989                 :            : 
     990                 :          1 :         g_test_add ("/service/set-alias-sync", Test, "mock-service-normal.py", setup, test_set_alias_sync, teardown);
     991                 :            : 
     992                 :          1 :         return egg_tests_run_with_loop ();
     993                 :            : }

Generated by: LCOV version 1.14