summaryrefslogtreecommitdiff
path: root/tests/online/clone.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-08-29 17:07:07 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2014-09-16 17:01:30 +0200
commit85acc56262b20567c40a90c0996115060655112c (patch)
treea85713d7fe31c1fa95f8035e5acced070009104c /tests/online/clone.c
parentec1ce4584a6a8ec2b5b227301a918548907a2b02 (diff)
downloadlibgit2-85acc56262b20567c40a90c0996115060655112c.tar.gz
remote: add tests for the certificate callback
Diffstat (limited to 'tests/online/clone.c')
-rw-r--r--tests/online/clone.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/online/clone.c b/tests/online/clone.c
index 1ccaf2773..2e8db2b64 100644
--- a/tests/online/clone.c
+++ b/tests/online/clone.c
@@ -469,3 +469,38 @@ void test_online_clone__url_with_no_path_returns_EINVALIDSPEC(void)
cl_git_fail_with(git_clone(&g_repo, "http://github.com", "./foo", &g_options),
GIT_EINVALIDSPEC);
}
+
+static int fail_certificate_check(git_cert_t type, void *data, size_t len, void *payload)
+{
+ GIT_UNUSED(type);
+ GIT_UNUSED(data);
+ GIT_UNUSED(len);
+ GIT_UNUSED(payload);
+
+ return GIT_EUSER;
+}
+
+void test_online_clone__certificate_invalid(void)
+{
+ g_options.remote_callbacks.certificate_check = fail_certificate_check;
+
+ cl_git_fail_with(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options),
+ GIT_EUSER);
+}
+
+static int succeed_certificate_check(git_cert_t type, void *data, size_t len, void *payload)
+{
+ GIT_UNUSED(type);
+ GIT_UNUSED(data);
+ GIT_UNUSED(len);
+ GIT_UNUSED(payload);
+
+ return 0;
+}
+
+void test_online_clone__certificate_valid(void)
+{
+ g_options.remote_callbacks.certificate_check = succeed_certificate_check;
+
+ cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
+}