From 0f49b34fa2b20dee49a78f362fd3fae546077be4 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Wed, 29 Nov 2023 06:44:32 +0900 Subject: [PATCH] tests: Conditionalize session algorithm check in test-session When compiled without libgcrypt, some of the tests in test-session fails as they expect the session algorithm to be "dh-ietf1024-sha256-aes128-cbc-pkcs7". This adds a build-time conditional to guard against it. Signed-off-by: Daiki Ueno --- libsecret/test-session.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libsecret/test-session.c b/libsecret/test-session.c index 8e993ee..c94f2fa 100644 --- a/libsecret/test-session.c +++ b/libsecret/test-session.c @@ -29,6 +29,12 @@ #include #include +#ifdef WITH_GCRYPT +#define SESSION_ALGO "dh-ietf1024-sha256-aes128-cbc-pkcs7" +#else +#define SESSION_ALGO "plain" +#endif + typedef struct { SecretService *service; } Test; @@ -73,7 +79,7 @@ test_ensure (Test *test, g_assert_no_error (error); g_assert_true (ret); g_assert_cmpstr (secret_service_get_session_dbus_path (test->service), !=, NULL); - g_assert_cmpstr (secret_service_get_session_algorithms (test->service), ==, "dh-ietf1024-sha256-aes128-cbc-pkcs7"); + g_assert_cmpstr (secret_service_get_session_algorithms (test->service), ==, SESSION_ALGO); } static void @@ -91,14 +97,14 @@ test_ensure_twice (Test *test, g_assert_no_error (error); g_assert_true (ret); g_assert_cmpstr (secret_service_get_session_dbus_path (test->service), !=, NULL); - g_assert_cmpstr (secret_service_get_session_algorithms (test->service), ==, "dh-ietf1024-sha256-aes128-cbc-pkcs7"); + g_assert_cmpstr (secret_service_get_session_algorithms (test->service), ==, SESSION_ALGO); path = g_strdup (secret_service_get_session_dbus_path (test->service)); ret = secret_service_ensure_session_sync (test->service, NULL, &error); g_assert_no_error (error); g_assert_true (ret); g_assert_cmpstr (secret_service_get_session_dbus_path (test->service), ==, path); - g_assert_cmpstr (secret_service_get_session_algorithms (test->service), ==, "dh-ietf1024-sha256-aes128-cbc-pkcs7"); + g_assert_cmpstr (secret_service_get_session_algorithms (test->service), ==, SESSION_ALGO); g_free (path); } @@ -172,7 +178,7 @@ test_ensure_async_aes (Test *test, g_assert_true (ret); g_assert_cmpstr (secret_service_get_session_dbus_path (test->service), !=, NULL); - g_assert_cmpstr (secret_service_get_session_algorithms (test->service), ==, "dh-ietf1024-sha256-aes128-cbc-pkcs7"); + g_assert_cmpstr (secret_service_get_session_algorithms (test->service), ==, SESSION_ALGO); g_object_unref (result); }