diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2023-05-12 20:48:30 +0100 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2023-05-13 16:42:04 +0100 |
commit | 6e4bbf222d8c4babaff90aef40615546c8bc9cde (patch) | |
tree | add632fcb19f7266e22044022840d9500b5b3c84 /tests | |
parent | dbe343b6e3e957b5cffbd04832c6e7364b496ae7 (diff) | |
download | libgit2-6e4bbf222d8c4babaff90aef40615546c8bc9cde.tar.gz |
net: move rfc2818 hostname / wildcard matching to util
Diffstat (limited to 'tests')
-rw-r--r-- | tests/libgit2/network/matchhost.c | 13 | ||||
-rw-r--r-- | tests/util/hostname.c | 13 |
2 files changed, 13 insertions, 13 deletions
diff --git a/tests/libgit2/network/matchhost.c b/tests/libgit2/network/matchhost.c deleted file mode 100644 index 3100dc21d..000000000 --- a/tests/libgit2/network/matchhost.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "clar_libgit2.h" -#include "netops.h" - -void test_network_matchhost__match(void) -{ - cl_git_pass(gitno__match_host("*.example.org", "www.example.org")); - cl_git_pass(gitno__match_host("*.foo.example.org", "www.foo.example.org")); - cl_git_fail(gitno__match_host("*.foo.example.org", "foo.example.org")); - cl_git_fail(gitno__match_host("*.foo.example.org", "www.example.org")); - cl_git_fail(gitno__match_host("*.example.org", "example.org")); - cl_git_fail(gitno__match_host("*.example.org", "www.foo.example.org")); - cl_git_fail(gitno__match_host("*.example.org", "blah.www.www.example.org")); -} diff --git a/tests/util/hostname.c b/tests/util/hostname.c new file mode 100644 index 000000000..5d8bfe2ac --- /dev/null +++ b/tests/util/hostname.c @@ -0,0 +1,13 @@ +#include "clar_libgit2.h" +#include "net.h" + +void test_hostname__matches_cert(void) +{ + cl_assert_equal_b(true, git_net_hostname_matches_cert("www.example.org", "*.example.org")); + cl_assert_equal_b(true, git_net_hostname_matches_cert("www.foo.example.org", "*.foo.example.org")); + cl_assert_equal_b(false, git_net_hostname_matches_cert("foo.example.org", "*.foo.example.org")); + cl_assert_equal_b(false, git_net_hostname_matches_cert("www.example.org", "*.foo.example.org")); + cl_assert_equal_b(false, git_net_hostname_matches_cert("example.org", "*.example.org")); + cl_assert_equal_b(false, git_net_hostname_matches_cert("www.foo.example.org", "*.example.org")); + cl_assert_equal_b(false, git_net_hostname_matches_cert("blah.www.www.example.org", "*.example.org")); +} |