summaryrefslogtreecommitdiff
path: root/tests/util/hostname.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/util/hostname.c')
-rw-r--r--tests/util/hostname.c13
1 files changed, 13 insertions, 0 deletions
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"));
+}