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
96d2d429
Commit
96d2d429
authored
Apr 14, 2022
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: move url tests into util
parent
f98dd543
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
47 deletions
+47
-47
tests/util/url/joinpath.c
+8
-8
tests/util/url/parse.c
+0
-0
tests/util/url/pattern.c
+2
-2
tests/util/url/redirect.c
+13
-13
tests/util/url/scp.c
+23
-23
tests/util/url/valid.c
+1
-1
No files found.
tests/
libgit2/network
/url/joinpath.c
→
tests/
util
/url/joinpath.c
View file @
96d2d429
...
...
@@ -4,19 +4,19 @@
static
git_net_url
source
,
target
;
void
test_
network_
url_joinpath__initialize
(
void
)
void
test_url_joinpath__initialize
(
void
)
{
memset
(
&
source
,
0
,
sizeof
(
source
));
memset
(
&
target
,
0
,
sizeof
(
target
));
}
void
test_
network_
url_joinpath__cleanup
(
void
)
void
test_url_joinpath__cleanup
(
void
)
{
git_net_url_dispose
(
&
source
);
git_net_url_dispose
(
&
target
);
}
void
test_
network_
url_joinpath__target_paths_and_queries
(
void
)
void
test_url_joinpath__target_paths_and_queries
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
source
,
"http://example.com/a/b"
));
...
...
@@ -31,7 +31,7 @@ void test_network_url_joinpath__target_paths_and_queries(void)
git_net_url_dispose
(
&
target
);
}
void
test_
network_
url_joinpath__source_query_removed
(
void
)
void
test_url_joinpath__source_query_removed
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
source
,
"http://example.com/a/b?query&one&two"
));
...
...
@@ -46,7 +46,7 @@ void test_network_url_joinpath__source_query_removed(void)
git_net_url_dispose
(
&
target
);
}
void
test_
network_
url_joinpath__source_lacks_path
(
void
)
void
test_url_joinpath__source_lacks_path
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
source
,
"http://example.com"
));
...
...
@@ -91,7 +91,7 @@ void test_network_url_joinpath__source_lacks_path(void)
git_net_url_dispose
(
&
target
);
}
void
test_
network_
url_joinpath__source_is_slash
(
void
)
void
test_url_joinpath__source_is_slash
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
source
,
"http://example.com/"
));
...
...
@@ -137,7 +137,7 @@ void test_network_url_joinpath__source_is_slash(void)
}
void
test_
network_
url_joinpath__source_has_query
(
void
)
void
test_url_joinpath__source_has_query
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
source
,
"http://example.com?query"
));
...
...
@@ -183,7 +183,7 @@ void test_network_url_joinpath__source_has_query(void)
}
void
test_
network_
url_joinpath__empty_query_ignored
(
void
)
void
test_url_joinpath__empty_query_ignored
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
source
,
"http://example.com/foo"
));
...
...
tests/
libgit2/network
/url/parse.c
→
tests/
util
/url/parse.c
View file @
96d2d429
This diff is collapsed.
Click to expand it.
tests/
libgit2/network
/url/pattern.c
→
tests/
util
/url/pattern.c
View file @
96d2d429
...
...
@@ -7,7 +7,7 @@ struct url_pattern {
bool
matches
;
};
void
test_
network_
url_pattern__single
(
void
)
void
test_url_pattern__single
(
void
)
{
git_net_url
url
;
size_t
i
;
...
...
@@ -53,7 +53,7 @@ void test_network_url_pattern__single(void)
}
}
void
test_
network_
url_pattern__list
(
void
)
void
test_url_pattern__list
(
void
)
{
git_net_url
url
;
size_t
i
;
...
...
tests/
libgit2/network
/url/redirect.c
→
tests/
util
/url/redirect.c
View file @
96d2d429
...
...
@@ -4,17 +4,17 @@
static
git_net_url
conndata
;
void
test_
network_
url_redirect__initialize
(
void
)
void
test_url_redirect__initialize
(
void
)
{
memset
(
&
conndata
,
0
,
sizeof
(
conndata
));
}
void
test_
network_
url_redirect__cleanup
(
void
)
void
test_url_redirect__cleanup
(
void
)
{
git_net_url_dispose
(
&
conndata
);
}
void
test_
network_
url_redirect__redirect_http
(
void
)
void
test_url_redirect__redirect_http
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"http://example.com/foo/bar/baz"
));
...
...
@@ -28,7 +28,7 @@ void test_network_url_redirect__redirect_http(void)
cl_assert_equal_p
(
conndata
.
password
,
NULL
);
}
void
test_
network_
url_redirect__redirect_ssl
(
void
)
void
test_url_redirect__redirect_ssl
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"https://example.com/foo/bar/baz"
));
...
...
@@ -42,7 +42,7 @@ void test_network_url_redirect__redirect_ssl(void)
cl_assert_equal_p
(
conndata
.
password
,
NULL
);
}
void
test_
network_
url_redirect__redirect_leaves_root_path
(
void
)
void
test_url_redirect__redirect_leaves_root_path
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"https://example.com/foo/bar/baz"
));
...
...
@@ -56,7 +56,7 @@ void test_network_url_redirect__redirect_leaves_root_path(void)
cl_assert_equal_p
(
conndata
.
password
,
NULL
);
}
void
test_
network_
url_redirect__redirect_encoded_username_password
(
void
)
void
test_url_redirect__redirect_encoded_username_password
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"https://user%2fname:pass%40word%zyx%v@example.com/foo/bar/baz"
));
...
...
@@ -70,7 +70,7 @@ void test_network_url_redirect__redirect_encoded_username_password(void)
cl_assert_equal_s
(
conndata
.
password
,
"pass@word%zyx%v"
);
}
void
test_
network_
url_redirect__redirect_cross_host_allowed
(
void
)
void
test_url_redirect__redirect_cross_host_allowed
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"https://bar.com/bar/baz"
));
...
...
@@ -84,7 +84,7 @@ void test_network_url_redirect__redirect_cross_host_allowed(void)
cl_assert_equal_p
(
conndata
.
password
,
NULL
);
}
void
test_
network_
url_redirect__redirect_cross_host_denied
(
void
)
void
test_url_redirect__redirect_cross_host_denied
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"https://bar.com/bar/baz"
));
...
...
@@ -92,7 +92,7 @@ void test_network_url_redirect__redirect_cross_host_denied(void)
"https://foo.com/bar/baz"
,
false
,
NULL
),
-
1
);
}
void
test_
network_
url_redirect__redirect_http_downgrade_denied
(
void
)
void
test_url_redirect__redirect_http_downgrade_denied
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"https://foo.com/bar/baz"
));
...
...
@@ -100,7 +100,7 @@ void test_network_url_redirect__redirect_http_downgrade_denied(void)
"http://foo.com/bar/baz"
,
true
,
NULL
),
-
1
);
}
void
test_
network_
url_redirect__redirect_relative
(
void
)
void
test_url_redirect__redirect_relative
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"http://foo.com/bar/baz/biff"
));
...
...
@@ -114,7 +114,7 @@ void test_network_url_redirect__redirect_relative(void)
cl_assert_equal_p
(
conndata
.
password
,
NULL
);
}
void
test_
network_
url_redirect__redirect_relative_ssl
(
void
)
void
test_url_redirect__redirect_relative_ssl
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"https://foo.com/bar/baz/biff"
));
...
...
@@ -128,7 +128,7 @@ void test_network_url_redirect__redirect_relative_ssl(void)
cl_assert_equal_p
(
conndata
.
password
,
NULL
);
}
void
test_
network_
url_redirect__service_query_no_query_params_in_location
(
void
)
void
test_url_redirect__service_query_no_query_params_in_location
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"https://foo.com/bar/info/refs?service=git-upload-pack"
));
...
...
@@ -137,7 +137,7 @@ void test_network_url_redirect__service_query_no_query_params_in_location(void)
cl_assert_equal_s
(
conndata
.
path
,
"/baz"
);
}
void
test_
network_
url_redirect__service_query_with_query_params_in_location
(
void
)
void
test_url_redirect__service_query_with_query_params_in_location
(
void
)
{
cl_git_pass
(
git_net_url_parse
(
&
conndata
,
"https://foo.com/bar/info/refs?service=git-upload-pack"
));
...
...
tests/
libgit2/network
/url/scp.c
→
tests/
util
/url/scp.c
View file @
96d2d429
...
...
@@ -3,19 +3,19 @@
static
git_net_url
conndata
;
void
test_
network_
url_scp__initialize
(
void
)
void
test_url_scp__initialize
(
void
)
{
memset
(
&
conndata
,
0
,
sizeof
(
conndata
));
}
void
test_
network_
url_scp__cleanup
(
void
)
void
test_url_scp__cleanup
(
void
)
{
git_net_url_dispose
(
&
conndata
);
}
/* Hostname */
void
test_
network_
url_scp__hostname_trivial
(
void
)
void
test_url_scp__hostname_trivial
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"example.com:/resource"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -27,7 +27,7 @@ void test_network_url_scp__hostname_trivial(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
1
);
}
void
test_
network_
url_scp__hostname_bracketed
(
void
)
void
test_url_scp__hostname_bracketed
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"[example.com]:/resource"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -39,7 +39,7 @@ void test_network_url_scp__hostname_bracketed(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
1
);
}
void
test_
network_
url_scp__hostname_root
(
void
)
void
test_url_scp__hostname_root
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"example.com:/"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -51,7 +51,7 @@ void test_network_url_scp__hostname_root(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
1
);
}
void
test_
network_
url_scp__hostname_user
(
void
)
void
test_url_scp__hostname_user
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"git@example.com:/resource"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -63,7 +63,7 @@ void test_network_url_scp__hostname_user(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
1
);
}
void
test_
network_
url_scp__hostname_user_bracketed
(
void
)
void
test_url_scp__hostname_user_bracketed
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"[git@example.com]:/resource"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -75,7 +75,7 @@ void test_network_url_scp__hostname_user_bracketed(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
1
);
}
void
test_
network_
url_scp__hostname_port
(
void
)
void
test_url_scp__hostname_port
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"[example.com:42]:/resource"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -87,7 +87,7 @@ void test_network_url_scp__hostname_port(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
0
);
}
void
test_
network_
url_scp__hostname_user_port
(
void
)
void
test_url_scp__hostname_user_port
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"[git@example.com:42]:/resource"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -99,7 +99,7 @@ void test_network_url_scp__hostname_user_port(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
0
);
}
void
test_
network_
url_scp__ipv4_trivial
(
void
)
void
test_url_scp__ipv4_trivial
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"192.168.99.88:/resource/a/b/c"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -111,7 +111,7 @@ void test_network_url_scp__ipv4_trivial(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
1
);
}
void
test_
network_
url_scp__ipv4_bracketed
(
void
)
void
test_url_scp__ipv4_bracketed
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"[192.168.99.88]:/resource/a/b/c"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -123,7 +123,7 @@ void test_network_url_scp__ipv4_bracketed(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
1
);
}
void
test_
network_
url_scp__ipv4_user
(
void
)
void
test_url_scp__ipv4_user
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"git@192.168.99.88:/resource/a/b/c"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -135,7 +135,7 @@ void test_network_url_scp__ipv4_user(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
1
);
}
void
test_
network_
url_scp__ipv4_port
(
void
)
void
test_url_scp__ipv4_port
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"[192.168.99.88:1111]:/resource/a/b/c"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -147,7 +147,7 @@ void test_network_url_scp__ipv4_port(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
0
);
}
void
test_
network_
url_scp__ipv4_user_port
(
void
)
void
test_url_scp__ipv4_user_port
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"[git@192.168.99.88:1111]:/resource/a/b/c"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -159,7 +159,7 @@ void test_network_url_scp__ipv4_user_port(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
0
);
}
void
test_
network_
url_scp__ipv6_trivial
(
void
)
void
test_url_scp__ipv6_trivial
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"[fe80::dcad:beff:fe00:0001]:/resource/foo"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -171,7 +171,7 @@ void test_network_url_scp__ipv6_trivial(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
1
);
}
void
test_
network_
url_scp__ipv6_user
(
void
)
void
test_url_scp__ipv6_user
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"git@[fe80::dcad:beff:fe00:0001]:/resource/foo"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -183,7 +183,7 @@ void test_network_url_scp__ipv6_user(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
1
);
}
void
test_
network_
url_scp__ipv6_port
(
void
)
void
test_url_scp__ipv6_port
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"[[fe80::dcad:beff:fe00:0001]:99]:/resource/foo"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -195,7 +195,7 @@ void test_network_url_scp__ipv6_port(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
0
);
}
void
test_
network_
url_scp__ipv6_user_port
(
void
)
void
test_url_scp__ipv6_user_port
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"[git@[fe80::dcad:beff:fe00:0001]:99]:/resource/foo"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -207,7 +207,7 @@ void test_network_url_scp__ipv6_user_port(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
0
);
}
void
test_
network_
url_scp__hexhost_and_port
(
void
)
void
test_url_scp__hexhost_and_port
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"[fe:22]:/resource/foo"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -219,7 +219,7 @@ void test_network_url_scp__hexhost_and_port(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
1
);
}
void
test_
network_
url_scp__malformed_ipv6_one
(
void
)
void
test_url_scp__malformed_ipv6_one
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"fe80::dcad:beff:fe00:0001]:/resource"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -231,7 +231,7 @@ void test_network_url_scp__malformed_ipv6_one(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
1
);
}
void
test_
network_
url_scp__malformed_ipv6_two
(
void
)
void
test_url_scp__malformed_ipv6_two
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"[fe80::dcad:beff:fe00:0001]:42]:/resource"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -243,7 +243,7 @@ void test_network_url_scp__malformed_ipv6_two(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
1
);
}
void
test_
network_
url_scp__malformed_ipv6_with_user
(
void
)
void
test_url_scp__malformed_ipv6_with_user
(
void
)
{
cl_git_pass
(
git_net_url_parse_scp
(
&
conndata
,
"git@[fe80::dcad:beff:fe00:0001]:42]:/resource"
));
cl_assert_equal_s
(
conndata
.
scheme
,
"ssh"
);
...
...
@@ -255,7 +255,7 @@ void test_network_url_scp__malformed_ipv6_with_user(void)
cl_assert_equal_i
(
git_net_url_is_default_port
(
&
conndata
),
1
);
}
void
test_
network_
url_scp__invalid_addresses
(
void
)
void
test_url_scp__invalid_addresses
(
void
)
{
/* Path is required */
cl_git_fail_with
(
GIT_EINVALIDSPEC
,
git_net_url_parse_scp
(
&
conndata
,
...
...
tests/
libgit2/network
/url/valid.c
→
tests/
util
/url/valid.c
View file @
96d2d429
#include "clar_libgit2.h"
#include "net.h"
void
test_
network_
url_valid__test
(
void
)
void
test_url_valid__test
(
void
)
{
cl_assert
(
git_net_str_is_url
(
"http://example.com/"
));
cl_assert
(
git_net_str_is_url
(
"file://localhost/tmp/foo/"
));
...
...
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