[Spice-devel] [PATCH spice-gtk 4/5] test-session: Also test hostname, username and password

Victor Toso lists at victortoso.com
Tue May 31 10:12:24 UTC 2016


Hi,

On Fri, May 20, 2016 at 02:50:59PM +0200, Pavel Grunt wrote:
> ---
>  tests/session.c | 48 +++++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 45 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/session.c b/tests/session.c
> index 549378b..00a5a1e 100644
> --- a/tests/session.c
> +++ b/tests/session.c
> @@ -8,33 +8,63 @@ static void test_session_uri(void)
>      struct {
>          gchar *port;
>          gchar *tls_port;
> +        gchar *host;
> +        gchar *username;
> +        gchar *password;
>          gchar *uri_input;
>          gchar *uri_output;
>      } tests[] = {
>          /* Arguments with empty value */
>          { "5900", NULL,
> +          "localhost",
> +          NULL, NULL,
>            "spice://localhost?port=5900&tls-port=",
>            "spice://localhost?port=5900&" },
>          { "5910", NULL,
> -          "spice://localhost?tls-port=&port=5910",
> +          "localhost",
> +          "user", NULL,
> +          "spice://user@localhost?tls-port=&port=5910",
>            "spice://localhost?port=5910&" },
>          { NULL, "5920",
> -          "spice://localhost?tls-port=5920&port=",
> +          "localhost",
> +          "user", "password",
> +          "spice://user@localhost?tls-port=5920&port=&password=password",
>            "spice://localhost?tls-port=5920" },
>          { NULL, "5930",
> +          "localhost",
> +          NULL, NULL,
>            "spice://localhost?port=&tls-port=5930",
>            "spice://localhost?tls-port=5930" },
>          { "42", NULL,
> +          "localhost",
> +          NULL, NULL,
>            "spice://localhost:42",
>            "spice://localhost?port=42&" },
>          { "42", "5930",
> +          "localhost",
> +          NULL, NULL,
>            "spice://localhost:42?tls-port=5930",
>            "spice://localhost?port=42&tls-port=5930" },
> +        { "42", "5930",
> +          "127.0.0.1",
> +          NULL, NULL,
> +          "spice://127.0.0.1:42?tls-port=5930",
> +          "spice://127.0.0.1?port=42&tls-port=5930" },
> +        { "42", "5930",
> +          "::1",
> +          "user", NULL,
> +          "spice://user@[::1]:42?tls-port=5930",
> +          "spice://::1?port=42&tls-port=5930" },
> +        { "42", NULL,
> +          "abcd::1",
> +          NULL, "00000",
> +          "spice://[abcd::1]?port=42&password=00000",
> +          "spice://abcd::1?port=42&" },

We did not have ipv6 tests so far, right? I would include them in a
different patch and different test as well.

>      };
>  
>      /* Set URI and check URI, port and tls_port */
>      for (i = 0; i < G_N_ELEMENTS(tests); i++) {
> -        gchar *uri, *port, *tls_port;
> +        gchar *uri, *port, *tls_port, *host, *username, *password;
>  
>          s = spice_session_new();
>          g_object_set(s, "uri", tests[i].uri_input, NULL);
> @@ -42,13 +72,22 @@ static void test_session_uri(void)
>                       "uri", &uri,
>                       "port", &port,
>                       "tls-port", &tls_port,
> +                     "host", &host,
> +                     "username", &username,
> +                     "password", &password,
>                        NULL);
>          g_assert_cmpstr(tests[i].uri_output, ==, uri);
>          g_assert_cmpstr(tests[i].port, ==, port);
>          g_assert_cmpstr(tests[i].tls_port, ==, tls_port);
> +        g_assert_cmpstr(tests[i].host, ==, host);
> +        g_assert_cmpstr(tests[i].username, ==, username);
> +        g_assert_cmpstr(tests[i].password, ==, password);
>          g_clear_pointer(&uri, g_free);
>          g_clear_pointer(&port, g_free);
>          g_clear_pointer(&tls_port, g_free);
> +        g_clear_pointer(&host, g_free);
> +        g_clear_pointer(&username, g_free);
> +        g_clear_pointer(&password, g_free);
>          g_object_unref(s);
>      }
>  
> @@ -60,6 +99,9 @@ static void test_session_uri(void)
>          g_object_set(s,
>                       "port", tests[i].port,
>                       "tls-port", tests[i].tls_port,
> +                     "host", tests[i].host,
> +                     "username", tests[i].username,
> +                     "password", tests[i].password,
>                        NULL);
>          g_object_get(s, "uri", &uri, NULL);
>          g_assert_cmpstr(tests[i].uri_output, ==, uri);
> -- 
> 2.8.2
> 

Looks good,
Reviewed-by: Victor Toso <victortoso at redhat.com>

> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list