summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libsoup/soup-auth-manager.c4
-rw-r--r--tests/auth-test.c61
2 files changed, 63 insertions, 2 deletions
diff --git a/libsoup/soup-auth-manager.c b/libsoup/soup-auth-manager.c
index 704661bc..9ff446cc 100644
--- a/libsoup/soup-auth-manager.c
+++ b/libsoup/soup-auth-manager.c
@@ -625,7 +625,7 @@ auth_got_headers (SoupMessage *msg, gpointer manager)
/* If we need to authenticate, try to do it. */
authenticate_auth (manager, auth, msg,
prior_auth_failed, FALSE, TRUE);
- soup_message_set_auth (msg, soup_auth_is_ready (auth, msg) ? auth : NULL);
+ soup_message_set_auth (msg, auth);
g_object_unref (auth);
g_mutex_unlock (&priv->lock);
}
@@ -689,7 +689,7 @@ proxy_auth_got_headers (SoupMessage *msg, gpointer manager)
/* If we need to authenticate, try to do it. */
authenticate_auth (manager, auth, msg,
prior_auth_failed, TRUE, TRUE);
- soup_message_set_proxy_auth (msg, soup_auth_is_ready (auth, msg) ? auth : NULL);
+ soup_message_set_proxy_auth (msg, auth);
g_object_unref (auth);
g_mutex_unlock (&priv->lock);
}
diff --git a/tests/auth-test.c b/tests/auth-test.c
index b674c61c..23e22133 100644
--- a/tests/auth-test.c
+++ b/tests/auth-test.c
@@ -1336,6 +1336,66 @@ do_message_do_not_use_auth_cache_test (void)
}
static void
+async_no_auth_cache_authenticate (SoupSession *session, SoupMessage *msg,
+ SoupAuth *auth, gboolean retrying, SoupAuth **auth_out)
+{
+ debug_printf (1, " async_no_auth_cache_authenticate\n");
+
+ soup_session_pause_message (session, msg);
+ *auth_out = g_object_ref (auth);
+ g_main_loop_quit (loop);
+}
+
+static void
+async_no_auth_cache_finished (SoupSession *session, SoupMessage *msg, gpointer user_data)
+{
+ debug_printf (1, " async_no_auth_cache_finished\n");
+
+ g_main_loop_quit (loop);
+}
+
+static void
+do_async_message_do_not_use_auth_cache_test (void)
+{
+ SoupSession *session;
+ SoupMessage *msg;
+ char *uri;
+ SoupAuth *auth = NULL;
+ SoupMessageFlags flags;
+
+ SOUP_TEST_SKIP_IF_NO_APACHE;
+
+ loop = g_main_loop_new (NULL, TRUE);
+ session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL);
+ uri = g_strconcat (base_uri, "Basic/realm1/", NULL);
+
+ msg = soup_message_new ("GET", uri);
+ g_free (uri);
+ g_signal_connect (session, "authenticate",
+ G_CALLBACK (async_no_auth_cache_authenticate), &auth);
+ flags = soup_message_get_flags (msg);
+ soup_message_set_flags (msg, flags | SOUP_MESSAGE_DO_NOT_USE_AUTH_CACHE);
+ g_object_ref (msg);
+ soup_session_queue_message (session, msg, async_no_auth_cache_finished, NULL);
+ g_main_loop_run (loop);
+
+ soup_test_assert_message_status (msg, SOUP_STATUS_UNAUTHORIZED);
+
+ soup_test_assert (auth, "msg didn't get authenticate signal");
+ soup_auth_authenticate (auth, "user1", "realm1");
+ g_object_unref (auth);
+
+ soup_session_unpause_message (session, msg);
+ g_main_loop_run (loop);
+
+ soup_test_assert_message_status (msg, SOUP_STATUS_OK);
+
+ soup_test_session_abort_unref (session);
+ g_object_unref (msg);
+ g_main_loop_unref (loop);
+}
+
+static void
has_authorization_header_authenticate (SoupSession *session, SoupMessage *msg,
SoupAuth *auth, gboolean retrying, gpointer data)
{
@@ -1432,6 +1492,7 @@ main (int argc, char **argv)
g_test_add_func ("/auth/disappearing-auth", do_disappearing_auth_test);
g_test_add_func ("/auth/clear-credentials", do_clear_credentials_test);
g_test_add_func ("/auth/message-do-not-use-auth-cache", do_message_do_not_use_auth_cache_test);
+ 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);
ret = g_test_run ();