33static git_repository * _repo ;
44static int counter ;
55
6+ static char * _remote_proxy_scheme = NULL ;
7+ static char * _remote_proxy_host = NULL ;
8+ static char * _remote_proxy_user = NULL ;
9+ static char * _remote_proxy_pass = NULL ;
10+
611void test_online_fetch__initialize (void )
712{
813 cl_git_pass (git_repository_init (& _repo , "./fetch" , 0 ));
14+
15+ _remote_proxy_scheme = cl_getenv ("GITTEST_REMOTE_PROXY_SCHEME" );
16+ _remote_proxy_host = cl_getenv ("GITTEST_REMOTE_PROXY_HOST" );
17+ _remote_proxy_user = cl_getenv ("GITTEST_REMOTE_PROXY_USER" );
18+ _remote_proxy_pass = cl_getenv ("GITTEST_REMOTE_PROXY_PASS" );
919}
1020
1121void test_online_fetch__cleanup (void )
@@ -14,6 +24,11 @@ void test_online_fetch__cleanup(void)
1424 _repo = NULL ;
1525
1626 cl_fixture_cleanup ("./fetch" );
27+
28+ git__free (_remote_proxy_scheme );
29+ git__free (_remote_proxy_host );
30+ git__free (_remote_proxy_user );
31+ git__free (_remote_proxy_pass );
1732}
1833
1934static int update_tips (const char * refname , const git_oid * a , const git_oid * b , void * data )
@@ -207,3 +222,28 @@ void test_online_fetch__twice(void)
207222
208223 git_remote_free (remote );
209224}
225+
226+ void test_online_fetch__proxy (void )
227+ {
228+ git_remote * remote ;
229+ git_buf url = GIT_BUF_INIT ;
230+ git_fetch_options fetch_opts ;
231+
232+ if (!_remote_proxy_host || !_remote_proxy_user || !_remote_proxy_pass )
233+ cl_skip ();
234+
235+ cl_git_pass (git_buf_printf (& url , "%s://%s:%s@%s/" ,
236+ _remote_proxy_scheme ? _remote_proxy_scheme : "http" ,
237+ _remote_proxy_user , _remote_proxy_pass , _remote_proxy_host ));
238+
239+ cl_git_pass (git_fetch_options_init (& fetch_opts , GIT_FETCH_OPTIONS_VERSION ));
240+ fetch_opts .proxy_opts .type = GIT_PROXY_SPECIFIED ;
241+ fetch_opts .proxy_opts .url = url .ptr ;
242+
243+ cl_git_pass (git_remote_create (& remote , _repo , "test" , "https://github.com/libgit2/TestGitRepository.git" ));
244+ cl_git_pass (git_remote_connect (remote , GIT_DIRECTION_FETCH , NULL , & fetch_opts .proxy_opts , NULL ));
245+ cl_git_pass (git_remote_fetch (remote , NULL , & fetch_opts , NULL ));
246+
247+ git_remote_free (remote );
248+ git_buf_dispose (& url );
249+ }
0 commit comments