summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2020-12-17 14:09:45 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2020-12-23 12:00:34 +0000
commit780ad7a9aac4215570f1a7a93b71dd4cf2f74312 (patch)
tree7a41367b8970dee9479e57bce538676030801074
parentab3e8565da67e3a1765780b717187314b47a83d6 (diff)
downloadlibgit2-780ad7a9aac4215570f1a7a93b71dd4cf2f74312.tar.gz
urlparse: use consistent ipv6 address rules
IPv6 addresses should be used identically internally; we should not denote them with brackets in one operating system and without them in another.
-rw-r--r--tests/network/urlparse.c339
1 files changed, 109 insertions, 230 deletions
diff --git a/tests/network/urlparse.c b/tests/network/urlparse.c
index d0aa214d8..91c1a527c 100644
--- a/tests/network/urlparse.c
+++ b/tests/network/urlparse.c
@@ -13,11 +13,9 @@ void test_network_urlparse__cleanup(void)
git_net_url_dispose(&conndata);
}
-/*
- * example.com based tests
- */
+/* Hostname */
-void test_network_urlparse__trivial(void)
+void test_network_urlparse__hostname_trivial(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://example.com/resource"));
cl_assert_equal_s(conndata.scheme, "http");
@@ -29,7 +27,7 @@ void test_network_urlparse__trivial(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__root(void)
+void test_network_urlparse__hostname_root(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://example.com/"));
cl_assert_equal_s(conndata.scheme, "http");
@@ -41,7 +39,7 @@ void test_network_urlparse__root(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__implied_root(void)
+void test_network_urlparse__hostname_implied_root(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://example.com"));
cl_assert_equal_s(conndata.scheme, "http");
@@ -53,7 +51,7 @@ void test_network_urlparse__implied_root(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__implied_root_custom_port(void)
+void test_network_urlparse__hostname_implied_root_custom_port(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://example.com:42"));
cl_assert_equal_s(conndata.scheme, "http");
@@ -65,7 +63,7 @@ void test_network_urlparse__implied_root_custom_port(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
}
-void test_network_urlparse__implied_root_empty_port(void)
+void test_network_urlparse__hostname_implied_root_empty_port(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://example.com:"));
cl_assert_equal_s(conndata.scheme, "http");
@@ -77,7 +75,7 @@ void test_network_urlparse__implied_root_empty_port(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__encoded_password(void)
+void test_network_urlparse__hostname_encoded_password(void)
{
cl_git_pass(git_net_url_parse(&conndata,
"https://user:pass%2fis%40bad@hostname.com:1234/"));
@@ -90,7 +88,7 @@ void test_network_urlparse__encoded_password(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
}
-void test_network_urlparse__user(void)
+void test_network_urlparse__hostname_user(void)
{
cl_git_pass(git_net_url_parse(&conndata,
"https://user@example.com/resource"));
@@ -103,7 +101,7 @@ void test_network_urlparse__user(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__user_pass(void)
+void test_network_urlparse__hostname_user_pass(void)
{
/* user:pass@hostname.tld/resource */
cl_git_pass(git_net_url_parse(&conndata,
@@ -117,7 +115,7 @@ void test_network_urlparse__user_pass(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__port(void)
+void test_network_urlparse__hostname_port(void)
{
/* hostname.tld:port/resource */
cl_git_pass(git_net_url_parse(&conndata,
@@ -131,7 +129,7 @@ void test_network_urlparse__port(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
}
-void test_network_urlparse__empty_port(void)
+void test_network_urlparse__hostname_empty_port(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://example.com:/resource"));
cl_assert_equal_s(conndata.scheme, "http");
@@ -143,7 +141,7 @@ void test_network_urlparse__empty_port(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__user_port(void)
+void test_network_urlparse__hostname_user_port(void)
{
/* user@hostname.tld:port/resource */
cl_git_pass(git_net_url_parse(&conndata,
@@ -157,7 +155,7 @@ void test_network_urlparse__user_port(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
}
-void test_network_urlparse__user_pass_port(void)
+void test_network_urlparse__hostname_user_pass_port(void)
{
/* user:pass@hostname.tld:port/resource */
cl_git_pass(git_net_url_parse(&conndata,
@@ -171,11 +169,9 @@ void test_network_urlparse__user_pass_port(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
}
-/*
- * IPv4 based tests
- */
+/* IPv4 addresses */
-void test_network_urlparse__trivial_ipv4(void)
+void test_network_urlparse__ipv4_trivial(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://192.168.1.1/resource"));
cl_assert_equal_s(conndata.scheme, "http");
@@ -187,7 +183,7 @@ void test_network_urlparse__trivial_ipv4(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__root_ipv4(void)
+void test_network_urlparse__ipv4_root(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://192.168.1.1/"));
cl_assert_equal_s(conndata.scheme, "http");
@@ -199,7 +195,7 @@ void test_network_urlparse__root_ipv4(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__implied_root_ipv4(void)
+void test_network_urlparse__ipv4_implied_root(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://192.168.1.1"));
cl_assert_equal_s(conndata.scheme, "http");
@@ -211,7 +207,7 @@ void test_network_urlparse__implied_root_ipv4(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__implied_root_custom_port_ipv4(void)
+void test_network_urlparse__ipv4_implied_root_custom_port(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://192.168.1.1:42"));
cl_assert_equal_s(conndata.scheme, "http");
@@ -223,7 +219,7 @@ void test_network_urlparse__implied_root_custom_port_ipv4(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
}
-void test_network_urlparse__implied_root_empty_port_ipv4(void)
+void test_network_urlparse__ipv4_implied_root_empty_port(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://192.168.1.1:"));
cl_assert_equal_s(conndata.scheme, "http");
@@ -235,7 +231,7 @@ void test_network_urlparse__implied_root_empty_port_ipv4(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__encoded_password_ipv4(void)
+void test_network_urlparse__ipv4_encoded_password(void)
{
cl_git_pass(git_net_url_parse(&conndata,
"https://user:pass%2fis%40bad@192.168.1.1:1234/"));
@@ -248,7 +244,7 @@ void test_network_urlparse__encoded_password_ipv4(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
}
-void test_network_urlparse__user_ipv4(void)
+void test_network_urlparse__ipv4_user(void)
{
cl_git_pass(git_net_url_parse(&conndata,
"https://user@192.168.1.1/resource"));
@@ -261,7 +257,7 @@ void test_network_urlparse__user_ipv4(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__user_pass_ipv4(void)
+void test_network_urlparse__ipv4_user_pass(void)
{
cl_git_pass(git_net_url_parse(&conndata,
"https://user:pass@192.168.1.1/resource"));
@@ -274,7 +270,7 @@ void test_network_urlparse__user_pass_ipv4(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__port_ipv4(void)
+void test_network_urlparse__ipv4_port(void)
{
cl_git_pass(git_net_url_parse(&conndata,
"https://192.168.1.1:9191/resource"));
@@ -287,7 +283,7 @@ void test_network_urlparse__port_ipv4(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
}
-void test_network_urlparse__empty_port_ipv4(void)
+void test_network_urlparse__ipv4_empty_port(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://192.168.1.1:/resource"));
cl_assert_equal_s(conndata.scheme, "http");
@@ -299,7 +295,7 @@ void test_network_urlparse__empty_port_ipv4(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__user_port_ipv4(void)
+void test_network_urlparse__ipv4_user_port(void)
{
cl_git_pass(git_net_url_parse(&conndata,
"https://user@192.168.1.1:9191/resource"));
@@ -312,7 +308,7 @@ void test_network_urlparse__user_port_ipv4(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
}
-void test_network_urlparse__user_pass_port_ipv4(void)
+void test_network_urlparse__ipv4_user_pass_port(void)
{
cl_git_pass(git_net_url_parse(&conndata,
"https://user:pass@192.168.1.1:9191/resource"));
@@ -325,354 +321,237 @@ void test_network_urlparse__user_pass_port_ipv4(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
}
-/*
- * IPv6 based tests
- */
+/* IPv6 addresses */
-void test_network_urlparse__trivial_ipv6(void)
+void test_network_urlparse__ipv6_trivial(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://[fe80::dcad:beff:fe00:0001]/resource"));
cl_assert_equal_s(conndata.scheme, "http");
-#ifdef WIN32
- cl_assert_equal_s(conndata.host, "[fe80::dcad:beff:fe00:0001]");
-#else
cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
-#endif
cl_assert_equal_s(conndata.port, "80");
cl_assert_equal_s(conndata.path, "/resource");
cl_assert_equal_p(conndata.username, NULL);
cl_assert_equal_p(conndata.password, NULL);
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
-
- /* Opening bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "http://fe80::dcad:beff:fe00:0001]/resource"));
- /* Closing bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "http://[fe80::dcad:beff:fe00:0001/resource"));
-#ifdef WIN32
- /* Both brackets missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "http://fe80::dcad:beff:fe00:0001/resource"));
-#endif
}
-void test_network_urlparse__root_ipv6(void)
+void test_network_urlparse__ipv6_root(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://[fe80::dcad:beff:fe00:0001]/"));
cl_assert_equal_s(conndata.scheme, "http");
-#ifdef WIN32
- cl_assert_equal_s(conndata.host, "[fe80::dcad:beff:fe00:0001]");
-#else
cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
-#endif
cl_assert_equal_s(conndata.port, "80");
cl_assert_equal_s(conndata.path, "/");
cl_assert_equal_p(conndata.username, NULL);
cl_assert_equal_p(conndata.password, NULL);
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
-
- /* Opening bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "http://fe80::dcad:beff:fe00:0001]/"));
- /* Closing bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "http://[fe80::dcad:beff:fe00:0001/"));
-#ifdef WIN32
- /* Both brackets missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "http://fe80::dcad:beff:fe00:0001/"));
-#endif
}
-void test_network_urlparse__implied_root_ipv6(void)
+void test_network_urlparse__ipv6_implied_root(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://[fe80::dcad:beff:fe00:0001]"));
cl_assert_equal_s(conndata.scheme, "http");
-#ifdef WIN32
- cl_assert_equal_s(conndata.host, "[fe80::dcad:beff:fe00:0001]");
-#else
cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
-#endif
cl_assert_equal_s(conndata.port, "80");
cl_assert_equal_s(conndata.path, "/");
cl_assert_equal_p(conndata.username, NULL);
cl_assert_equal_p(conndata.password, NULL);
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
-
- /* Opening bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "http://fe80::dcad:beff:fe00:0001]"));
- /* Closing bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "http://[fe80::dcad:beff:fe00:0001"));
-#ifdef WIN32
- /* Both brackets missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "http://fe80::dcad:beff:fe00:0001"));
-#endif
}
-void test_network_urlparse__implied_root_custom_port_ipv6(void)
+void test_network_urlparse__ipv6_implied_root_custom_port(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://[fe80::dcad:beff:fe00:0001]:42"));
cl_assert_equal_s(conndata.scheme, "http");
-#ifdef WIN32
- cl_assert_equal_s(conndata.host, "[fe80::dcad:beff:fe00:0001]");
-#else
cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
-#endif
cl_assert_equal_s(conndata.port, "42");
cl_assert_equal_s(conndata.path, "/");
cl_assert_equal_p(conndata.username, NULL);
cl_assert_equal_p(conndata.password, NULL);
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
-
- /* Opening bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "http://fe80::dcad:beff:fe00:0001]:42"));
- /* Closing bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "http://[fe80::dcad:beff:fe00:0001:42"));
-#ifdef WIN32
- /* Both brackets missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "http://fe80::dcad:beff:fe00:0001:42"));
-#endif
}
-void test_network_urlparse__implied_root_empty_port_ipv6(void)
+void test_network_urlparse__ipv6_implied_root_empty_port(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://[fe80::dcad:beff:fe00:0001]:"));
cl_assert_equal_s(conndata.scheme, "http");
-#ifdef WIN32
- cl_assert_equal_s(conndata.host, "[fe80::dcad:beff:fe00:0001]");
-#else
cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
-#endif
cl_assert_equal_s(conndata.port, "80");
cl_assert_equal_s(conndata.path, "/");
cl_assert_equal_p(conndata.username, NULL);
cl_assert_equal_p(conndata.password, NULL);
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
-
- /* Opening bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "http://fe80::dcad:beff:fe00:0001]:"));
- /* Closing bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "http://[fe80::dcad:beff:fe00:0001:"));
-#ifdef WIN32
- /* Both brackets missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "http://fe80::dcad:beff:fe00:0001:"));
-#endif
}
-void test_network_urlparse__encoded_password_ipv6(void)
+void test_network_urlparse__ipv6_encoded_password(void)
{
cl_git_pass(git_net_url_parse(&conndata,
"https://user:pass%2fis%40bad@[fe80::dcad:beff:fe00:0001]:1234/"));
cl_assert_equal_s(conndata.scheme, "https");
-#ifdef WIN32
- cl_assert_equal_s(conndata.host, "[fe80::dcad:beff:fe00:0001]");
-#else
cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
-#endif
cl_assert_equal_s(conndata.port, "1234");
cl_assert_equal_s(conndata.path, "/");
cl_assert_equal_s(conndata.username, "user");
cl_assert_equal_s(conndata.password, "pass/is@bad");
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
-
- /* Opening bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "https://user:pass%2fis%40bad@fe80::dcad:beff:fe00:0001]:1234/"));
- /* Closing bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "https://user:pass%2fis%40bad@[fe80::dcad:beff:fe00:0001:1234/"));
-#ifdef WIN32
- /* Both brackets missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "https://user:pass%2fis%40bad@fe80::dcad:beff:fe00:0001:1234/"));
-#endif
}
-void test_network_urlparse__user_ipv6(void)
+void test_network_urlparse__ipv6_user(void)
{
cl_git_pass(git_net_url_parse(&conndata,
"https://user@[fe80::dcad:beff:fe00:0001]/resource"));
cl_assert_equal_s(conndata.scheme, "https");
-#ifdef WIN32
- cl_assert_equal_s(conndata.host, "[fe80::dcad:beff:fe00:0001]");
-#else
cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
-#endif
cl_assert_equal_s(conndata.port, "443");
cl_assert_equal_s(conndata.path, "/resource");
cl_assert_equal_s(conndata.username, "user");
cl_assert_equal_p(conndata.password, NULL);
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
-
- /* Opening bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "https://user@fe80::dcad:beff:fe00:0001]/resource"));
- /* Closing bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "https://user@[fe80::dcad:beff:fe00:0001/resource"));
-#ifdef WIN32
- /* Both brackets missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "https://user@fe80::dcad:beff:fe00:0001/resource"));
-#endif
}
-void test_network_urlparse__user_pass_ipv6(void)
+void test_network_urlparse__ipv6_user_pass(void)
{
cl_git_pass(git_net_url_parse(&conndata,
"https://user:pass@[fe80::dcad:beff:fe00:0001]/resource"));
cl_assert_equal_s(conndata.scheme, "https");
-#ifdef WIN32
- cl_assert_equal_s(conndata.host, "[fe80::dcad:beff:fe00:0001]");
-#else
cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
-#endif
cl_assert_equal_s(conndata.port, "443");
cl_assert_equal_s(conndata.path, "/resource");
cl_assert_equal_s(conndata.username, "user");
cl_assert_equal_s(conndata.password, "pass");
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
-
- /* Opening bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "https://user:pass@fe80::dcad:beff:fe00:0001]/resource"));
- /* Closing bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "https://user:pass@[fe80::dcad:beff:fe00:0001/resource"));
-#ifdef WIN32
- /* Both brackets missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "https://user:pass@fe80::dcad:beff:fe00:0001/resource"));
-#endif
}
-void test_network_urlparse__port_ipv6(void)
+void test_network_urlparse__ipv6_port(void)
{
cl_git_pass(git_net_url_parse(&conndata,
"https://[fe80::dcad:beff:fe00:0001]:9191/resource"));
cl_assert_equal_s(conndata.scheme, "https");
-#ifdef WIN32
- cl_assert_equal_s(conndata.host, "[fe80::dcad:beff:fe00:0001]");
-#else
cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
-#endif
cl_assert_equal_s(conndata.port, "9191");
cl_assert_equal_s(conndata.path, "/resource");
cl_assert_equal_p(conndata.username, NULL);
cl_assert_equal_p(conndata.password, NULL);
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
-
- /* Opening bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "https://fe80::dcad:beff:fe00:0001]:9191/resource"));
- /* Closing bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "https://[fe80::dcad:beff:fe00:0001:9191/resource"));
-#ifdef WIN32
- /* Both brackets missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "https://fe80::dcad:beff:fe00:0001:9191/resource"));
-#endif
}
-void test_network_urlparse__empty_port_ipv6(void)
+void test_network_urlparse__ipv6_empty_port(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://[fe80::dcad:beff:fe00:0001]:/resource"));
cl_assert_equal_s(conndata.scheme, "http");
-#ifdef WIN32
- cl_assert_equal_s(conndata.host, "[fe80::dcad:beff:fe00:0001]");
-#else
cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
-#endif
cl_assert_equal_s(conndata.port, "80");
cl_assert_equal_s(conndata.path, "/resource");
cl_assert_equal_p(conndata.username, NULL);
cl_assert_equal_p(conndata.password, NULL);
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
-
- /* Opening bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "http://fe80::dcad:beff:fe00:0001]:/resource"));
- /* Closing bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "http://[fe80::dcad:beff:fe00:0001:/resource"));
-#ifdef WIN32
- /* Both brackets missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "http://fe80::dcad:beff:fe00:0001:/resource"));
-#endif
}
-void test_network_urlparse__user_port_ipv6(void)
+void test_network_urlparse__ipv6_user_port(void)
{
cl_git_pass(git_net_url_parse(&conndata,
"https://user@[fe80::dcad:beff:fe00:0001]:9191/resource"));
cl_assert_equal_s(conndata.scheme, "https");
-#ifdef WIN32
- cl_assert_equal_s(conndata.host, "[fe80::dcad:beff:fe00:0001]");
-#else
cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
-#endif
cl_assert_equal_s(conndata.port, "9191");
cl_assert_equal_s(conndata.path, "/resource");
cl_assert_equal_s(conndata.username, "user");
cl_assert_equal_p(conndata.password, NULL);
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
-
- /* Opening bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "https://user@fe80::dcad:beff:fe00:0001]:9191/resource"));
- /* Closing bracket missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "https://user@[fe80::dcad:beff:fe00:0001:9191/resource"));
-#ifdef WIN32
- /* Both brackets missing */
- cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
- "https://user@fe80::dcad:beff:fe00:0001:9191/resource"));
-#endif
}
-void test_network_urlparse__user_pass_port_ipv6(void)
+void test_network_urlparse__ipv6_user_pass_port(void)
{
cl_git_pass(git_net_url_parse(&conndata,
"https://user:pass@[fe80::dcad:beff:fe00:0001]:9191/resource"));
cl_assert_equal_s(conndata.scheme, "https");
-#ifdef WIN32
- cl_assert_equal_s(conndata.host, "[fe80::dcad:beff:fe00:0001]");
-#else
cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
-#endif
cl_assert_equal_s(conndata.port, "9191");
cl_assert_equal_s(conndata.path, "/resource");
cl_assert_equal_s(conndata.username, "user");
cl_assert_equal_s(conndata.password, "pass");
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
+}
+void test_network_urlparse__ipv6_invalid_addresses(void)
+{
/* Opening bracket missing */
cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001]/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001]/"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001]"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001]:42"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001]:"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user:pass%2fis%40bad@fe80::dcad:beff:fe00:0001]:1234/"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user@fe80::dcad:beff:fe00:0001]/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user:pass@fe80::dcad:beff:fe00:0001]/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://fe80::dcad:beff:fe00:0001]:9191/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001]:/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user@fe80::dcad:beff:fe00:0001]:9191/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
"https://user:pass@fe80::dcad:beff:fe00:0001]:9191/resource"));
+
/* Closing bracket missing */
cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://[fe80::dcad:beff:fe00:0001/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://[fe80::dcad:beff:fe00:0001/"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://[fe80::dcad:beff:fe00:0001"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://[fe80::dcad:beff:fe00:0001:42"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://[fe80::dcad:beff:fe00:0001:"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user:pass%2fis%40bad@[fe80::dcad:beff:fe00:0001:1234/"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user@[fe80::dcad:beff:fe00:0001/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user:pass@[fe80::dcad:beff:fe00:0001/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://[fe80::dcad:beff:fe00:0001:9191/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://[fe80::dcad:beff:fe00:0001:/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user@[fe80::dcad:beff:fe00:0001:9191/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
"https://user:pass@[fe80::dcad:beff:fe00:0001:9191/resource"));
-#ifdef WIN32
/* Both brackets missing */
cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001/"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001:42"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001:"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user:pass%2fis%40bad@fe80::dcad:beff:fe00:0001:1234/"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user@fe80::dcad:beff:fe00:0001/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user:pass@fe80::dcad:beff:fe00:0001/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://fe80::dcad:beff:fe00:0001:9191/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001:/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user@fe80::dcad:beff:fe00:0001:9191/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
"https://user:pass@fe80::dcad:beff:fe00:0001:9191/resource"));
-#endif
-}
-void test_network_urlparse__fails_ipv6(void)
-{
/* Invalid chracter inside address */
cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata, "http://[fe8o::dcad:beff:fe00:0001]/resource"));
}