[libsoup/carlosgc/cancel-auth-on-auth-cb] auth: do not pause the message when cancelled in the authenticate callback
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/carlosgc/cancel-auth-on-auth-cb] auth: do not pause the message when cancelled in the authenticate callback
- Date: Thu, 4 Feb 2021 12:48:17 +0000 (UTC)
commit 4a71ab8df15a57891f99c1b64495cc2b55a7f992
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Thu Feb 4 13:46:56 2021 +0100
auth: do not pause the message when cancelled in the authenticate callback
We are currently pausing the message that is never unpaused because the
auth is already cancelled.
libsoup/auth/soup-auth-manager.c | 2 +-
tests/auth-test.c | 42 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 1 deletion(-)
---
diff --git a/libsoup/auth/soup-auth-manager.c b/libsoup/auth/soup-auth-manager.c
index 5e602dce..8c02c0ca 100644
--- a/libsoup/auth/soup-auth-manager.c
+++ b/libsoup/auth/soup-auth-manager.c
@@ -566,7 +566,7 @@ authenticate_auth (SoupAuthManager *manager, SoupAuth *auth,
original_msg = soup_session_get_original_message_for_authentication (priv->session,
msg);
handled = soup_message_authenticate (original_msg, auth, prior_auth_failed);
- if (handled && !soup_auth_is_authenticated (auth)) {
+ if (handled && !soup_auth_is_authenticated (auth) && !soup_auth_is_cancelled (auth)) {
soup_session_pause_message (priv->session, msg);
g_object_set_data_full (G_OBJECT (msg), "auth-msg-session",
g_object_ref (priv->session),
diff --git a/tests/auth-test.c b/tests/auth-test.c
index 305179d8..271e8aa6 100644
--- a/tests/auth-test.c
+++ b/tests/auth-test.c
@@ -1640,6 +1640,47 @@ do_cancel_after_retry_test (void)
g_main_loop_unref (loop);
}
+static gboolean
+cancel_on_authenticate (SoupMessage *msg,
+ SoupAuth *auth,
+ gboolean retrying)
+{
+ soup_auth_cancel (auth);
+
+ return TRUE;
+}
+
+static void
+do_cancel_on_authenticate (void)
+{
+ SoupSession *session;
+ SoupMessage *msg;
+ char *uri;
+
+ SOUP_TEST_SKIP_IF_NO_APACHE;
+
+ session = soup_test_session_new (NULL);
+
+ loop = g_main_loop_new (NULL, FALSE);
+
+ uri = g_strconcat (base_uri, "Digest/realm1/", NULL);
+ msg = soup_message_new ("GET", uri);
+ g_signal_connect (msg, "authenticate",
+ G_CALLBACK (cancel_on_authenticate),
+ NULL);
+ g_signal_connect (msg, "finished",
+ G_CALLBACK (async_no_auth_cache_finished), NULL);
+ soup_session_send_async (session, msg, G_PRIORITY_DEFAULT, NULL, NULL, NULL);
+ g_main_loop_run (loop);
+
+ soup_test_assert_message_status (msg, SOUP_STATUS_UNAUTHORIZED);
+
+ g_object_unref (msg);
+ g_free (uri);
+ soup_test_session_abort_unref (session);
+ g_main_loop_unref (loop);
+}
+
int
main (int argc, char **argv)
{
@@ -1668,6 +1709,7 @@ main (int argc, char **argv)
g_test_add_func ("/auth/async-message-do-not-use-auth-cache",
do_async_message_do_not_use_auth_cache_test);
g_test_add_func ("/auth/authorization-header-request", do_message_has_authorization_header_test);
g_test_add_func ("/auth/cancel-after-retry", do_cancel_after_retry_test);
+ g_test_add_func ("/auth/cancel-on-authenticate", do_cancel_on_authenticate);
ret = g_test_run ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]