Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
ab3e8565
Commit
ab3e8565
authored
Jul 01, 2019
by
Paul Wolfgang (DC-AE/ESF1)
Committed by
Edward Thomson
Dec 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
urlparse: Add IPv4 and IPv6 based tests
parent
381991a1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
510 additions
and
0 deletions
+510
-0
tests/network/urlparse.c
+510
-0
No files found.
tests/network/urlparse.c
View file @
ab3e8565
...
...
@@ -13,6 +13,10 @@ void test_network_urlparse__cleanup(void)
git_net_url_dispose
(
&
conndata
);
}
/*
* example.com based tests
*/
void
test_network_urlparse__trivial
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"http://example.com/resource"
));
...
...
@@ -166,3 +170,509 @@ void test_network_urlparse__user_pass_port(void)
cl_assert_equal_s
(
conndata
.
password
,
"pass"
);
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
0
);
}
/*
* IPv4 based tests
*/
void
test_network_urlparse__trivial_ipv4
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"http://192.168.1.1/resource"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"http"
);
cl_assert_equal_s
(
conndata
.
host
,
"192.168.1.1"
);
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
);
}
void
test_network_urlparse__root_ipv4
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"http://192.168.1.1/"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"http"
);
cl_assert_equal_s
(
conndata
.
host
,
"192.168.1.1"
);
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
);
}
void
test_network_urlparse__implied_root_ipv4
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"http://192.168.1.1"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"http"
);
cl_assert_equal_s
(
conndata
.
host
,
"192.168.1.1"
);
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
);
}
void
test_network_urlparse__implied_root_custom_port_ipv4
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"http://192.168.1.1:42"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"http"
);
cl_assert_equal_s
(
conndata
.
host
,
"192.168.1.1"
);
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
);
}
void
test_network_urlparse__implied_root_empty_port_ipv4
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"http://192.168.1.1:"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"http"
);
cl_assert_equal_s
(
conndata
.
host
,
"192.168.1.1"
);
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
);
}
void
test_network_urlparse__encoded_password_ipv4
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"https://user:pass%2fis%40bad@192.168.1.1:1234/"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"https"
);
cl_assert_equal_s
(
conndata
.
host
,
"192.168.1.1"
);
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
);
}
void
test_network_urlparse__user_ipv4
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"https://user@192.168.1.1/resource"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"https"
);
cl_assert_equal_s
(
conndata
.
host
,
"192.168.1.1"
);
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
);
}
void
test_network_urlparse__user_pass_ipv4
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"https://user:pass@192.168.1.1/resource"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"https"
);
cl_assert_equal_s
(
conndata
.
host
,
"192.168.1.1"
);
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
);
}
void
test_network_urlparse__port_ipv4
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"https://192.168.1.1:9191/resource"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"https"
);
cl_assert_equal_s
(
conndata
.
host
,
"192.168.1.1"
);
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
);
}
void
test_network_urlparse__empty_port_ipv4
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"http://192.168.1.1:/resource"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"http"
);
cl_assert_equal_s
(
conndata
.
host
,
"192.168.1.1"
);
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
);
}
void
test_network_urlparse__user_port_ipv4
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"https://user@192.168.1.1:9191/resource"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"https"
);
cl_assert_equal_s
(
conndata
.
host
,
"192.168.1.1"
);
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
);
}
void
test_network_urlparse__user_pass_port_ipv4
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"https://user:pass@192.168.1.1:9191/resource"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"https"
);
cl_assert_equal_s
(
conndata
.
host
,
"192.168.1.1"
);
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
);
}
/*
* IPv6 based tests
*/
void
test_network_urlparse__trivial_ipv6
(
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
)
{
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
)
{
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
)
{
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
)
{
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
)
{
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
)
{
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
)
{
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
)
{
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
)
{
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
)
{
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
)
{
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
);
/* Opening bracket missing */
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
,
"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
,
"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"
));
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment