From 199df7547dba1ddf9a77fbd6540705ddd357e944 Mon Sep 17 00:00:00 2001 From: Stephan Bosch Date: Wed, 20 Aug 2025 20:43:38 +0200 Subject: [PATCH] lib-auth-client: auth-master - Improve some of the connection failure messages returned to caller --- src/lib-auth-client/auth-master.c | 9 +++++++-- src/lib-auth-client/test-auth-master.c | 24 ++++++++++++++++-------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/lib-auth-client/auth-master.c b/src/lib-auth-client/auth-master.c index 9960eb9813..b363dc87b3 100644 --- a/src/lib-auth-client/auth-master.c +++ b/src/lib-auth-client/auth-master.c @@ -207,8 +207,12 @@ static void auth_master_destroy(struct connection *_conn) auth_master_connection_failure(conn, NULL); break; default: - if (conn->requests_head != NULL) + if (conn->requests_head != NULL) { e_error(conn->conn.event, "Disconnected unexpectedly"); + auth_master_connection_failure(conn, + "Unexpectedly disconnected from auth service"); + break; + } auth_master_connection_failure(conn, NULL); } } @@ -473,7 +477,8 @@ auth_master_delayed_connect_failure(struct auth_master_connection *conn) i_assert(conn->to_connect != NULL); timeout_remove(&conn->to_connect); - auth_master_connection_failure(conn, "Connect failed"); + auth_master_connection_failure(conn, + "Failed to connect to auth service"); } int auth_master_connect(struct auth_master_connection *conn) diff --git a/src/lib-auth-client/test-auth-master.c b/src/lib-auth-client/test-auth-master.c index dbfcc0c94b..5680b7da1d 100644 --- a/src/lib-auth-client/test-auth-master.c +++ b/src/lib-auth-client/test-auth-master.c @@ -512,13 +512,15 @@ static bool test_client_passdb_disconnect(void) ret = test_client_passdb_lookup_simple("hendrik", FALSE, &error); test_out("run (ret == -1)", ret == -1); test_assert(error != NULL && - str_begins_with(error, "Disconnected from auth service")); + str_begins_with(error, + "Unexpectedly disconnected from auth service")); test_expect_error_string("Disconnected unexpectedly"); ret = test_client_passdb_lookup_simple_async("hendrik", FALSE, &error); test_out("run async (ret == -1)", ret == -1); test_assert(error != NULL && - str_begins_with(error, "Disconnected from auth service")); + str_begins_with(error, + "Unexpectedly disconnected from auth service")); return FALSE; } @@ -532,13 +534,15 @@ static bool test_client_passdb_reconnect(void) ret = test_client_passdb_lookup_simple("hendrik", TRUE, &error); test_out("run (ret == -1)", ret == -1); test_assert(error != NULL && - str_begins_with(error, "Disconnected from auth service")); + str_begins_with(error, + "Unexpectedly disconnected from auth service")); test_expect_errors(2); ret = test_client_passdb_lookup_simple_async("hendrik", TRUE, &error); test_out("run async (ret == -1)", ret == -1); test_assert(error != NULL && - str_begins_with(error, "Disconnected from auth service")); + str_begins_with(error, + "Unexpectedly disconnected from auth service")); return FALSE; } @@ -726,13 +730,15 @@ static bool test_client_userdb_disconnect(void) ret = test_client_userdb_lookup_simple("hendrik", FALSE, &error); test_out("run (ret == -1)", ret == -1); test_assert(error != NULL && - str_begins_with(error, "Disconnected from auth service")); + str_begins_with(error, + "Unexpectedly disconnected from auth service")); test_expect_error_string("Disconnected unexpectedly"); ret = test_client_userdb_lookup_simple_async("hendrik", FALSE, &error); test_out("run async (ret == -1)", ret == -1); test_assert(error != NULL && - str_begins_with(error, "Disconnected from auth service")); + str_begins_with(error, + "Unexpectedly disconnected from auth service")); return FALSE; } @@ -746,13 +752,15 @@ static bool test_client_userdb_reconnect(void) ret = test_client_userdb_lookup_simple("hendrik", TRUE, &error); test_out("run (ret == -1)", ret == -1); test_assert(error != NULL && - str_begins_with(error, "Disconnected from auth service")); + str_begins_with(error, + "Unexpectedly disconnected from auth service")); test_expect_errors(2); ret = test_client_userdb_lookup_simple_async("hendrik", TRUE, &error); test_out("run async (ret == -1)", ret == -1); test_assert(error != NULL && - str_begins_with(error, "Disconnected from auth service")); + str_begins_with(error, + "Unexpectedly disconnected from auth service")); return FALSE; } -- 2.47.3