"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/test-authenticator.c" between
flatpak-1.15.1.tar.xz and flatpak-1.15.2.tar.xz

About: Flatpak is a Linux application sandboxing and distribution framework. Pre-release.

test-authenticator.c  (flatpak-1.15.1.tar.xz):test-authenticator.c  (flatpak-1.15.2.tar.xz)
skipping to change at line 115 skipping to change at line 115
g_assert_true (data->request != NULL); g_assert_true (data->request != NULL);
required_token = get_required_token (); required_token = get_required_token ();
g_variant_builder_init (&tokens, G_VARIANT_TYPE ("a{sas}")); g_variant_builder_init (&tokens, G_VARIANT_TYPE ("a{sas}"));
g_variant_builder_add (&tokens, "{s^as}", required_token, data->arg_refs); g_variant_builder_add (&tokens, "{s^as}", required_token, data->arg_refs);
g_variant_builder_init (&results, G_VARIANT_TYPE ("a{sv}")); g_variant_builder_init (&results, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&results, "{sv}", "tokens", g_variant_builder_end (&tok ens)); g_variant_builder_add (&results, "{sv}", "tokens", g_variant_builder_end (&tok ens));
g_debug ("emitting response"); g_info ("emitting response");
flatpak_authenticator_request_emit_response (data->request, flatpak_authenticator_request_emit_response (data->request,
FLATPAK_AUTH_RESPONSE_OK, FLATPAK_AUTH_RESPONSE_OK,
g_variant_builder_end (&results)) ; g_variant_builder_end (&results)) ;
} }
static gboolean static gboolean
http_incoming (GSocketService *service, http_incoming (GSocketService *service,
GSocketConnection *connection, GSocketConnection *connection,
GObject *source_object, GObject *source_object,
gpointer user_data) gpointer user_data)
{ {
TokenRequestData *data = user_data; TokenRequestData *data = user_data;
g_autoptr(GVariant) options = g_variant_ref_sink (g_variant_new_array (G_VARIA NT_TYPE ("{sv}"), NULL, 0)); g_autoptr(GVariant) options = g_variant_ref_sink (g_variant_new_array (G_VARIA NT_TYPE ("{sv}"), NULL, 0));
g_assert_true (data->request != NULL); g_assert_true (data->request != NULL);
/* For the test, just assume any connection is a valid use of the web flow */ /* For the test, just assume any connection is a valid use of the web flow */
g_debug ("handling incoming http request"); g_info ("handling incoming http request");
g_debug ("emitting webflow done"); g_info ("emitting webflow done");
flatpak_authenticator_request_emit_webflow_done (data->request, options); flatpak_authenticator_request_emit_webflow_done (data->request, options);
finish_request_ref_tokens (data); finish_request_ref_tokens (data);
token_request_data_free (data); token_request_data_free (data);
return TRUE; return TRUE;
} }
static gboolean static gboolean
handle_request_close (FlatpakAuthenticatorRequest *object, handle_request_close (FlatpakAuthenticatorRequest *object,
GDBusMethodInvocation *invocation, GDBusMethodInvocation *invocation,
gpointer user_data) gpointer user_data)
{ {
TokenRequestData *data = user_data; TokenRequestData *data = user_data;
g_debug ("handle_request_close"); g_info ("handle_request_close");
flatpak_authenticator_request_complete_close (object, invocation); flatpak_authenticator_request_complete_close (object, invocation);
if (requires_webflow ()) if (requires_webflow ())
{ {
GVariantBuilder results; GVariantBuilder results;
g_debug ("Webflow was cancelled by client"); g_info ("Webflow was cancelled by client");
g_variant_builder_init (&results, G_VARIANT_TYPE ("a{sv}")); g_variant_builder_init (&results, G_VARIANT_TYPE ("a{sv}"));
flatpak_authenticator_request_emit_response (data->request, flatpak_authenticator_request_emit_response (data->request,
FLATPAK_AUTH_RESPONSE_CANCELL ED, FLATPAK_AUTH_RESPONSE_CANCELL ED,
g_variant_builder_end (&resul ts)); g_variant_builder_end (&resul ts));
} }
else else
{ {
g_debug ("Ignored webflow cancel by client"); g_info ("Ignored webflow cancel by client");
finish_request_ref_tokens (data); /* Silently succeed anyway */ finish_request_ref_tokens (data); /* Silently succeed anyway */
} }
token_request_data_free (data); token_request_data_free (data);
return G_DBUS_METHOD_INVOCATION_HANDLED; return G_DBUS_METHOD_INVOCATION_HANDLED;
} }
static gboolean static gboolean
handle_request_ref_tokens (FlatpakAuthenticator *authenticator, handle_request_ref_tokens (FlatpakAuthenticator *authenticator,
skipping to change at line 199 skipping to change at line 199
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_autoptr(GSocketService) server = NULL; g_autoptr(GSocketService) server = NULL;
g_autoptr(AutoFlatpakAuthenticatorRequest) request = NULL; g_autoptr(AutoFlatpakAuthenticatorRequest) request = NULL;
g_autofree char *uri = NULL; g_autofree char *uri = NULL;
g_autofree char *request_path = NULL; g_autofree char *request_path = NULL;
guint16 port; guint16 port;
g_autoptr(GPtrArray) refs = NULL; g_autoptr(GPtrArray) refs = NULL;
gsize n_refs, i; gsize n_refs, i;
g_autofree char *options_s = NULL; g_autofree char *options_s = NULL;
g_debug ("handling RequestRefTokens"); g_info ("handling RequestRefTokens");
options_s = g_variant_print (arg_options, FALSE); options_s = g_variant_print (arg_options, FALSE);
write_request (g_strdup_printf ("remote: %s\n" write_request (g_strdup_printf ("remote: %s\n"
"uri: %s\n" "uri: %s\n"
"options: %s", "options: %s",
arg_remote, arg_remote,
arg_remote_uri, arg_remote_uri,
options_s)); options_s));
request_path = flatpak_auth_create_request_path (g_dbus_method_invocation_get_ sender (invocation), request_path = flatpak_auth_create_request_path (g_dbus_method_invocation_get_ sender (invocation),
skipping to change at line 263 skipping to change at line 263
g_signal_connect (server, "incoming", (GCallback)http_incoming, data); g_signal_connect (server, "incoming", (GCallback)http_incoming, data);
g_signal_connect (request, "handle-close", G_CALLBACK (handle_request_close), data); g_signal_connect (request, "handle-close", G_CALLBACK (handle_request_close), data);
flatpak_authenticator_complete_request_ref_tokens (authenticator, invocation, request_path); flatpak_authenticator_complete_request_ref_tokens (authenticator, invocation, request_path);
if (request_webflow ()) if (request_webflow ())
{ {
g_autoptr(GVariant) options = g_variant_ref_sink (g_variant_new_array (G_V ARIANT_TYPE ("{sv}"), NULL, 0)); g_autoptr(GVariant) options = g_variant_ref_sink (g_variant_new_array (G_V ARIANT_TYPE ("{sv}"), NULL, 0));
uri = g_strdup_printf ("http://localhost:%d", (int)port); uri = g_strdup_printf ("http://localhost:%d", (int)port);
g_debug ("Requesting webflow %s", uri); g_info ("Requesting webflow %s", uri);
flatpak_authenticator_request_emit_webflow (request, uri, options); flatpak_authenticator_request_emit_webflow (request, uri, options);
} }
else else
{ {
finish_request_ref_tokens (data); finish_request_ref_tokens (data);
token_request_data_free (data); token_request_data_free (data);
} }
return G_DBUS_METHOD_INVOCATION_HANDLED; return G_DBUS_METHOD_INVOCATION_HANDLED;
} }
static void static void
on_bus_acquired (GDBusConnection *connection, on_bus_acquired (GDBusConnection *connection,
const gchar *name, const gchar *name,
gpointer user_data) gpointer user_data)
{ {
GError *error = NULL; GError *error = NULL;
g_debug ("Bus acquired, creating skeleton"); g_info ("Bus acquired, creating skeleton");
g_dbus_connection_set_exit_on_close (connection, FALSE); g_dbus_connection_set_exit_on_close (connection, FALSE);
global_authenticator = flatpak_authenticator_skeleton_new (); global_authenticator = flatpak_authenticator_skeleton_new ();
flatpak_authenticator_set_version (global_authenticator, 0); flatpak_authenticator_set_version (global_authenticator, 0);
g_signal_connect (global_authenticator, "handle-request-ref-tokens", G_CALLBAC K (handle_request_ref_tokens), NULL); g_signal_connect (global_authenticator, "handle-request-ref-tokens", G_CALLBAC K (handle_request_ref_tokens), NULL);
if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (global_authe nticator), if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (global_authe nticator),
connection, connection,
skipping to change at line 306 skipping to change at line 306
g_warning ("error: %s", error->message); g_warning ("error: %s", error->message);
g_error_free (error); g_error_free (error);
} }
} }
static void static void
on_name_acquired (GDBusConnection *connection, on_name_acquired (GDBusConnection *connection,
const gchar *name, const gchar *name,
gpointer user_data) gpointer user_data)
{ {
g_debug ("Name acquired"); g_info ("Name acquired");
} }
static void static void
on_name_lost (GDBusConnection *connection, on_name_lost (GDBusConnection *connection,
const gchar *name, const gchar *name,
gpointer user_data) gpointer user_data)
{ {
g_debug ("Name lost"); g_info ("Name lost");
} }
static void static void
message_handler (const gchar *log_domain, message_handler (const gchar *log_domain,
GLogLevelFlags log_level, GLogLevelFlags log_level,
const gchar *message, const gchar *message,
gpointer user_data) gpointer user_data)
{ {
/* Make this look like normal console output */ /* Make this look like normal console output */
if (log_level & G_LOG_LEVEL_DEBUG) if (log_level & (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO))
g_printerr ("F: %s\n", message); g_printerr ("F: %s\n", message);
else else
g_printerr ("%s: %s\n", g_get_prgname (), message); g_printerr ("%s: %s\n", g_get_prgname (), message);
} }
int int
main (int argc, main (int argc,
char **argv) char **argv)
{ {
gboolean replace; gboolean replace;
skipping to change at line 374 skipping to change at line 374
g_printerr ("%s: %s", g_get_application_name (), error->message); g_printerr ("%s: %s", g_get_application_name (), error->message);
g_printerr ("\n"); g_printerr ("\n");
g_printerr ("Try \"%s --help\" for more information.", g_printerr ("Try \"%s --help\" for more information.",
g_get_prgname ()); g_get_prgname ());
g_printerr ("\n"); g_printerr ("\n");
g_option_context_free (context); g_option_context_free (context);
return 1; return 1;
} }
if (opt_verbose) if (opt_verbose)
g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, message_handler, NULL); g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, message_handler, NULL);
g_debug ("Started test-authenticator"); g_info ("Started test-authenticator");
session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
if (session_bus == NULL) if (session_bus == NULL)
{ {
g_printerr ("Can't find bus: %s\n", error->message); g_printerr ("Can't find bus: %s\n", error->message);
return 1; return 1;
} }
flags = G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT; flags = G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT;
if (replace) if (replace)
 End of changes. 14 change blocks. 
14 lines changed or deleted 14 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)