1 #include "clar_libgit2.h"
4 #include "git2/clone.h"
5 #include "git2/cred_helpers.h"
11 * Certificate one is in the `certs` folder; certificate two is in the
12 * `self-signed.pem` file.
14 #define CUSTOM_CERT_ONE_URL "https://test.libgit2.org:1443/anonymous/test.git"
15 #define CUSTOM_CERT_ONE_PATH "certs"
17 #define CUSTOM_CERT_TWO_URL "https://test.libgit2.org:2443/anonymous/test.git"
18 #define CUSTOM_CERT_TWO_FILE "self-signed.pem"
20 #if (GIT_OPENSSL || GIT_MBEDTLS)
21 static git_repository
*g_repo
;
22 static int initialized
= false;
25 void test_online_customcert__initialize(void)
27 #if (GIT_OPENSSL || GIT_MBEDTLS)
31 git_str path
= GIT_STR_INIT
, file
= GIT_STR_INIT
;
32 char cwd
[GIT_PATH_MAX
];
34 cl_fixture_sandbox(CUSTOM_CERT_ONE_PATH
);
35 cl_fixture_sandbox(CUSTOM_CERT_TWO_FILE
);
37 cl_must_pass(p_getcwd(cwd
, GIT_PATH_MAX
));
38 cl_git_pass(git_str_joinpath(&path
, cwd
, CUSTOM_CERT_ONE_PATH
));
39 cl_git_pass(git_str_joinpath(&file
, cwd
, CUSTOM_CERT_TWO_FILE
));
41 cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SSL_CERT_LOCATIONS
,
45 git_str_dispose(&file
);
46 git_str_dispose(&path
);
51 void test_online_customcert__cleanup(void)
53 #if (GIT_OPENSSL || GIT_MBEDTLS)
55 git_repository_free(g_repo
);
59 cl_fixture_cleanup("./cloned");
60 cl_fixture_cleanup(CUSTOM_CERT_ONE_PATH
);
61 cl_fixture_cleanup(CUSTOM_CERT_TWO_FILE
);
65 void test_online_customcert__file(void)
67 #if (GIT_OPENSSL || GIT_MBEDTLS)
68 cl_git_pass(git_clone(&g_repo
, CUSTOM_CERT_ONE_URL
, "./cloned", NULL
));
69 cl_assert(git_fs_path_exists("./cloned/master.txt"));
73 void test_online_customcert__path(void)
75 #if (GIT_OPENSSL || GIT_MBEDTLS)
76 cl_git_pass(git_clone(&g_repo
, CUSTOM_CERT_TWO_URL
, "./cloned", NULL
));
77 cl_assert(git_fs_path_exists("./cloned/master.txt"));