diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2015-07-10 12:20:45 +0100 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2015-07-10 12:22:19 +0100 |
commit | c5ced0ac8d6736b3214ebe27f3207e06e46722f5 (patch) | |
tree | f2afd1ae85a7eb31438ae532a7c75490f507b667 | |
parent | 00ec26d6c1e0c29ea09c89df3d3667e329bc6008 (diff) | |
download | libgdata-c5ced0ac8d6736b3214ebe27f3207e06e46722f5.tar.gz |
tests: Remove outdated async authentication tests from YouTube
These were using the unsupported ClientLogin API. The OAuth2 authoriser
has its own async authorisation tests, so porting the existing YouTube
tests would gain us nothing.
-rw-r--r-- | gdata/tests/youtube.c | 189 |
1 files changed, 0 insertions, 189 deletions
diff --git a/gdata/tests/youtube.c b/gdata/tests/youtube.c index e1731294..ba8d0795 100644 --- a/gdata/tests/youtube.c +++ b/gdata/tests/youtube.c @@ -103,189 +103,6 @@ skip_test: uhm_server_end_trace (mock_server); } -/* HTTP message responses and the expected associated GData error domain/code. */ -static const GDataTestRequestErrorData authentication_errors[] = { - /* Generic network errors. */ - { SOUP_STATUS_BAD_REQUEST, "Bad Request", "Invalid parameter ‘foobar’.", - gdata_service_error_quark, GDATA_SERVICE_ERROR_PROTOCOL_ERROR }, - { SOUP_STATUS_NOT_FOUND, "Not Found", "Login page wasn't found for no good reason at all.", - gdata_service_error_quark, GDATA_SERVICE_ERROR_NOT_FOUND }, - { SOUP_STATUS_PRECONDITION_FAILED, "Precondition Failed", "Not allowed to log in at this time, possibly.", - gdata_service_error_quark, GDATA_SERVICE_ERROR_CONFLICT }, - { SOUP_STATUS_INTERNAL_SERVER_ERROR, "Internal Server Error", "Whoops.", - gdata_service_error_quark, GDATA_SERVICE_ERROR_PROTOCOL_ERROR }, -#if 0 -FIXME: These need porting to JSON. - /* Specific authentication errors. */ - { SOUP_STATUS_FORBIDDEN, "Access Forbidden", "Error=BadAuthentication\n", - gdata_client_login_authorizer_error_quark, GDATA_CLIENT_LOGIN_AUTHORIZER_ERROR_BAD_AUTHENTICATION }, - { SOUP_STATUS_FORBIDDEN, "Access Forbidden", "Error=BadAuthentication\nInfo=InvalidSecondFactor\n", - gdata_client_login_authorizer_error_quark, GDATA_CLIENT_LOGIN_AUTHORIZER_ERROR_INVALID_SECOND_FACTOR }, - { SOUP_STATUS_FORBIDDEN, "Access Forbidden", "Error=NotVerified\nUrl=http://example.com/\n", - gdata_client_login_authorizer_error_quark, GDATA_CLIENT_LOGIN_AUTHORIZER_ERROR_NOT_VERIFIED }, - { SOUP_STATUS_FORBIDDEN, "Access Forbidden", "Error=TermsNotAgreed\nUrl=http://example.com/\n", - gdata_client_login_authorizer_error_quark, GDATA_CLIENT_LOGIN_AUTHORIZER_ERROR_TERMS_NOT_AGREED }, - { SOUP_STATUS_FORBIDDEN, "Access Forbidden", "Error=Unknown\nUrl=http://example.com/\n", - gdata_service_error_quark, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED }, - { SOUP_STATUS_FORBIDDEN, "Access Forbidden", "Error=AccountDeleted\nUrl=http://example.com/\n", - gdata_client_login_authorizer_error_quark, GDATA_CLIENT_LOGIN_AUTHORIZER_ERROR_ACCOUNT_DELETED }, - { SOUP_STATUS_FORBIDDEN, "Access Forbidden", "Error=AccountDisabled\nUrl=http://example.com/\n", - gdata_client_login_authorizer_error_quark, GDATA_CLIENT_LOGIN_AUTHORIZER_ERROR_ACCOUNT_DISABLED }, - { SOUP_STATUS_FORBIDDEN, "Access Forbidden", "Error=AccountMigrated\nUrl=http://example.com/\n", - gdata_client_login_authorizer_error_quark, GDATA_CLIENT_LOGIN_AUTHORIZER_ERROR_ACCOUNT_MIGRATED }, - { SOUP_STATUS_FORBIDDEN, "Access Forbidden", "Error=ServiceDisabled\nUrl=http://example.com/\n", - gdata_client_login_authorizer_error_quark, GDATA_CLIENT_LOGIN_AUTHORIZER_ERROR_SERVICE_DISABLED }, - { SOUP_STATUS_FORBIDDEN, "Access Forbidden", "Error=ServiceUnavailable\nUrl=http://example.com/\n", - gdata_service_error_quark, GDATA_SERVICE_ERROR_UNAVAILABLE }, - /* Malformed authentication errors to test parser error handling. */ - { SOUP_STATUS_INTERNAL_SERVER_ERROR, "Access Forbidden", "Error=BadAuthentication", /* missing Error delimiter */ - gdata_service_error_quark, GDATA_SERVICE_ERROR_PROTOCOL_ERROR }, - { SOUP_STATUS_INTERNAL_SERVER_ERROR, "Access Forbidden", "Error=AccountDeleted\n", /* missing Url */ - gdata_service_error_quark, GDATA_SERVICE_ERROR_PROTOCOL_ERROR }, - { SOUP_STATUS_INTERNAL_SERVER_ERROR, "Access Forbidden", "Error=AccountDeleted\nUrl=http://example.com/", /* missing Url delimiter */ - gdata_service_error_quark, GDATA_SERVICE_ERROR_PROTOCOL_ERROR }, - { SOUP_STATUS_INTERNAL_SERVER_ERROR, "Access Forbidden", "", /* missing Error */ - gdata_service_error_quark, GDATA_SERVICE_ERROR_PROTOCOL_ERROR }, - { SOUP_STATUS_INTERNAL_SERVER_ERROR, "Access Forbidden", "Error=", /* missing Error */ - gdata_service_error_quark, GDATA_SERVICE_ERROR_PROTOCOL_ERROR }, - { SOUP_STATUS_INTERNAL_SERVER_ERROR, "Access Forbidden", "Error=Foobar\nUrl=http://example.com/\n", /* unknown Error */ - gdata_service_error_quark, GDATA_SERVICE_ERROR_PROTOCOL_ERROR }, -#endif -}; - -static void -test_authentication_error (void) -{ - gboolean retval; - GDataClientLoginAuthorizer *authorizer; - GError *error = NULL; - gulong handler_id; - guint i; - - if (uhm_server_get_enable_logging (mock_server) == TRUE) { - g_test_message ("Ignoring test due to logging being enabled."); - return; - } else if (uhm_server_get_enable_online (mock_server) == TRUE) { - g_test_message ("Ignoring test due to running online and test not being reproducible."); - return; - } - - for (i = 0; i < G_N_ELEMENTS (authentication_errors); i++) { - const GDataTestRequestErrorData *data = &authentication_errors[i]; - - handler_id = g_signal_connect (mock_server, "handle-message", (GCallback) gdata_test_mock_server_handle_message_error, (gpointer) data); - gdata_test_mock_server_run (mock_server); - - /* Create an authorizer */ - authorizer = gdata_client_login_authorizer_new (CLIENT_ID, GDATA_TYPE_YOUTUBE_SERVICE); - - g_assert_cmpstr (gdata_client_login_authorizer_get_client_id (authorizer), ==, CLIENT_ID); - - /* Log in */ - retval = gdata_client_login_authorizer_authenticate (authorizer, USERNAME, PASSWORD, NULL, &error); - g_assert_error (error, data->error_domain_func (), data->error_code); - g_assert (retval == FALSE); - g_clear_error (&error); - - /* Check nothing's changed in the authoriser. */ - g_assert_cmpstr (gdata_client_login_authorizer_get_username (authorizer), ==, NULL); - g_assert_cmpstr (gdata_client_login_authorizer_get_password (authorizer), ==, NULL); - - g_assert (gdata_authorizer_is_authorized_for_domain (GDATA_AUTHORIZER (authorizer), - gdata_youtube_service_get_primary_authorization_domain ()) == FALSE); - - g_object_unref (authorizer); - - uhm_server_stop (mock_server); - g_signal_handler_disconnect (mock_server, handler_id); - } -} - -static void -test_authentication_timeout (void) -{ - gboolean retval; - GDataClientLoginAuthorizer *authorizer; - GError *error = NULL; - gulong handler_id; - - if (uhm_server_get_enable_logging (mock_server) == TRUE) { - g_test_message ("Ignoring test due to logging being enabled."); - return; - } else if (uhm_server_get_enable_online (mock_server) == TRUE) { - g_test_message ("Ignoring test due to running online and test not being reproducible."); - return; - } - - handler_id = g_signal_connect (mock_server, "handle-message", (GCallback) gdata_test_mock_server_handle_message_timeout, NULL); - uhm_server_run (mock_server); - gdata_test_set_https_port (mock_server); - - /* Create an authorizer and set its timeout as low as possible (1 second). */ - authorizer = gdata_client_login_authorizer_new (CLIENT_ID, GDATA_TYPE_YOUTUBE_SERVICE); - gdata_client_login_authorizer_set_timeout (authorizer, 1); - - g_assert_cmpstr (gdata_client_login_authorizer_get_client_id (authorizer), ==, CLIENT_ID); - - /* Log in */ - retval = gdata_client_login_authorizer_authenticate (authorizer, USERNAME, PASSWORD, NULL, &error); - g_assert_error (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_NETWORK_ERROR); - g_assert (retval == FALSE); - g_clear_error (&error); - - /* Check nothing's changed in the authoriser. */ - g_assert_cmpstr (gdata_client_login_authorizer_get_username (authorizer), ==, NULL); - g_assert_cmpstr (gdata_client_login_authorizer_get_password (authorizer), ==, NULL); - - g_assert (gdata_authorizer_is_authorized_for_domain (GDATA_AUTHORIZER (authorizer), - gdata_youtube_service_get_primary_authorization_domain ()) == FALSE); - - g_object_unref (authorizer); - - uhm_server_stop (mock_server); - g_signal_handler_disconnect (mock_server, handler_id); -} - -GDATA_ASYNC_TEST_FUNCTIONS (authentication, void, -G_STMT_START { - GDataClientLoginAuthorizer *authorizer; - - /* Create an authorizer */ - authorizer = gdata_client_login_authorizer_new (CLIENT_ID, GDATA_TYPE_YOUTUBE_SERVICE); - - g_assert_cmpstr (gdata_client_login_authorizer_get_client_id (authorizer), ==, CLIENT_ID); - - gdata_client_login_authorizer_authenticate_async (authorizer, USERNAME, PASSWORD, cancellable, async_ready_callback, async_data); - - g_object_unref (authorizer); -} G_STMT_END, -G_STMT_START { - gboolean retval; - GDataClientLoginAuthorizer *authorizer = GDATA_CLIENT_LOGIN_AUTHORIZER (obj); - - retval = gdata_client_login_authorizer_authenticate_finish (authorizer, async_result, &error); - - if (error == NULL) { - g_assert (retval == TRUE); - - /* Check all is as it should be */ - g_assert_cmpstr (gdata_client_login_authorizer_get_username (authorizer), ==, USERNAME); - g_assert_cmpstr (gdata_client_login_authorizer_get_password (authorizer), ==, PASSWORD); - - g_assert (gdata_authorizer_is_authorized_for_domain (GDATA_AUTHORIZER (authorizer), - gdata_youtube_service_get_primary_authorization_domain ()) == TRUE); - } else { - g_assert (retval == FALSE); - - /* Check nothing's changed */ - g_assert_cmpstr (gdata_client_login_authorizer_get_username (authorizer), ==, NULL); - g_assert_cmpstr (gdata_client_login_authorizer_get_password (authorizer), ==, NULL); - - g_assert (gdata_authorizer_is_authorized_for_domain (GDATA_AUTHORIZER (authorizer), - gdata_youtube_service_get_primary_authorization_domain ()) == FALSE); - } -} G_STMT_END); - static void test_service_properties (void) { @@ -2596,12 +2413,6 @@ main (int argc, char *argv[]) authorizer)); g_test_add_func ("/youtube/authentication", test_authentication); - g_test_add_func ("/youtube/authentication/error", test_authentication_error); - g_test_add_func ("/youtube/authentication/timeout", test_authentication_timeout); - g_test_add ("/youtube/authentication/async", GDataAsyncTestData, NULL, gdata_set_up_async_test_data, test_authentication_async, - gdata_tear_down_async_test_data); - g_test_add ("/youtube/authentication/async/cancellation", GDataAsyncTestData, NULL, gdata_set_up_async_test_data, - test_authentication_async_cancellation, gdata_tear_down_async_test_data); g_test_add_data_func ("/youtube/query/standard_feeds", service, test_query_standard_feeds); g_test_add_data_func ("/youtube/query/standard_feed", service, test_query_standard_feed); |