mirror of
https://gitlab.gnome.org/GNOME/libsecret.git
synced 2024-12-22 04:38:55 +00:00
tests: Add tests for binary variant of secret_{lookup,store}
This commit is contained in:
parent
29c1460fd7
commit
2ae6ec89f4
@ -440,6 +440,76 @@ test_search_no_name (Test *test,
|
||||
g_list_free (items);
|
||||
}
|
||||
|
||||
static void
|
||||
test_binary_sync (Test *test,
|
||||
gconstpointer used)
|
||||
{
|
||||
const gchar *collection_path = "/org/freedesktop/secrets/collection/english";
|
||||
GError *error = NULL;
|
||||
SecretValue *value;
|
||||
gboolean ret;
|
||||
|
||||
value = secret_value_new ("the password", -1, "text/plain");
|
||||
ret = secret_password_store_binary_sync (&MOCK_SCHEMA, collection_path,
|
||||
"Label here", value, NULL, &error,
|
||||
"even", TRUE,
|
||||
"string", "twelve",
|
||||
"number", 12,
|
||||
NULL);
|
||||
|
||||
g_assert_no_error (error);
|
||||
g_assert_true (ret);
|
||||
secret_value_unref (value);
|
||||
|
||||
value = secret_password_lookup_binary_sync (&MOCK_SCHEMA, NULL, &error,
|
||||
"string", "twelve",
|
||||
NULL);
|
||||
|
||||
g_assert_no_error (error);
|
||||
g_assert_cmpstr (secret_value_get_text (value), ==, "the password");
|
||||
|
||||
secret_value_unref (value);
|
||||
}
|
||||
|
||||
static void
|
||||
test_binary_async (Test *test,
|
||||
gconstpointer used)
|
||||
{
|
||||
const gchar *collection_path = "/org/freedesktop/secrets/collection/english";
|
||||
GAsyncResult *result = NULL;
|
||||
GError *error = NULL;
|
||||
SecretValue *value;
|
||||
gboolean ret;
|
||||
|
||||
value = secret_value_new ("the password", -1, "text/plain");
|
||||
secret_password_store_binary (&MOCK_SCHEMA, collection_path, "Label here",
|
||||
value, NULL, on_complete_get_result, &result,
|
||||
"even", TRUE,
|
||||
"string", "twelve",
|
||||
"number", 12,
|
||||
NULL);
|
||||
g_assert_null (result);
|
||||
secret_value_unref (value);
|
||||
|
||||
egg_test_wait ();
|
||||
|
||||
ret = secret_password_store_finish (result, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert_true (ret);
|
||||
g_object_unref (result);
|
||||
|
||||
value = secret_password_lookup_binary_sync (&MOCK_SCHEMA, NULL, &error,
|
||||
"string", "twelve",
|
||||
NULL);
|
||||
|
||||
g_assert_no_error (error);
|
||||
g_assert_nonnull (value);
|
||||
|
||||
g_assert_cmpstr (secret_value_get_text (value), ==, "the password");
|
||||
|
||||
secret_value_unref (value);
|
||||
}
|
||||
|
||||
static void
|
||||
test_password_free_null (void)
|
||||
{
|
||||
@ -468,6 +538,9 @@ main (int argc, char **argv)
|
||||
g_test_add ("/password/search-async", Test, "mock-service-normal.py", setup, test_search_async, teardown);
|
||||
g_test_add ("/password/search-no-name", Test, "mock-service-normal.py", setup, test_search_no_name, teardown);
|
||||
|
||||
g_test_add ("/password/binary-sync", Test, "mock-service-normal.py", setup, test_binary_sync, teardown);
|
||||
g_test_add ("/password/binary-async", Test, "mock-service-normal.py", setup, test_binary_async, teardown);
|
||||
|
||||
g_test_add_func ("/password/free-null", test_password_free_null);
|
||||
|
||||
return egg_tests_run_with_loop ();
|
||||
|
Loading…
Reference in New Issue
Block a user