diff options
author | Pavel Grunt <pgrunt@redhat.com> | 2016-06-01 10:04:49 +0200 |
---|---|---|
committer | Pavel Grunt <pgrunt@redhat.com> | 2016-06-02 10:26:10 +0200 |
commit | b542dfa2d58cd352dc596318a1e50f074865ef5e (patch) | |
tree | 6b5379f4d95fd7906726b09d6f612434eba5a556 /tests | |
parent | 8dcb4129acde2aed353cd66e28678408e7d1257c (diff) |
spice-uri: Add ipv6 support
Just basic support - http://user:password@[host]:port
Resolves: rhbz#1335239
Diffstat (limited to 'tests')
-rw-r--r-- | tests/uri.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/uri.c b/tests/uri.c index 80b00f4..ea8b794 100644 --- a/tests/uri.c +++ b/tests/uri.c @@ -99,12 +99,45 @@ static void test_spice_uri_ipv4_good(void) test_spice_uri_good(valid_test_cases, G_N_ELEMENTS(valid_test_cases)); } +static void test_spice_uri_ipv6_bad(void) +{ + const struct test_case invalid_test_cases[] = { + {"http://[]:80", "http", NULL, 80, NULL, NULL, "Invalid hostname in uri address"}, + {"http://[::1", "http", NULL, 3128, NULL, NULL, "Missing ']' in ipv6 uri"}, + {"http://[host]1234", "http", "host", 3128, NULL, NULL, "Invalid uri address"}, + {"http://[host]foo/", "http", "host", 3128, NULL, NULL, "Invalid uri address"}, + {"http://[::1]:port", "http", "::1", 3128, NULL, NULL, "Invalid uri port: port"}, + {"http://[::127.0.0.1]:", "http", "::127.0.0.1", 3128, NULL, NULL, "Missing uri port"}, + {"http://[::127.0.0.1]:-42", "http", "::127.0.0.1", 3128, NULL, NULL, "Port out of range"}, + {"[3ffe:2a00:100:7031::1]:42000000", "http", "3ffe:2a00:100:7031::1", 3128, NULL, NULL, "Port out of range"}, + {"scheme://[3ffe::192.168.1.1]:3128", "http", "3ffe::192.168.1.1", 3128, NULL, NULL, + "Invalid uri scheme for proxy: scheme"}, + }; + + test_spice_uri_bad(invalid_test_cases, G_N_ELEMENTS(invalid_test_cases)); +} + +static void test_spice_uri_ipv6_good(void) +{ + const struct test_case valid_test_cases[] = { + {"http://user:password@[host]:80/", "http", "host", 80, "user", "password", NULL}, + {"http://user@[1080:0:0:0:8:800:200C:4171]:100", "http", "1080:0:0:0:8:800:200C:4171", 100, + "user", NULL, NULL}, + {"https://[1080::8:800:200C:417A]", "https", "1080::8:800:200C:417A", 3129, NULL, NULL, NULL}, + {"[3ffe:2a00:100:7031::1]", "http", "3ffe:2a00:100:7031::1", 3128, NULL, NULL, NULL}, + }; + + test_spice_uri_good(valid_test_cases, G_N_ELEMENTS(valid_test_cases)); +} + int main(int argc, char* argv[]) { g_test_init(&argc, &argv, NULL); g_test_add_func("/spice_uri/ipv4/bad-uri", test_spice_uri_ipv4_bad); g_test_add_func("/spice_uri/ipv4/good-uri", test_spice_uri_ipv4_good); + g_test_add_func("/spice_uri/ipv6/bad-uri", test_spice_uri_ipv6_bad); + g_test_add_func("/spice_uri/ipv6/good-uri", test_spice_uri_ipv6_good); return g_test_run(); } |