[libsoup/wip/ci-pkcs11: 4/4] WIP
- From: Patrick Griffis <pgriffis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/wip/ci-pkcs11: 4/4] WIP
- Date: Sun, 30 May 2021 16:43:37 +0000 (UTC)
commit 3134ef143e1aefe163feafd87ff2d5dc8da17fd9
Author: Patrick Griffis <pgriffis igalia com>
Date: Sat May 1 18:58:21 2021 -0500
WIP
libsoup/soup-connection.c | 8 ++++++++
libsoup/soup-connection.h | 2 ++
tests/ssl-test.c | 40 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+)
---
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
index f8dccec2..76cd9585 100644
--- a/libsoup/soup-connection.c
+++ b/libsoup/soup-connection.c
@@ -1223,3 +1223,11 @@ soup_connection_get_id (SoupConnection *conn)
return priv->id;
}
+
+GIOStream *
+soup_connection_get_connection (SoupConnection *conn)
+{
+ SoupConnectionPrivate *priv = soup_connection_get_instance_private (conn);
+
+ return priv->connection;
+}
diff --git a/libsoup/soup-connection.h b/libsoup/soup-connection.h
index 4f58cba2..efb7b2c1 100644
--- a/libsoup/soup-connection.h
+++ b/libsoup/soup-connection.h
@@ -88,6 +88,8 @@ void soup_connection_complete_tls_certificate_password_request (
guint64 soup_connection_get_id (SoupConnection *conn);
+GIOStream *soup_connection_get_connection (SoupConnection *conn);
+
G_END_DECLS
#endif /* __SOUP_CONNECTION_H__ */
diff --git a/tests/ssl-test.c b/tests/ssl-test.c
index 351e5608..b967606a 100644
--- a/tests/ssl-test.c
+++ b/tests/ssl-test.c
@@ -1,6 +1,8 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
#include "test-utils.h"
+#include "soup-connection.h"
+#include "soup-message-private.h"
#include "soup-server-message-private.h"
#if HAVE_GNUTLS
@@ -298,10 +300,42 @@ request_certificate_password_async_cb (SoupMessage *msg,
return TRUE;
}
+static void
+run_loop_until_connection_destroyed (SoupConnection *conn)
+{
+ GIOStream *stream;
+ GWeakRef stream_ref;
+ GObject *object;
+
+ /* The mock pkcs11 module only supports one session at a time so
+ * this will ensure the GTlsClientConnection is fully closed before
+ * continuing. */
+
+ stream = soup_connection_get_connection (conn);
+ g_weak_ref_init (&stream_ref, stream);
+
+ soup_connection_disconnect (conn);
+ while ((object = g_weak_ref_get (&stream_ref))) {
+ g_message ("Waiting on connection to be destroyed");
+ g_object_unref (object);
+ g_main_context_iteration (g_main_context_default (), FALSE);
+ }
+
+ g_weak_ref_clear (&stream_ref);
+}
+
+static void
+on_got_headers (SoupMessage *msg, SoupConnection **connection)
+{
+ *connection = soup_message_get_connection (msg);
+ g_assert_nonnull (*connection);
+}
+
static void
do_tls_interaction_msg_test (gconstpointer data)
{
SoupServer *server = (SoupServer *)data;
+ SoupConnection *connection = NULL;
SoupSession *session;
SoupMessage *msg;
GBytes *body;
@@ -423,7 +457,10 @@ do_tls_interaction_msg_test (gconstpointer data)
g_signal_connect (msg, "request-certificate-password",
G_CALLBACK (request_certificate_password_cb),
"ABC123");
+ g_signal_connect (msg, "got-headers", G_CALLBACK (on_got_headers),
+ &connection);
body = soup_test_session_async_send (session, msg, NULL, &error);
+ run_loop_until_connection_destroyed (connection);
g_assert_no_error (error);
g_clear_error (&error);
g_bytes_unref (body);
@@ -454,7 +491,10 @@ do_tls_interaction_msg_test (gconstpointer data)
g_signal_connect (msg, "request-certificate-password",
G_CALLBACK (request_certificate_password_async_cb),
"ABC123");
+ g_signal_connect (msg, "got-headers", G_CALLBACK (on_got_headers),
+ &connection);
body = soup_test_session_async_send (session, msg, NULL, &error);
+ run_loop_until_connection_destroyed (connection);
g_assert_no_error (error);
g_clear_error (&error);
g_bytes_unref (body);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]