[libsecret/wip/dueno/simple-item: 7/8] tests: Add tests for binary variant of secret_{lookup, store}
- From: Daiki Ueno <dueno src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsecret/wip/dueno/simple-item: 7/8] tests: Add tests for binary variant of secret_{lookup, store}
- Date: Tue, 2 Jul 2019 09:25:17 +0000 (UTC)
commit f7b5f3c115670c7a42ba4c092d5375e8c69f4d07
Author: Daiki Ueno <dueno src gnome org>
Date: Sat Jun 29 09:55:01 2019 +0200
tests: Add tests for binary variant of secret_{lookup,store}
libsecret/test-password.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+)
---
diff --git a/libsecret/test-password.c b/libsecret/test-password.c
index fbd706d..0fea2fd 100644
--- a/libsecret/test-password.c
+++ b/libsecret/test-password.c
@@ -438,6 +438,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)
{
@@ -466,6 +536,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 ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]