summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabiano FidĂȘncio <fidencio@redhat.com>2013-11-18 09:38:45 +0100
committerPhilip Withnall <philip@tecnocode.co.uk>2013-12-18 23:41:32 +0000
commitb551827afd557f826c89ecce2695fa25342db838 (patch)
treec20333a83cf3adbdb940252f7cb5bbc87d157383
parenta8a023e7f0a502566fe7d39c308f55cbe1662f37 (diff)
downloadlibgdata-b551827afd557f826c89ecce2695fa25342db838.tar.gz
tests: Replace g_test_trap_fork() with g_test_trap_subprocess()
For GLib versions newer than 2.38.0. This continues to work for older versions, so the GLib dependency is not bumped. https://bugzilla.gnome.org/show_bug.cgi?id=712565
-rw-r--r--gdata/tests/client-login-authorizer.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/gdata/tests/client-login-authorizer.c b/gdata/tests/client-login-authorizer.c
index e87d9f43..918544e8 100644
--- a/gdata/tests/client-login-authorizer.c
+++ b/gdata/tests/client-login-authorizer.c
@@ -677,29 +677,37 @@ test_client_login_authorizer_process_request_authenticated (ClientLoginAuthorize
g_object_unref (message);
}
-/* Test that processing a HTTP request (as opposed to the more normal HTTPS request) with an authenticated authorizer will abort rather than
- * transmitting the user's private auth token over an insecure HTTP connection. */
static void
-test_client_login_authorizer_process_request_insecure (ClientLoginAuthorizerData *data, gconstpointer user_data)
+test_client_login_authorizer_process_request_insecure_subprocess (ClientLoginAuthorizerData *data, gconstpointer user_data)
{
SoupMessage *message;
/* Create a new message which uses HTTP instead of HTTPS */
message = soup_message_new (SOUP_METHOD_GET, "http://example.com/");
+ gdata_authorizer_process_request (GDATA_AUTHORIZER (data->authorizer), gdata_youtube_service_get_primary_authorization_domain (),
+ message);
+ g_object_unref (message);
+}
+/* Test that processing a HTTP request (as opposed to the more normal HTTPS request) with an authenticated authorizer will abort rather than
+ * transmitting the user's private auth token over an insecure HTTP connection. */
+static void
+test_client_login_authorizer_process_request_insecure (ClientLoginAuthorizerData *data, gconstpointer user_data)
+{
/* Process the message */
+#if GLIB_CHECK_VERSION(2, 38, 0)
+ g_test_trap_subprocess ("/client-login-authorizer/process-request/insecure/subprocess", 0, 0);
+#else
if (g_test_trap_fork (0, 0) == TRUE) {
- gdata_authorizer_process_request (GDATA_AUTHORIZER (data->authorizer), gdata_youtube_service_get_primary_authorization_domain (),
- message);
+ test_client_login_authorizer_process_request_insecure_subprocess (data, user_data);
exit (0);
}
+#endif
/* Assert that it aborted */
g_test_trap_assert_failed ();
g_test_trap_assert_stderr_unmatched ("Not authorizing a non-HTTPS message with the user's ClientLogin "
"auth token as the connection isn't secure.");
-
- g_object_unref (message);
}
static void
@@ -798,6 +806,11 @@ main (int argc, char *argv[])
g_test_add ("/client-login-authorizer/process-request/insecure", ClientLoginAuthorizerData, NULL,
set_up_client_login_authorizer_data_authenticated, test_client_login_authorizer_process_request_insecure,
tear_down_client_login_authorizer_data);
+#if GLIB_CHECK_VERSION(2, 38, 0)
+ g_test_add ("/client-login-authorizer/process-request/insecure/subprocess", ClientLoginAuthorizerData, NULL,
+ set_up_client_login_authorizer_data_authenticated, test_client_login_authorizer_process_request_insecure_subprocess,
+ tear_down_client_login_authorizer_data);
+#endif
return g_test_run ();
}