From: Jussi Laako Date: Fri, 1 Mar 2013 16:13:58 +0000 (+0200) Subject: Fix tests for more strict security enforcement of gsignond X-Git-Tag: upstream/2.4.0^2~117 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9885de7d38677fa02d6477d31c60f802ff4063a8;p=platform%2Fupstream%2Flibgsignon-glib.git Fix tests for more strict security enforcement of gsignond --- diff --git a/libsignon-glib/signon-identity-info.c b/libsignon-glib/signon-identity-info.c index bce8979..f41a9b6 100644 --- a/libsignon-glib/signon-identity-info.c +++ b/libsignon-glib/signon-identity-info.c @@ -71,6 +71,14 @@ static void identity_methods_copy (gpointer key, gpointer value, gpointer user_d (const gchar* const *)value); } +/** + * signon_identity_info_set_methods: + * @info: the #SignonIdentityInfo. + * @methods: (transfer none) (element-type utf8 GStrv): methods. + * + * Set allowed methods. + * Mechanisms are method-specific functions. + */ void signon_identity_info_set_methods (SignonIdentityInfo *info, const GHashTable *methods) { @@ -152,7 +160,7 @@ signon_identity_info_new_from_variant (GVariant *variant) if (g_variant_lookup (variant, SIGNOND_IDENTITY_INFO_OWNER, - "(ss)", + "@(ss)", &owner)) { info->owner = signon_security_context_deconstruct_variant (owner); @@ -527,9 +535,8 @@ void signon_identity_info_set_caption (SignonIdentityInfo *info, const gchar *ca * @method: an authentication method. * @mechanisms: a %NULL-termianted list of mechanisms. * - * Adds a method to the list of allowed methods. If this method is not called - * even once, then all methods are allowed. - * Mechanisms are method-specific variants of authentication. + * Adds a method to the list of allowed methods. + * Mechanisms are method-specific functions. */ void signon_identity_info_set_method (SignonIdentityInfo *info, const gchar *method, const gchar* const *mechanisms) diff --git a/libsignon-glib/signon-identity-info.h b/libsignon-glib/signon-identity-info.h index 2dcd744..f585fac 100644 --- a/libsignon-glib/signon-identity-info.h +++ b/libsignon-glib/signon-identity-info.h @@ -86,6 +86,8 @@ void signon_identity_info_set_secret (SignonIdentityInfo *info, gboolean store_secret); void signon_identity_info_set_caption (SignonIdentityInfo *info, const gchar *caption); +void signon_identity_info_set_methods (SignonIdentityInfo *info, + const GHashTable *methods); void signon_identity_info_set_method (SignonIdentityInfo *info, const gchar *method, const gchar* const *mechanisms); diff --git a/libsignon-glib/signon-internals.h b/libsignon-glib/signon-internals.h index 34358c1..3201870 100644 --- a/libsignon-glib/signon-internals.h +++ b/libsignon-glib/signon-internals.h @@ -174,10 +174,6 @@ G_GNUC_INTERNAL GVariant * signon_identity_info_to_variant (const SignonIdentityInfo *self); -G_GNUC_INTERNAL -void signon_identity_info_set_methods (SignonIdentityInfo *self, - const GHashTable *methods); - G_END_DECLS #endif diff --git a/tests/check_signon.c b/tests/check_signon.c index 623393c..2de8e14 100644 --- a/tests/check_signon.c +++ b/tests/check_signon.c @@ -44,6 +44,8 @@ #include #include +static const gchar *ssotest_mechanisms[] = + { "mech1", "mech2", "mech3", "BLOB", NULL }; static GMainLoop *main_loop = NULL; static SignonIdentity *identity = NULL; static SignonAuthService *auth_service = NULL; @@ -227,9 +229,9 @@ test_quit_main_loop_cb (gpointer data) static void test_auth_session_query_mechanisms_cb (SignonAuthSession *self, - gchar **mechanisms, - const GError *error, - gpointer user_data) + gchar **mechanisms, + const GError *error, + gpointer user_data) { if (error) { @@ -272,11 +274,12 @@ START_TEST(test_auth_session_query_mechanisms) g_clear_error(&err); - gchar* patterns[4]; + gchar* patterns[5]; patterns[0] = g_strdup("mech1"); patterns[1] = g_strdup("mech2"); patterns[2] = g_strdup("mech3"); - patterns[3] = NULL; + patterns[3] = g_strdup("BLOB"); + patterns[4] = NULL; signon_auth_session_query_available_mechanisms(auth_session, (const gchar**)patterns, @@ -677,6 +680,7 @@ START_TEST(test_auth_session_process_after_store) "Failed to initialize the Identity."); info = signon_identity_info_new (); + signon_identity_info_set_method (info, "ssotest", ssotest_mechanisms); signon_identity_info_set_owner_from_values (info, "", ""); signon_identity_info_access_control_list_append (info, signon_security_context_new_from_values ("*", "*")); @@ -746,12 +750,13 @@ new_identity() identity = signon_identity_new (NULL); fail_unless (SIGNON_IS_IDENTITY (identity)); methods = g_hash_table_new (g_str_hash, g_str_equal); + g_hash_table_insert (methods, "ssotest", ssotest_mechanisms); signon_identity_store_credentials_with_args (identity, "James Bond", "007", - 1, + TRUE, methods, - "caption", + "MI-6", NULL, NULL, NULL, @@ -1104,8 +1109,17 @@ static void identity_info_cb(SignonIdentity *self, const SignonIdentityInfo *inf static SignonIdentityInfo *create_standard_info() { + GHashTable *methods; + g_debug("%s", G_STRFUNC); + SignonIdentityInfo *info = signon_identity_info_new (); + + methods = g_hash_table_new (g_str_hash, g_str_equal); + g_hash_table_insert (methods, "ssotest", ssotest_mechanisms); + signon_identity_info_set_methods (info, methods); + g_hash_table_destroy (methods); + signon_identity_info_set_owner_from_values (info, "", ""); signon_identity_info_access_control_list_append (info, signon_security_context_new_from_values ("*", "*"));