~online-accounts/libsignon-glib/13.04

« back to all changes in this revision

Viewing changes to tests/check_signon.c

  • Committer: Alberto Mardegan
  • Date: 2013-04-26 14:21:52 UTC
  • mfrom: (122.1.65)
  • Revision ID: alberto.mardegan@canonical.com-20130426142152-20uyq0gqln13p4hb
[ Robert Bruce Park ]
[ Alberto Mardegan ]
* New upstream release.
  - Invoke the callback when errors occur
  - Add NOCONFIGURE logic to autogen.sh
  - Fix the check for pyoverridesdir for python3
  - Fix a memory leak

Show diffs side-by-side

added added

removed removed

Lines of Context:
527
527
END_TEST
528
528
 
529
529
static void
 
530
test_auth_session_process_failure_cb (GObject *source_object,
 
531
                                      GAsyncResult *res,
 
532
                                      gpointer user_data)
 
533
{
 
534
    SignonAuthSession *auth_session = SIGNON_AUTH_SESSION (source_object);
 
535
    GVariant *v_reply;
 
536
    GError **error = user_data;
 
537
 
 
538
    fail_unless (SIGNON_IS_AUTH_SESSION (source_object));
 
539
 
 
540
    v_reply = signon_auth_session_process_finish (auth_session, res, error);
 
541
    fail_unless (v_reply == NULL);
 
542
 
 
543
    g_main_loop_quit (main_loop);
 
544
}
 
545
 
 
546
START_TEST(test_auth_session_process_failure)
 
547
{
 
548
    SignonAuthSession *auth_session;
 
549
    GVariantBuilder builder;
 
550
    GVariant *session_data;
 
551
    GError *error = NULL;
 
552
 
 
553
    g_debug("%s", G_STRFUNC);
 
554
 
 
555
    g_type_init ();
 
556
 
 
557
    auth_session = signon_auth_session_new (0, "nonexisting-method", &error);
 
558
    fail_unless (auth_session != NULL, "Cannot create AuthSession object");
 
559
    fail_unless (error == NULL);
 
560
 
 
561
    g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
 
562
    g_variant_builder_add (&builder, "{sv}",
 
563
                           "key", g_variant_new_string ("value"));
 
564
 
 
565
    session_data = g_variant_builder_end (&builder);
 
566
 
 
567
    signon_auth_session_process_async (auth_session,
 
568
                                       session_data,
 
569
                                       "mech1",
 
570
                                       NULL,
 
571
                                       test_auth_session_process_failure_cb,
 
572
                                       &error);
 
573
 
 
574
    main_loop = g_main_loop_new (NULL, FALSE);
 
575
    g_main_loop_run (main_loop);
 
576
    fail_unless (error != NULL);
 
577
    fail_unless (error->domain == SIGNON_ERROR);
 
578
    fail_unless (error->code == SIGNON_ERROR_METHOD_NOT_KNOWN);
 
579
 
 
580
    g_object_unref (auth_session);
 
581
 
 
582
    end_test ();
 
583
}
 
584
END_TEST
 
585
 
 
586
static void
530
587
test_auth_session_process_after_store_cb (SignonAuthSession *self,
531
588
                                          GHashTable *reply,
532
589
                                          const GError *error,
1403
1460
    tcase_add_test (tc_core, test_auth_session_query_mechanisms);
1404
1461
    tcase_add_test (tc_core, test_auth_session_query_mechanisms_nonexisting);
1405
1462
    tcase_add_test (tc_core, test_auth_session_process);
 
1463
    tcase_add_test (tc_core, test_auth_session_process_failure);
1406
1464
    tcase_add_test (tc_core, test_auth_session_process_after_store);
1407
1465
    tcase_add_test (tc_core, test_store_credentials_identity);
1408
1466
    tcase_add_test (tc_core, test_verify_secret_identity);