Re: [PATCH spice-gtk 1/4] tests: Add test for SpiceUri

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Po, 2016-05-16 at 10:10 -0400, Frediano Ziglio wrote:
> > 
> > Related: rhbz#1335239
> > ---
> >  tests/Makefile.am      |  2 ++
> >  tests/test-spice-uri.c | 64
> >  ++++++++++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 66 insertions(+)
> >  create mode 100644 tests/test-spice-uri.c
> > 
> > diff --git a/tests/Makefile.am b/tests/Makefile.am
> > index c1d95c1..fb97138 100644
> > --- a/tests/Makefile.am
> > +++ b/tests/Makefile.am
> > @@ -4,6 +4,7 @@ noinst_PROGRAMS =
> >  TESTS = coroutine				\
> >  	util					\
> >  	session					\
> > +	test-spice-uri				\
> >  	$(NULL)
> >  
> >  if WITH_PHODAV
> > @@ -35,6 +36,7 @@ util_SOURCES = util.c
> >  coroutine_SOURCES = coroutine.c
> >  session_SOURCES = session.c
> >  pipe_SOURCES = pipe.c
> > +test_spice_uri_SOURCES = test-spice-uri.c
> >  usb_acl_helper_SOURCES = usb-acl-helper.c
> >  usb_acl_helper_CFLAGS = -DTESTDIR=\"$(abs_builddir)\"
> >  mock_acl_helper_SOURCES = mock-acl-helper.c
> > diff --git a/tests/test-spice-uri.c b/tests/test-spice-uri.c
> > new file mode 100644
> > index 0000000..993cc78
> > --- /dev/null
> > +++ b/tests/test-spice-uri.c
> > @@ -0,0 +1,64 @@
> > +/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
> > +/*
> > +   Copyright (C) 2016 Red Hat, Inc.
> > +
> > +   This library is free software; you can redistribute it and/or
> > +   modify it under the terms of the GNU Lesser General Public
> > +   License as published by the Free Software Foundation; either
> > +   version 2.1 of the License, or (at your option) any later version.
> > +
> > +   This library is distributed in the hope that it will be useful,
> > +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > +   Lesser General Public License for more details.
> > +
> > +   You should have received a copy of the GNU Lesser General Public
> > +   License along with this library; if not, see
> > <http://www.gnu.org/licenses/>.
> > +*/
> > +#include <glib.h>
> > +#include <spice-client.h>
> > +#include "spice-uri-priv.h"
> > +
> > +static void test_spice_uri_ipv4(void)
> > +{
> > +    SpiceURI *uri = spice_uri_new();
> > +    g_assert_nonnull(uri);
> > +
> > +    /* missing hostname */
> > +    g_assert_false(spice_uri_parse(uri, "http://:80";, NULL));
> > +    /* invalid port */
> > +    g_assert_false(spice_uri_parse(uri, "http://127.0.0.1:port";, NULL));
> > +
> > +    g_assert_true(spice_uri_parse(uri, "http://127.0.0.1/";, NULL));
> > +    g_assert_cmpstr(spice_uri_get_scheme(uri), ==, "http");
> > +    g_assert_cmpstr(spice_uri_get_hostname(uri), ==, "127.0.0.1");
> > +    g_assert_cmpuint(spice_uri_get_port(uri), ==, 3128);
> > +
> > +    g_assert_true(spice_uri_parse(uri, "https://127.0.0.1";, NULL));
> > +    g_assert_cmpstr(spice_uri_get_scheme(uri), ==, "https");
> > +    g_assert_cmpstr(spice_uri_get_hostname(uri), ==, "127.0.0.1");
> > +    g_assert_cmpuint(spice_uri_get_port(uri), ==, 3129);
> > +
> > +    g_assert_true(spice_uri_parse(uri, "127.0.0.1", NULL));
> > +    g_assert_cmpstr(spice_uri_get_scheme(uri), ==, "http");
> > +    g_assert_cmpstr(spice_uri_get_hostname(uri), ==, "127.0.0.1");
> > +    g_assert_cmpuint(spice_uri_get_port(uri), ==, 3128);
> > +
> > +    g_assert_true(spice_uri_parse(uri, "http://user:password@host:80";,
> > NULL));
> > +    g_assert_cmpstr(spice_uri_get_scheme(uri), ==, "http");
> > +    g_assert_cmpstr(spice_uri_get_hostname(uri), ==, "host");
> > +    g_assert_cmpstr(spice_uri_get_user(uri), ==, "user");
> > +    g_assert_cmpstr(spice_uri_get_password(uri), ==, "password");
> > +    g_assert_cmpuint(spice_uri_get_port(uri), ==, 80);
> > +
> > +    g_object_unref(uri);
> > +}
> > +
> > +int main(int argc, char* argv[])
> > +{
> > +    g_test_init(&argc, &argv, NULL);
> > +
> > +    g_test_add_func("/spice_uri/ipv4", test_spice_uri_ipv4);
> > +
> > +    return g_test_run();
> > +}
> > --
> > 2.8.2
> > 
> 
> Looks ok, a bit weird that default ports are 3128 and 3129, looks different
> from the "URI" definition.

IIUC there is no real standard port for http CONNECT proxies, let alone
for much less used https. 3128 is default for squid, some other default
to 8080/8443 and some use just standard http(s) ports of 80/443 (e.g.
apache's mod_proxy).

David

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


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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]