1 #include "clar_libgit2.h"
3 #include "git2/clone.h"
5 static git_repository
*g_repo
;
8 static bool g_has_ssl
= true;
10 static bool g_has_ssl
= false;
13 static int cert_check_assert_invalid(git_cert
*cert
, int valid
, const char* host
, void *payload
)
15 GIT_UNUSED(cert
); GIT_UNUSED(host
); GIT_UNUSED(payload
);
17 cl_assert_equal_i(0, valid
);
19 return GIT_ECERTIFICATE
;
22 void test_online_badssl__expired(void)
24 git_clone_options opts
= GIT_CLONE_OPTIONS_INIT
;
25 opts
.fetch_opts
.callbacks
.certificate_check
= cert_check_assert_invalid
;
30 cl_git_fail_with(GIT_ECERTIFICATE
,
31 git_clone(&g_repo
, "https://expired.badssl.com/fake.git", "./fake", NULL
));
33 cl_git_fail_with(GIT_ECERTIFICATE
,
34 git_clone(&g_repo
, "https://expired.badssl.com/fake.git", "./fake", &opts
));
37 void test_online_badssl__wrong_host(void)
39 git_clone_options opts
= GIT_CLONE_OPTIONS_INIT
;
40 opts
.fetch_opts
.callbacks
.certificate_check
= cert_check_assert_invalid
;
45 cl_git_fail_with(GIT_ECERTIFICATE
,
46 git_clone(&g_repo
, "https://wrong.host.badssl.com/fake.git", "./fake", NULL
));
47 cl_git_fail_with(GIT_ECERTIFICATE
,
48 git_clone(&g_repo
, "https://wrong.host.badssl.com/fake.git", "./fake", &opts
));
51 void test_online_badssl__self_signed(void)
53 git_clone_options opts
= GIT_CLONE_OPTIONS_INIT
;
54 opts
.fetch_opts
.callbacks
.certificate_check
= cert_check_assert_invalid
;
59 cl_git_fail_with(GIT_ECERTIFICATE
,
60 git_clone(&g_repo
, "https://self-signed.badssl.com/fake.git", "./fake", NULL
));
61 cl_git_fail_with(GIT_ECERTIFICATE
,
62 git_clone(&g_repo
, "https://self-signed.badssl.com/fake.git", "./fake", &opts
));
65 void test_online_badssl__old_cipher(void)
67 git_clone_options opts
= GIT_CLONE_OPTIONS_INIT
;
68 opts
.fetch_opts
.callbacks
.certificate_check
= cert_check_assert_invalid
;
73 cl_git_fail(git_clone(&g_repo
, "https://rc4.badssl.com/fake.git", "./fake", NULL
));
74 cl_git_fail(git_clone(&g_repo
, "https://rc4.badssl.com/fake.git", "./fake", &opts
));