Bug 576583 - Tests fail if "localhost" resolves to ::1
authorDan Winship <danw@src.gnome.org>
Fri, 27 Mar 2009 19:47:03 +0000 (19:47 +0000)
committerDan Winship <danw@src.gnome.org>
Fri, 27 Mar 2009 19:47:03 +0000 (19:47 +0000)
* tests/*.c: Use "127.0.0.1" in URIs rather than "localhost",
since the default SoupServer config only listen on IPv4 (qv bug
522519), and tests/httpd.conf.in only configures apache to listen
on IPv4, and we don't handle multiple IP addresses (qv bug 526321)
but the machine might be configured to return "::1" rather than
"127.0.0.1" first for "localhost". Patch from Andreas Rottmann.

svn path=/trunk/; revision=1257

15 files changed:
ChangeLog
tests/auth-test.c
tests/chunk-test.c
tests/context-test.c
tests/continue-test.c
tests/forms-test.c
tests/misc-test.c
tests/ntlm-test.c
tests/pull-api.c
tests/range-test.c
tests/redirect-test.c
tests/server-auth-test.c
tests/streaming-test.c
tests/xmlrpc-server-test.c
tests/xmlrpc-test.c

index 583c855..60c77d3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2009-03-27  Dan Winship  <danw@gnome.org>
 
+       Bug 576583 – Tests fail if "localhost" resolves to ::1
+
+       * tests/*.c: Use "127.0.0.1" in URIs rather than "localhost",
+       since the default SoupServer config only listen on IPv4 (qv bug
+       522519), and tests/httpd.conf.in only configures apache to listen
+       on IPv4, and we don't handle multiple IP addresses (qv bug 526321)
+       but the machine might be configured to return "::1" rather than
+       "127.0.0.1" first for "localhost". Patch from Andreas Rottmann.
+
+2009-03-27  Dan Winship  <danw@gnome.org>
+
        * libsoup/soup-cookie.c (soup_cookie_new): Fix docs to not claim
        that the cookie domain can be %NULL. Add some g_return_if_fail()s.
 
index 23bf513..c035f65 100644 (file)
@@ -684,7 +684,7 @@ do_select_auth_test (void)
        soup_server_add_handler (server, NULL,
                                 server_callback, NULL, NULL);
 
-       uri = soup_uri_new ("http://localhost/");
+       uri = soup_uri_new ("http://127.0.0.1/");
        soup_uri_set_port (uri, soup_server_get_port (server));
 
        basic_auth_domain = soup_auth_domain_basic_new (
@@ -765,7 +765,7 @@ main (int argc, char **argv)
        test_init (argc, argv, NULL);
        apache_init ();
 
-       base_uri = "http://localhost:47524/";
+       base_uri = "http://127.0.0.1:47524/";
 
        session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL);
        g_signal_connect (session, "authenticate",
index db526fe..e6bc1e8 100644 (file)
@@ -363,7 +363,7 @@ main (int argc, char **argv)
 
        loop = g_main_loop_new (NULL, TRUE);
 
-       base_uri = soup_uri_new ("http://localhost");
+       base_uri = soup_uri_new ("http://127.0.0.1");
        soup_uri_set_port (base_uri, port);
        do_chunk_tests (base_uri);
        soup_uri_free (base_uri);
index 6cd9ec7..fc203b3 100644 (file)
@@ -263,7 +263,7 @@ main (int argc, char **argv)
 
        server = soup_test_server_new (TRUE);
        soup_server_add_handler (server, NULL, server_callback, NULL, NULL);
-       base_uri = g_strdup_printf ("http://localhost:%u/",
+       base_uri = g_strdup_printf ("http://127.0.0.1:%u/",
                                    soup_server_get_port (server));
 
        do_test1 ();
index d0905ce..1bca917 100644 (file)
@@ -76,7 +76,7 @@ do_message (const char *path, gboolean long_body,
                      expect_continue ? "" : "no ",
                      auth ? "with" : "without");
 
-       uri = g_strdup_printf ("http://%slocalhost:%d/%s",
+       uri = g_strdup_printf ("http://%s127.0.0.1:%d/%s",
                               auth ? "user:pass@" : "",
                               port, path);
        msg = soup_message_new ("POST", uri);
index 74792f1..e48c9c9 100644 (file)
@@ -412,11 +412,11 @@ main (int argc, char **argv)
        loop = g_main_loop_new (NULL, TRUE);
 
        if (run_tests) {
-               uri_str = g_strdup_printf ("http://localhost:%u/hello", port);
+               uri_str = g_strdup_printf ("http://127.0.0.1:%u/hello", port);
                do_hello_tests (uri_str);
                g_free (uri_str);
 
-               uri_str = g_strdup_printf ("http://localhost:%u/md5", port);
+               uri_str = g_strdup_printf ("http://127.0.0.1:%u/md5", port);
                do_md5_tests (uri_str);
                g_free (uri_str);
        } else {
index 6bb5016..52b7bec 100644 (file)
@@ -156,7 +156,7 @@ do_callback_unref_test (void)
 
        /* Get a guaranteed-bad URI */
        bad_server = soup_server_new (NULL, NULL);
-       bad_uri = g_strdup_printf ("http://localhost:%u/",
+       bad_uri = g_strdup_printf ("http://127.0.0.1:%u/",
                                   soup_server_get_port (bad_server));
        g_object_unref (bad_server);
 
@@ -293,7 +293,7 @@ main (int argc, char **argv)
 
        server = soup_test_server_new (TRUE);
        soup_server_add_handler (server, NULL, server_callback, NULL, NULL);
-       base_uri = soup_uri_new ("http://localhost/");
+       base_uri = soup_uri_new ("http://127.0.0.1/");
        soup_uri_set_port (base_uri, soup_server_get_port (server));
 
        auth_domain = soup_auth_domain_basic_new (
index a154cab..4e8ace9 100644 (file)
@@ -419,7 +419,7 @@ main (int argc, char **argv)
 
        loop = g_main_loop_new (NULL, TRUE);
 
-       uri = soup_uri_new ("http://localhost/");
+       uri = soup_uri_new ("http://127.0.0.1/");
        soup_uri_set_port (uri, soup_server_get_port (server));
        do_ntlm_tests (uri);
        soup_uri_free (uri);
index d47ce91..febe490 100644 (file)
@@ -494,7 +494,7 @@ main (int argc, char **argv)
        test_init (argc, argv, NULL);
        apache_init ();
 
-       base_uri = "http://localhost:47524/";
+       base_uri = "http://127.0.0.1:47524/";
        get_correct_response (base_uri);
 
        debug_printf (1, "\nFully async, fast requests\n");
index a67bd66..c673f83 100644 (file)
@@ -356,12 +356,12 @@ main (int argc, char **argv)
        session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL);
 
        debug_printf (1, "1. Testing against apache\n");
-       do_range_test (session, "http://localhost:47524/", FALSE);
+       do_range_test (session, "http://127.0.0.1:47524/", FALSE);
 
        debug_printf (1, "\n2. Testing against SoupServer\n");
        server = soup_test_server_new (FALSE);
        soup_server_add_handler (server, NULL, server_handler, NULL, NULL);
-       base_uri = g_strdup_printf ("http://localhost:%u/",
+       base_uri = g_strdup_printf ("http://127.0.0.1:%u/",
                                    soup_server_get_port (server));
        do_range_test (session, base_uri, TRUE);
        g_free (base_uri);
index e863068..7cada95 100644 (file)
@@ -308,7 +308,7 @@ main (int argc, char **argv)
        loop = g_main_loop_new (NULL, TRUE);
 
        if (run_tests) {
-               base_uri = soup_uri_new ("http://localhost");
+               base_uri = soup_uri_new ("http://127.0.0.1");
                soup_uri_set_port (base_uri, port);
                do_redirect_tests (base_uri);
                soup_uri_free (base_uri);
index 51d40f4..72f6f7c 100644 (file)
@@ -365,7 +365,7 @@ main (int argc, char **argv)
        loop = g_main_loop_new (NULL, TRUE);
 
        if (run_tests) {
-               uri = soup_uri_new ("http://localhost");
+               uri = soup_uri_new ("http://127.0.0.1");
                soup_uri_set_port (uri, soup_server_get_port (server));
                do_auth_tests (uri);
                soup_uri_free (uri);
index 36d5dd6..e28cfe2 100644 (file)
@@ -175,7 +175,7 @@ main (int argc, char **argv)
 
        loop = g_main_loop_new (NULL, TRUE);
 
-       base_uri = soup_uri_new ("http://localhost");
+       base_uri = soup_uri_new ("http://127.0.0.1");
        soup_uri_set_port (base_uri, port);
        do_tests (base_uri);
        soup_uri_free (base_uri);
index 9c159b1..8f20f99 100644 (file)
@@ -322,7 +322,7 @@ main (int argc, char **argv)
        loop = g_main_loop_new (NULL, TRUE);
 
        if (run_tests) {
-               uri = soup_uri_new ("http://localhost/xmlrpc-server.php");
+               uri = soup_uri_new ("http://127.0.0.1/xmlrpc-server.php");
                soup_uri_set_port (uri, soup_server_get_port (server));
                do_xmlrpc_tests (uri);
                soup_uri_free (uri);
index fc86e8f..c7c1774 100644 (file)
@@ -13,7 +13,7 @@
 #include "test-utils.h"
 
 static SoupSession *session;
-static const char *default_uri = "http://localhost:47524/xmlrpc-server.php";
+static const char *default_uri = "http://127.0.0.1:47524/xmlrpc-server.php";
 static const char *uri = NULL;
 static gboolean server_test = FALSE;