mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-31 15:36:04 +00:00
proxy: ask the user for credentials if necessary
This commit is contained in:
parent
a7bece2014
commit
07bd3e57d9
@ -26,7 +26,7 @@ static int use_remote(git_repository *repo, char *name)
|
|||||||
*/
|
*/
|
||||||
callbacks.credentials = cred_acquire_cb;
|
callbacks.credentials = cred_acquire_cb;
|
||||||
|
|
||||||
error = git_remote_connect(remote, GIT_DIRECTION_FETCH, &callbacks, NULL);
|
error = git_remote_connect(remote, GIT_DIRECTION_FETCH, &callbacks, NULL, NULL);
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "strarray.h"
|
#include "strarray.h"
|
||||||
#include "transport.h"
|
#include "transport.h"
|
||||||
#include "pack.h"
|
#include "pack.h"
|
||||||
|
#include "proxy.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file git2/remote.h
|
* @file git2/remote.h
|
||||||
@ -241,10 +242,11 @@ GIT_EXTERN(const git_refspec *)git_remote_get_refspec(const git_remote *remote,
|
|||||||
* @param direction GIT_DIRECTION_FETCH if you want to fetch or
|
* @param direction GIT_DIRECTION_FETCH if you want to fetch or
|
||||||
* GIT_DIRECTION_PUSH if you want to push
|
* GIT_DIRECTION_PUSH if you want to push
|
||||||
* @param callbacks the callbacks to use for this connection
|
* @param callbacks the callbacks to use for this connection
|
||||||
|
* @param proxy_opts proxy settings
|
||||||
* @param custom_headers extra HTTP headers to use in this connection
|
* @param custom_headers extra HTTP headers to use in this connection
|
||||||
* @return 0 or an error code
|
* @return 0 or an error code
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks, const git_strarray *custom_headers);
|
GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks, const git_proxy_options *proxy_opts, const git_strarray *custom_headers);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the remote repository's reference advertisement list
|
* Get the remote repository's reference advertisement list
|
||||||
@ -548,6 +550,11 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
git_remote_autotag_option_t download_tags;
|
git_remote_autotag_option_t download_tags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Proxy options to use, by default no proxy is used.
|
||||||
|
*/
|
||||||
|
git_proxy_options proxy_opts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extra headers for this fetch operation
|
* Extra headers for this fetch operation
|
||||||
*/
|
*/
|
||||||
@ -555,7 +562,8 @@ typedef struct {
|
|||||||
} git_fetch_options;
|
} git_fetch_options;
|
||||||
|
|
||||||
#define GIT_FETCH_OPTIONS_VERSION 1
|
#define GIT_FETCH_OPTIONS_VERSION 1
|
||||||
#define GIT_FETCH_OPTIONS_INIT { GIT_FETCH_OPTIONS_VERSION, GIT_REMOTE_CALLBACKS_INIT, GIT_FETCH_PRUNE_UNSPECIFIED, 1 }
|
#define GIT_FETCH_OPTIONS_INIT { GIT_FETCH_OPTIONS_VERSION, GIT_REMOTE_CALLBACKS_INIT, GIT_FETCH_PRUNE_UNSPECIFIED, 1, \
|
||||||
|
GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED, GIT_PROXY_OPTIONS_INIT }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a `git_fetch_options` with default values. Equivalent to
|
* Initializes a `git_fetch_options` with default values. Equivalent to
|
||||||
@ -592,6 +600,11 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
git_remote_callbacks callbacks;
|
git_remote_callbacks callbacks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Proxy options to use, by default no proxy is used.
|
||||||
|
*/
|
||||||
|
git_proxy_options proxy_opts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extra headers for this push operation
|
* Extra headers for this push operation
|
||||||
*/
|
*/
|
||||||
@ -599,7 +612,7 @@ typedef struct {
|
|||||||
} git_push_options;
|
} git_push_options;
|
||||||
|
|
||||||
#define GIT_PUSH_OPTIONS_VERSION 1
|
#define GIT_PUSH_OPTIONS_VERSION 1
|
||||||
#define GIT_PUSH_OPTIONS_INIT { GIT_PUSH_OPTIONS_VERSION, 0, GIT_REMOTE_CALLBACKS_INIT }
|
#define GIT_PUSH_OPTIONS_INIT { GIT_PUSH_OPTIONS_VERSION, 0, GIT_REMOTE_CALLBACKS_INIT, GIT_PROXY_OPTIONS_INIT }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a `git_push_options` with default values. Equivalent to
|
* Initializes a `git_push_options` with default values. Equivalent to
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "git2/net.h"
|
#include "git2/net.h"
|
||||||
#include "git2/types.h"
|
#include "git2/types.h"
|
||||||
#include "git2/strarray.h"
|
#include "git2/strarray.h"
|
||||||
|
#include "git2/proxy.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file git2/sys/transport.h
|
* @file git2/sys/transport.h
|
||||||
@ -53,6 +54,7 @@ struct git_transport {
|
|||||||
const char *url,
|
const char *url,
|
||||||
git_cred_acquire_cb cred_acquire_cb,
|
git_cred_acquire_cb cred_acquire_cb,
|
||||||
void *cred_acquire_payload,
|
void *cred_acquire_payload,
|
||||||
|
const git_proxy_options *proxy_opts,
|
||||||
int direction,
|
int direction,
|
||||||
int flags);
|
int flags);
|
||||||
|
|
||||||
@ -65,7 +67,7 @@ struct git_transport {
|
|||||||
git_transport *transport);
|
git_transport *transport);
|
||||||
|
|
||||||
/* Executes the push whose context is in the git_push object. */
|
/* Executes the push whose context is in the git_push object. */
|
||||||
int (*push)(git_transport *transport, git_push *push, const git_remote_callbacks *callbacks);
|
int(*push)(git_transport *transport, git_push *push, const git_remote_callbacks *callbacks);
|
||||||
|
|
||||||
/* This function may be called after a successful call to connect(), when
|
/* This function may be called after a successful call to connect(), when
|
||||||
* the direction is FETCH. The function performs a negotiation to calculate
|
* the direction is FETCH. The function performs a negotiation to calculate
|
||||||
|
16
src/proxy.c
16
src/proxy.c
@ -14,3 +14,19 @@ int git_proxy_init_options(git_proxy_options *opts, unsigned int version)
|
|||||||
opts, version, git_proxy_options, GIT_PROXY_OPTIONS_INIT);
|
opts, version, git_proxy_options, GIT_PROXY_OPTIONS_INIT);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int git_proxy_options_dup(git_proxy_options *tgt, const git_proxy_options *src)
|
||||||
|
{
|
||||||
|
if (!src) {
|
||||||
|
git_proxy_init_options(tgt, GIT_PROXY_OPTIONS_VERSION);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(tgt, src, sizeof(git_proxy_options));
|
||||||
|
if (src->url) {
|
||||||
|
tgt->url = git__strdup(src->url);
|
||||||
|
GITERR_CHECK_ALLOC(tgt->url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
14
src/proxy.h
Normal file
14
src/proxy.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||||
|
* a Linking Exception. For full terms see the included COPYING file.
|
||||||
|
*/
|
||||||
|
#ifndef INCLUDE_proxy_h__
|
||||||
|
#define INCLUDE_proxy_h__
|
||||||
|
|
||||||
|
#include "git2/proxy.h"
|
||||||
|
|
||||||
|
extern int git_proxy_options_dup(git_proxy_options *tgt, const git_proxy_options *src);
|
||||||
|
|
||||||
|
#endif
|
@ -639,7 +639,7 @@ int git_push_finish(git_push *push, const git_remote_callbacks *callbacks)
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (!git_remote_connected(push->remote) &&
|
if (!git_remote_connected(push->remote) &&
|
||||||
(error = git_remote_connect(push->remote, GIT_DIRECTION_PUSH, callbacks, push->custom_headers)) < 0)
|
(error = git_remote_connect(push->remote, GIT_DIRECTION_PUSH, callbacks, NULL, push->custom_headers)) < 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
if ((error = filter_refs(push->remote)) < 0 ||
|
if ((error = filter_refs(push->remote)) < 0 ||
|
||||||
|
26
src/remote.c
26
src/remote.c
@ -695,7 +695,7 @@ static int set_transport_custom_headers(git_transport *t, const git_strarray *cu
|
|||||||
return t->set_custom_headers(t, custom_headers);
|
return t->set_custom_headers(t, custom_headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_remote_connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks, const git_strarray *custom_headers)
|
int git_remote_connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks, const git_proxy_options *proxy, const git_strarray *custom_headers)
|
||||||
{
|
{
|
||||||
git_transport *t;
|
git_transport *t;
|
||||||
const char *url;
|
const char *url;
|
||||||
@ -714,6 +714,9 @@ int git_remote_connect(git_remote *remote, git_direction direction, const git_re
|
|||||||
payload = callbacks->payload;
|
payload = callbacks->payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (proxy)
|
||||||
|
GITERR_CHECK_VERSION(proxy, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
|
||||||
|
|
||||||
t = remote->transport;
|
t = remote->transport;
|
||||||
|
|
||||||
url = git_remote__urlfordirection(remote, direction);
|
url = git_remote__urlfordirection(remote, direction);
|
||||||
@ -738,7 +741,7 @@ int git_remote_connect(git_remote *remote, git_direction direction, const git_re
|
|||||||
goto on_error;
|
goto on_error;
|
||||||
|
|
||||||
if ((error = set_transport_callbacks(t, callbacks)) < 0 ||
|
if ((error = set_transport_callbacks(t, callbacks)) < 0 ||
|
||||||
(error = t->connect(t, url, credentials, payload, direction, flags)) != 0)
|
(error = t->connect(t, url, credentials, payload, proxy, direction, flags)) != 0)
|
||||||
goto on_error;
|
goto on_error;
|
||||||
|
|
||||||
remote->transport = t;
|
remote->transport = t;
|
||||||
@ -896,6 +899,7 @@ int git_remote_download(git_remote *remote, const git_strarray *refspecs, const
|
|||||||
git_vector *to_active, specs = GIT_VECTOR_INIT, refs = GIT_VECTOR_INIT;
|
git_vector *to_active, specs = GIT_VECTOR_INIT, refs = GIT_VECTOR_INIT;
|
||||||
const git_remote_callbacks *cbs = NULL;
|
const git_remote_callbacks *cbs = NULL;
|
||||||
const git_strarray *custom_headers = NULL;
|
const git_strarray *custom_headers = NULL;
|
||||||
|
const git_proxy_options *proxy = NULL;
|
||||||
|
|
||||||
assert(remote);
|
assert(remote);
|
||||||
|
|
||||||
@ -903,10 +907,12 @@ int git_remote_download(git_remote *remote, const git_strarray *refspecs, const
|
|||||||
GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
|
GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
|
||||||
cbs = &opts->callbacks;
|
cbs = &opts->callbacks;
|
||||||
custom_headers = &opts->custom_headers;
|
custom_headers = &opts->custom_headers;
|
||||||
|
GITERR_CHECK_VERSION(&opts->proxy_opts, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
|
||||||
|
proxy = &opts->proxy_opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!git_remote_connected(remote) &&
|
if (!git_remote_connected(remote) &&
|
||||||
(error = git_remote_connect(remote, GIT_DIRECTION_FETCH, cbs, custom_headers)) < 0)
|
(error = git_remote_connect(remote, GIT_DIRECTION_FETCH, cbs, proxy, custom_headers)) < 0)
|
||||||
goto on_error;
|
goto on_error;
|
||||||
|
|
||||||
if (ls_to_vector(&refs, remote) < 0)
|
if (ls_to_vector(&refs, remote) < 0)
|
||||||
@ -971,6 +977,7 @@ int git_remote_fetch(
|
|||||||
git_buf reflog_msg_buf = GIT_BUF_INIT;
|
git_buf reflog_msg_buf = GIT_BUF_INIT;
|
||||||
const git_remote_callbacks *cbs = NULL;
|
const git_remote_callbacks *cbs = NULL;
|
||||||
const git_strarray *custom_headers = NULL;
|
const git_strarray *custom_headers = NULL;
|
||||||
|
const git_proxy_options *proxy = NULL;
|
||||||
|
|
||||||
if (opts) {
|
if (opts) {
|
||||||
GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
|
GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
|
||||||
@ -978,10 +985,12 @@ int git_remote_fetch(
|
|||||||
custom_headers = &opts->custom_headers;
|
custom_headers = &opts->custom_headers;
|
||||||
update_fetchhead = opts->update_fetchhead;
|
update_fetchhead = opts->update_fetchhead;
|
||||||
tagopt = opts->download_tags;
|
tagopt = opts->download_tags;
|
||||||
|
GITERR_CHECK_VERSION(&opts->proxy_opts, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
|
||||||
|
proxy = &opts->proxy_opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Connect and download everything */
|
/* Connect and download everything */
|
||||||
if ((error = git_remote_connect(remote, GIT_DIRECTION_FETCH, cbs, custom_headers)) != 0)
|
if ((error = git_remote_connect(remote, GIT_DIRECTION_FETCH, cbs, proxy, custom_headers)) != 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
error = git_remote_download(remote, refspecs, opts);
|
error = git_remote_download(remote, refspecs, opts);
|
||||||
@ -2393,16 +2402,18 @@ int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const gi
|
|||||||
git_refspec *spec;
|
git_refspec *spec;
|
||||||
const git_remote_callbacks *cbs = NULL;
|
const git_remote_callbacks *cbs = NULL;
|
||||||
const git_strarray *custom_headers = NULL;
|
const git_strarray *custom_headers = NULL;
|
||||||
|
const git_proxy_options *proxy = NULL;
|
||||||
|
|
||||||
assert(remote);
|
assert(remote);
|
||||||
|
|
||||||
if (opts) {
|
if (opts) {
|
||||||
cbs = &opts->callbacks;
|
cbs = &opts->callbacks;
|
||||||
custom_headers = &opts->custom_headers;
|
custom_headers = &opts->custom_headers;
|
||||||
|
proxy = &opts->proxy_opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!git_remote_connected(remote) &&
|
if (!git_remote_connected(remote) &&
|
||||||
(error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, custom_headers)) < 0)
|
(error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, proxy, custom_headers)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
free_refspecs(&remote->active_refspecs);
|
free_refspecs(&remote->active_refspecs);
|
||||||
@ -2452,16 +2463,19 @@ int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_
|
|||||||
int error;
|
int error;
|
||||||
const git_remote_callbacks *cbs = NULL;
|
const git_remote_callbacks *cbs = NULL;
|
||||||
const git_strarray *custom_headers = NULL;
|
const git_strarray *custom_headers = NULL;
|
||||||
|
const git_proxy_options *proxy = NULL;
|
||||||
|
|
||||||
if (opts) {
|
if (opts) {
|
||||||
GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
|
GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
|
||||||
cbs = &opts->callbacks;
|
cbs = &opts->callbacks;
|
||||||
custom_headers = &opts->custom_headers;
|
custom_headers = &opts->custom_headers;
|
||||||
|
GITERR_CHECK_VERSION(&opts->proxy_opts, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
|
||||||
|
proxy = &opts->proxy_opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(remote && refspecs);
|
assert(remote && refspecs);
|
||||||
|
|
||||||
if ((error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, custom_headers)) < 0)
|
if ((error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, proxy, custom_headers)) < 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
if ((error = git_remote_upload(remote, refspecs, opts)) < 0)
|
if ((error = git_remote_upload(remote, refspecs, opts)) < 0)
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "odb.h"
|
#include "odb.h"
|
||||||
#include "push.h"
|
#include "push.h"
|
||||||
#include "remote.h"
|
#include "remote.h"
|
||||||
|
#include "proxy.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
git_transport parent;
|
git_transport parent;
|
||||||
@ -199,6 +200,7 @@ static int local_connect(
|
|||||||
const char *url,
|
const char *url,
|
||||||
git_cred_acquire_cb cred_acquire_cb,
|
git_cred_acquire_cb cred_acquire_cb,
|
||||||
void *cred_acquire_payload,
|
void *cred_acquire_payload,
|
||||||
|
const git_proxy_options *proxy,
|
||||||
int direction, int flags)
|
int direction, int flags)
|
||||||
{
|
{
|
||||||
git_repository *repo;
|
git_repository *repo;
|
||||||
@ -209,6 +211,7 @@ static int local_connect(
|
|||||||
|
|
||||||
GIT_UNUSED(cred_acquire_cb);
|
GIT_UNUSED(cred_acquire_cb);
|
||||||
GIT_UNUSED(cred_acquire_payload);
|
GIT_UNUSED(cred_acquire_payload);
|
||||||
|
GIT_UNUSED(proxy);
|
||||||
|
|
||||||
if (t->connected)
|
if (t->connected)
|
||||||
return 0;
|
return 0;
|
||||||
@ -439,7 +442,7 @@ static int local_push(
|
|||||||
|
|
||||||
if (!url || t->parent.close(&t->parent) < 0 ||
|
if (!url || t->parent.close(&t->parent) < 0 ||
|
||||||
t->parent.connect(&t->parent, url,
|
t->parent.connect(&t->parent, url,
|
||||||
NULL, NULL, GIT_DIRECTION_PUSH, flags))
|
NULL, NULL, NULL, GIT_DIRECTION_PUSH, flags))
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "smart.h"
|
#include "smart.h"
|
||||||
#include "refs.h"
|
#include "refs.h"
|
||||||
#include "refspec.h"
|
#include "refspec.h"
|
||||||
|
#include "proxy.h"
|
||||||
|
|
||||||
static int git_smart__recv_cb(gitno_buffer *buf)
|
static int git_smart__recv_cb(gitno_buffer *buf)
|
||||||
{
|
{
|
||||||
@ -199,6 +200,7 @@ static int git_smart__connect(
|
|||||||
const char *url,
|
const char *url,
|
||||||
git_cred_acquire_cb cred_acquire_cb,
|
git_cred_acquire_cb cred_acquire_cb,
|
||||||
void *cred_acquire_payload,
|
void *cred_acquire_payload,
|
||||||
|
const git_proxy_options *proxy,
|
||||||
int direction,
|
int direction,
|
||||||
int flags)
|
int flags)
|
||||||
{
|
{
|
||||||
@ -216,6 +218,9 @@ static int git_smart__connect(
|
|||||||
t->url = git__strdup(url);
|
t->url = git__strdup(url);
|
||||||
GITERR_CHECK_ALLOC(t->url);
|
GITERR_CHECK_ALLOC(t->url);
|
||||||
|
|
||||||
|
if (git_proxy_options_dup(&t->proxy, proxy) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
t->direction = direction;
|
t->direction = direction;
|
||||||
t->flags = flags;
|
t->flags = flags;
|
||||||
t->cred_acquire_cb = cred_acquire_cb;
|
t->cred_acquire_cb = cred_acquire_cb;
|
||||||
|
@ -133,6 +133,7 @@ typedef struct {
|
|||||||
char *url;
|
char *url;
|
||||||
git_cred_acquire_cb cred_acquire_cb;
|
git_cred_acquire_cb cred_acquire_cb;
|
||||||
void *cred_acquire_payload;
|
void *cred_acquire_payload;
|
||||||
|
git_proxy_options proxy;
|
||||||
int direction;
|
int direction;
|
||||||
int flags;
|
int flags;
|
||||||
git_transport_message_cb progress_cb;
|
git_transport_message_cb progress_cb;
|
||||||
|
@ -91,13 +91,39 @@ typedef struct {
|
|||||||
git_smart_subtransport parent;
|
git_smart_subtransport parent;
|
||||||
transport_smart *owner;
|
transport_smart *owner;
|
||||||
gitno_connection_data connection_data;
|
gitno_connection_data connection_data;
|
||||||
|
gitno_connection_data proxy_connection_data;
|
||||||
git_cred *cred;
|
git_cred *cred;
|
||||||
git_cred *url_cred;
|
git_cred *url_cred;
|
||||||
|
git_cred *proxy_cred;
|
||||||
int auth_mechanism;
|
int auth_mechanism;
|
||||||
HINTERNET session;
|
HINTERNET session;
|
||||||
HINTERNET connection;
|
HINTERNET connection;
|
||||||
} winhttp_subtransport;
|
} winhttp_subtransport;
|
||||||
|
|
||||||
|
static int apply_basic_credential_proxy(HINTERNET request, git_cred *cred)
|
||||||
|
{
|
||||||
|
git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *)cred;
|
||||||
|
wchar_t *user, *pass;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
if ((error = git__utf8_to_16_alloc(&user, c->username)) < 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = git__utf8_to_16_alloc(&pass, c->password)) < 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if (!WinHttpSetCredentials(request, WINHTTP_AUTH_TARGET_PROXY, WINHTTP_AUTH_SCHEME_BASIC,
|
||||||
|
user, pass, NULL)) {
|
||||||
|
giterr_set(GITERR_OS, "failed to set proxy auth");
|
||||||
|
error = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
git__free(user);
|
||||||
|
git__free(pass);
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
static int apply_basic_credential(HINTERNET request, git_cred *cred)
|
static int apply_basic_credential(HINTERNET request, git_cred *cred)
|
||||||
{
|
{
|
||||||
git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *)cred;
|
git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *)cred;
|
||||||
@ -271,6 +297,34 @@ static void winhttp_stream_close(winhttp_stream *s)
|
|||||||
s->sent_request = 0;
|
s->sent_request = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the url and password from a URL. The outputs are pointers
|
||||||
|
* into the input.
|
||||||
|
*/
|
||||||
|
static int userpass_from_url(wchar_t **user, int *user_len,
|
||||||
|
wchar_t **pass, int *pass_len,
|
||||||
|
const wchar_t *url, int url_len)
|
||||||
|
{
|
||||||
|
URL_COMPONENTS components = { 0 };
|
||||||
|
|
||||||
|
components.dwStructSize = sizeof(components);
|
||||||
|
/* These tell WinHttpCrackUrl that we're interested in the fields */
|
||||||
|
components.dwUserNameLength = 1;
|
||||||
|
components.dwPasswordLength = 1;
|
||||||
|
|
||||||
|
if (!WinHttpCrackUrl(url, url_len, 0, &components)) {
|
||||||
|
giterr_set(GITERR_OS, "failed to extract user/pass from url");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
*user = components.lpszUserName;
|
||||||
|
*user_len = components.dwUserNameLength;
|
||||||
|
*pass = components.lpszPassword;
|
||||||
|
*pass_len = components.dwPasswordLength;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int winhttp_stream_connect(winhttp_stream *s)
|
static int winhttp_stream_connect(winhttp_stream *s)
|
||||||
{
|
{
|
||||||
winhttp_subtransport *t = OWNING_SUBTRANSPORT(s);
|
winhttp_subtransport *t = OWNING_SUBTRANSPORT(s);
|
||||||
@ -284,6 +338,7 @@ static int winhttp_stream_connect(winhttp_stream *s)
|
|||||||
int default_timeout = TIMEOUT_INFINITE;
|
int default_timeout = TIMEOUT_INFINITE;
|
||||||
int default_connect_timeout = DEFAULT_CONNECT_TIMEOUT;
|
int default_connect_timeout = DEFAULT_CONNECT_TIMEOUT;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
const git_proxy_options *proxy_opts;
|
||||||
|
|
||||||
/* Prepare URL */
|
/* Prepare URL */
|
||||||
git_buf_printf(&buf, "%s%s", t->connection_data.path, s->service_url);
|
git_buf_printf(&buf, "%s%s", t->connection_data.path, s->service_url);
|
||||||
@ -317,26 +372,49 @@ static int winhttp_stream_connect(winhttp_stream *s)
|
|||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set proxy if necessary */
|
proxy_opts = &t->owner->proxy;
|
||||||
if (git_remote__get_http_proxy(t->owner->owner, !!t->connection_data.use_ssl, &proxy_url) < 0)
|
if (proxy_opts->type == GIT_PROXY_AUTO) {
|
||||||
goto on_error;
|
/* Set proxy if necessary */
|
||||||
|
if (git_remote__get_http_proxy(t->owner->owner, !!t->connection_data.use_ssl, &proxy_url) < 0)
|
||||||
|
goto on_error;
|
||||||
|
}
|
||||||
|
else if (proxy_opts->type == GIT_PROXY_HTTP) {
|
||||||
|
proxy_url = git__strdup(proxy_opts->url);
|
||||||
|
GITERR_CHECK_ALLOC(proxy_url);
|
||||||
|
}
|
||||||
|
|
||||||
if (proxy_url) {
|
if (proxy_url) {
|
||||||
|
git_buf processed_url = GIT_BUF_INIT;
|
||||||
WINHTTP_PROXY_INFO proxy_info;
|
WINHTTP_PROXY_INFO proxy_info;
|
||||||
wchar_t *proxy_wide;
|
wchar_t *proxy_wide;
|
||||||
|
|
||||||
/* Convert URL to wide characters */
|
if ((error = gitno_connection_data_from_url(&t->proxy_connection_data, proxy_url, NULL)) < 0)
|
||||||
int proxy_wide_len = git__utf8_to_16_alloc(&proxy_wide, proxy_url);
|
goto on_error;
|
||||||
|
|
||||||
if (proxy_wide_len < 0) {
|
if (t->proxy_connection_data.user && t->proxy_connection_data.pass) {
|
||||||
giterr_set(GITERR_OS, "Failed to convert string to wide form");
|
if ((error = git_cred_userpass_plaintext_new(&t->proxy_cred, t->proxy_connection_data.user, t->proxy_connection_data.pass)) < 0)
|
||||||
|
goto on_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t->proxy_connection_data.use_ssl)
|
||||||
|
git_buf_puts(&processed_url, "https://");
|
||||||
|
else
|
||||||
|
git_buf_puts(&processed_url, "http://");
|
||||||
|
|
||||||
|
git_buf_puts(&processed_url, t->proxy_connection_data.host);
|
||||||
|
if (t->proxy_connection_data.port)
|
||||||
|
git_buf_printf(&processed_url, ":%s", t->proxy_connection_data.port);
|
||||||
|
|
||||||
|
if (git_buf_oom(&processed_url)) {
|
||||||
|
giterr_set_oom();
|
||||||
|
error = -1;
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Strip any trailing forward slash on the proxy URL;
|
/* Convert URL to wide characters */
|
||||||
* WinHTTP doesn't like it if one is present */
|
if ((error = git__utf8_to_16_alloc(&proxy_wide, processed_url.ptr)) < 0)
|
||||||
if (proxy_wide_len > 1 && L'/' == proxy_wide[proxy_wide_len - 2])
|
goto on_error;
|
||||||
proxy_wide[proxy_wide_len - 2] = L'\0';
|
|
||||||
|
|
||||||
proxy_info.dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
|
proxy_info.dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
|
||||||
proxy_info.lpszProxy = proxy_wide;
|
proxy_info.lpszProxy = proxy_wide;
|
||||||
@ -352,6 +430,14 @@ static int winhttp_stream_connect(winhttp_stream *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
git__free(proxy_wide);
|
git__free(proxy_wide);
|
||||||
|
|
||||||
|
if (t->proxy_cred) {
|
||||||
|
if (t->proxy_cred->credtype == GIT_CREDTYPE_USERPASS_PLAINTEXT) {
|
||||||
|
if ((error = apply_basic_credential_proxy(s->request, t->proxy_cred)) < 0)
|
||||||
|
goto on_error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disable WinHTTP redirects so we can handle them manually. Why, you ask?
|
/* Disable WinHTTP redirects so we can handle them manually. Why, you ask?
|
||||||
@ -919,6 +1005,26 @@ replay:
|
|||||||
goto replay;
|
goto replay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Handle proxy authentication failures */
|
||||||
|
if (status_code == HTTP_STATUS_PROXY_AUTH_REQ) {
|
||||||
|
int allowed_types;
|
||||||
|
|
||||||
|
if (parse_unauthorized_response(s->request, &allowed_types, &t->auth_mechanism) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* TODO: extract the username from the url, no payload? */
|
||||||
|
if (t->owner->proxy.credentials) {
|
||||||
|
int cred_error = 1;
|
||||||
|
cred_error = t->owner->proxy.credentials(&t->proxy_cred, t->owner->proxy.url, NULL, allowed_types, NULL);
|
||||||
|
|
||||||
|
if (cred_error < 0)
|
||||||
|
return cred_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
winhttp_stream_close(s);
|
||||||
|
goto replay;
|
||||||
|
}
|
||||||
|
|
||||||
/* Handle authentication failures */
|
/* Handle authentication failures */
|
||||||
if (HTTP_STATUS_DENIED == status_code && get_verb == s->verb) {
|
if (HTTP_STATUS_DENIED == status_code && get_verb == s->verb) {
|
||||||
int allowed_types;
|
int allowed_types;
|
||||||
|
@ -26,7 +26,7 @@ static void assert_default_branch(const char *should)
|
|||||||
{
|
{
|
||||||
git_buf name = GIT_BUF_INIT;
|
git_buf name = GIT_BUF_INIT;
|
||||||
|
|
||||||
cl_git_pass(git_remote_connect(g_remote, GIT_DIRECTION_FETCH, NULL, NULL));
|
cl_git_pass(git_remote_connect(g_remote, GIT_DIRECTION_FETCH, NULL, NULL, NULL));
|
||||||
cl_git_pass(git_remote_default_branch(&name, g_remote));
|
cl_git_pass(git_remote_default_branch(&name, g_remote));
|
||||||
cl_assert_equal_s(should, name.ptr);
|
cl_assert_equal_s(should, name.ptr);
|
||||||
git_buf_free(&name);
|
git_buf_free(&name);
|
||||||
@ -57,7 +57,7 @@ void test_network_remote_defaultbranch__no_default_branch(void)
|
|||||||
git_buf buf = GIT_BUF_INIT;
|
git_buf buf = GIT_BUF_INIT;
|
||||||
|
|
||||||
cl_git_pass(git_remote_create(&remote_b, g_repo_b, "self", git_repository_path(g_repo_b)));
|
cl_git_pass(git_remote_create(&remote_b, g_repo_b, "self", git_repository_path(g_repo_b)));
|
||||||
cl_git_pass(git_remote_connect(remote_b, GIT_DIRECTION_FETCH, NULL, NULL));
|
cl_git_pass(git_remote_connect(remote_b, GIT_DIRECTION_FETCH, NULL, NULL, NULL));
|
||||||
cl_git_pass(git_remote_ls(&heads, &len, remote_b));
|
cl_git_pass(git_remote_ls(&heads, &len, remote_b));
|
||||||
cl_assert_equal_i(0, len);
|
cl_assert_equal_i(0, len);
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ void test_network_remote_defaultbranch__detached_sharing_nonbranch_id(void)
|
|||||||
cl_git_pass(git_reference_create(&ref, g_repo_a, "refs/foo/bar", &id, 1, NULL));
|
cl_git_pass(git_reference_create(&ref, g_repo_a, "refs/foo/bar", &id, 1, NULL));
|
||||||
git_reference_free(ref);
|
git_reference_free(ref);
|
||||||
|
|
||||||
cl_git_pass(git_remote_connect(g_remote, GIT_DIRECTION_FETCH, NULL, NULL));
|
cl_git_pass(git_remote_connect(g_remote, GIT_DIRECTION_FETCH, NULL, NULL, NULL));
|
||||||
cl_git_fail_with(GIT_ENOTFOUND, git_remote_default_branch(&buf, g_remote));
|
cl_git_fail_with(GIT_ENOTFOUND, git_remote_default_branch(&buf, g_remote));
|
||||||
|
|
||||||
cl_git_pass(git_clone(&cloned_repo, git_repository_path(g_repo_a), "./local-detached", NULL));
|
cl_git_pass(git_clone(&cloned_repo, git_repository_path(g_repo_a), "./local-detached", NULL));
|
||||||
|
@ -40,7 +40,7 @@ static void connect_to_local_repository(const char *local_repository)
|
|||||||
git_buf_sets(&file_path_buf, cl_git_path_url(local_repository));
|
git_buf_sets(&file_path_buf, cl_git_path_url(local_repository));
|
||||||
|
|
||||||
cl_git_pass(git_remote_create_anonymous(&remote, repo, git_buf_cstr(&file_path_buf)));
|
cl_git_pass(git_remote_create_anonymous(&remote, repo, git_buf_cstr(&file_path_buf)));
|
||||||
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL));
|
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_network_remote_local__connected(void)
|
void test_network_remote_local__connected(void)
|
||||||
@ -214,7 +214,7 @@ void test_network_remote_local__push_to_bare_remote(void)
|
|||||||
|
|
||||||
/* Connect to the bare repo */
|
/* Connect to the bare repo */
|
||||||
cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localbare.git"));
|
cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localbare.git"));
|
||||||
cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL, NULL));
|
cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL, NULL, NULL));
|
||||||
|
|
||||||
/* Try to push */
|
/* Try to push */
|
||||||
cl_git_pass(git_remote_upload(localremote, &push_array, NULL));
|
cl_git_pass(git_remote_upload(localremote, &push_array, NULL));
|
||||||
@ -253,7 +253,7 @@ void test_network_remote_local__push_to_bare_remote_with_file_url(void)
|
|||||||
|
|
||||||
/* Connect to the bare repo */
|
/* Connect to the bare repo */
|
||||||
cl_git_pass(git_remote_create_anonymous(&localremote, repo, url));
|
cl_git_pass(git_remote_create_anonymous(&localremote, repo, url));
|
||||||
cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL, NULL));
|
cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL, NULL, NULL));
|
||||||
|
|
||||||
/* Try to push */
|
/* Try to push */
|
||||||
cl_git_pass(git_remote_upload(localremote, &push_array, NULL));
|
cl_git_pass(git_remote_upload(localremote, &push_array, NULL));
|
||||||
@ -290,7 +290,7 @@ void test_network_remote_local__push_to_non_bare_remote(void)
|
|||||||
|
|
||||||
/* Connect to the bare repo */
|
/* Connect to the bare repo */
|
||||||
cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localnonbare"));
|
cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localnonbare"));
|
||||||
cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL, NULL));
|
cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL, NULL, NULL));
|
||||||
|
|
||||||
/* Try to push */
|
/* Try to push */
|
||||||
cl_git_fail_with(GIT_EBAREREPO, git_remote_upload(localremote, &push_array, NULL));
|
cl_git_fail_with(GIT_EBAREREPO, git_remote_upload(localremote, &push_array, NULL));
|
||||||
|
@ -93,7 +93,7 @@ void test_network_remote_remotes__error_when_no_push_available(void)
|
|||||||
cl_git_pass(git_remote_create_anonymous(&r, _repo, cl_fixture("testrepo.git")));
|
cl_git_pass(git_remote_create_anonymous(&r, _repo, cl_fixture("testrepo.git")));
|
||||||
|
|
||||||
callbacks.transport = git_transport_local;
|
callbacks.transport = git_transport_local;
|
||||||
cl_git_pass(git_remote_connect(r, GIT_DIRECTION_PUSH, &callbacks, NULL));
|
cl_git_pass(git_remote_connect(r, GIT_DIRECTION_PUSH, &callbacks, NULL, NULL));
|
||||||
|
|
||||||
/* Make sure that push is really not available */
|
/* Make sure that push is really not available */
|
||||||
r->transport->push = NULL;
|
r->transport->push = NULL;
|
||||||
@ -359,7 +359,7 @@ void test_network_remote_remotes__can_load_with_an_empty_url(void)
|
|||||||
cl_assert(remote->url == NULL);
|
cl_assert(remote->url == NULL);
|
||||||
cl_assert(remote->pushurl == NULL);
|
cl_assert(remote->pushurl == NULL);
|
||||||
|
|
||||||
cl_git_fail(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL));
|
cl_git_fail(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL, NULL));
|
||||||
|
|
||||||
cl_assert(giterr_last() != NULL);
|
cl_assert(giterr_last() != NULL);
|
||||||
cl_assert(giterr_last()->klass == GITERR_INVALID);
|
cl_assert(giterr_last()->klass == GITERR_INVALID);
|
||||||
@ -376,7 +376,7 @@ void test_network_remote_remotes__can_load_with_only_an_empty_pushurl(void)
|
|||||||
cl_assert(remote->url == NULL);
|
cl_assert(remote->url == NULL);
|
||||||
cl_assert(remote->pushurl == NULL);
|
cl_assert(remote->pushurl == NULL);
|
||||||
|
|
||||||
cl_git_fail(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL));
|
cl_git_fail(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL, NULL));
|
||||||
|
|
||||||
git_remote_free(remote);
|
git_remote_free(remote);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,9 @@ static char *_remote_ssh_pubkey = NULL;
|
|||||||
static char *_remote_ssh_privkey = NULL;
|
static char *_remote_ssh_privkey = NULL;
|
||||||
static char *_remote_ssh_passphrase = NULL;
|
static char *_remote_ssh_passphrase = NULL;
|
||||||
static char *_remote_ssh_fingerprint = NULL;
|
static char *_remote_ssh_fingerprint = NULL;
|
||||||
|
static char *_remote_proxy_url = NULL;
|
||||||
|
static char *_remote_proxy_user = NULL;
|
||||||
|
static char *_remote_proxy_pass = NULL;
|
||||||
|
|
||||||
|
|
||||||
void test_online_clone__initialize(void)
|
void test_online_clone__initialize(void)
|
||||||
@ -46,6 +49,9 @@ void test_online_clone__initialize(void)
|
|||||||
_remote_ssh_privkey = cl_getenv("GITTEST_REMOTE_SSH_KEY");
|
_remote_ssh_privkey = cl_getenv("GITTEST_REMOTE_SSH_KEY");
|
||||||
_remote_ssh_passphrase = cl_getenv("GITTEST_REMOTE_SSH_PASSPHRASE");
|
_remote_ssh_passphrase = cl_getenv("GITTEST_REMOTE_SSH_PASSPHRASE");
|
||||||
_remote_ssh_fingerprint = cl_getenv("GITTEST_REMOTE_SSH_FINGERPRINT");
|
_remote_ssh_fingerprint = cl_getenv("GITTEST_REMOTE_SSH_FINGERPRINT");
|
||||||
|
_remote_proxy_url = cl_getenv("GITTEST_REMOTE_PROXY_URL");
|
||||||
|
_remote_proxy_user = cl_getenv("GITTEST_REMOTE_PROXY_USER");
|
||||||
|
_remote_proxy_pass = cl_getenv("GITTEST_REMOTE_PROXY_PASS");
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_online_clone__cleanup(void)
|
void test_online_clone__cleanup(void)
|
||||||
@ -63,6 +69,9 @@ void test_online_clone__cleanup(void)
|
|||||||
git__free(_remote_ssh_privkey);
|
git__free(_remote_ssh_privkey);
|
||||||
git__free(_remote_ssh_passphrase);
|
git__free(_remote_ssh_passphrase);
|
||||||
git__free(_remote_ssh_fingerprint);
|
git__free(_remote_ssh_fingerprint);
|
||||||
|
git__free(_remote_proxy_url);
|
||||||
|
git__free(_remote_proxy_user);
|
||||||
|
git__free(_remote_proxy_pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_online_clone__network_full(void)
|
void test_online_clone__network_full(void)
|
||||||
@ -653,3 +662,39 @@ void test_online_clone__start_with_http(void)
|
|||||||
|
|
||||||
cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
|
cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int called_proxy_creds;
|
||||||
|
static int proxy_creds(git_cred **out, const char *url, const char *username, unsigned int allowed, void *payload)
|
||||||
|
{
|
||||||
|
GIT_UNUSED(payload);
|
||||||
|
GIT_UNUSED(username);
|
||||||
|
|
||||||
|
called_proxy_creds = 1;
|
||||||
|
return git_cred_userpass_plaintext_new(out, _remote_proxy_user, _remote_proxy_pass);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_online_clone__proxy_credentials_request(void)
|
||||||
|
{
|
||||||
|
if (!_remote_proxy_url || !_remote_proxy_user || !_remote_proxy_pass)
|
||||||
|
cl_skip();
|
||||||
|
|
||||||
|
g_options.fetch_opts.proxy_opts.type = GIT_PROXY_HTTP;
|
||||||
|
g_options.fetch_opts.proxy_opts.url = _remote_proxy_url;
|
||||||
|
g_options.fetch_opts.proxy_opts.credentials = proxy_creds;
|
||||||
|
called_proxy_creds = 0;
|
||||||
|
cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
|
||||||
|
cl_assert(called_proxy_creds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_online_clone__proxy_credentials_in_url(void)
|
||||||
|
{
|
||||||
|
if (!_remote_proxy_url)
|
||||||
|
cl_skip();
|
||||||
|
|
||||||
|
g_options.fetch_opts.proxy_opts.type = GIT_PROXY_HTTP;
|
||||||
|
g_options.fetch_opts.proxy_opts.url = _remote_proxy_url;
|
||||||
|
g_options.fetch_opts.proxy_opts.credentials = proxy_creds;
|
||||||
|
called_proxy_creds = 0;
|
||||||
|
cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
|
||||||
|
cl_assert(called_proxy_creds == 0);
|
||||||
|
}
|
||||||
|
@ -81,11 +81,11 @@ void test_online_fetch__fetch_twice(void)
|
|||||||
{
|
{
|
||||||
git_remote *remote;
|
git_remote *remote;
|
||||||
cl_git_pass(git_remote_create(&remote, _repo, "test", "git://github.com/libgit2/TestGitRepository.git"));
|
cl_git_pass(git_remote_create(&remote, _repo, "test", "git://github.com/libgit2/TestGitRepository.git"));
|
||||||
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL));
|
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL, NULL));
|
||||||
cl_git_pass(git_remote_download(remote, NULL, NULL));
|
cl_git_pass(git_remote_download(remote, NULL, NULL));
|
||||||
git_remote_disconnect(remote);
|
git_remote_disconnect(remote);
|
||||||
|
|
||||||
git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL);
|
git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL, NULL);
|
||||||
cl_git_pass(git_remote_download(remote, NULL, NULL));
|
cl_git_pass(git_remote_download(remote, NULL, NULL));
|
||||||
git_remote_disconnect(remote);
|
git_remote_disconnect(remote);
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ void test_online_fetch__doesnt_retrieve_a_pack_when_the_repository_is_up_to_date
|
|||||||
cl_git_pass(git_repository_open(&_repository, "./fetch/lg2"));
|
cl_git_pass(git_repository_open(&_repository, "./fetch/lg2"));
|
||||||
|
|
||||||
cl_git_pass(git_remote_lookup(&remote, _repository, "origin"));
|
cl_git_pass(git_remote_lookup(&remote, _repository, "origin"));
|
||||||
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL));
|
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL, NULL));
|
||||||
|
|
||||||
cl_assert_equal_i(false, invoked);
|
cl_assert_equal_i(false, invoked);
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ void test_online_fetch__can_cancel(void)
|
|||||||
options.callbacks.transfer_progress = cancel_at_half;
|
options.callbacks.transfer_progress = cancel_at_half;
|
||||||
options.callbacks.payload = &bytes_received;
|
options.callbacks.payload = &bytes_received;
|
||||||
|
|
||||||
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL));
|
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL, NULL));
|
||||||
cl_git_fail_with(git_remote_download(remote, NULL, &options), -4321);
|
cl_git_fail_with(git_remote_download(remote, NULL, &options), -4321);
|
||||||
git_remote_disconnect(remote);
|
git_remote_disconnect(remote);
|
||||||
git_remote_free(remote);
|
git_remote_free(remote);
|
||||||
@ -169,7 +169,7 @@ void test_online_fetch__ls_disconnected(void)
|
|||||||
|
|
||||||
cl_git_pass(git_remote_create(&remote, _repo, "test",
|
cl_git_pass(git_remote_create(&remote, _repo, "test",
|
||||||
"http://github.com/libgit2/TestGitRepository.git"));
|
"http://github.com/libgit2/TestGitRepository.git"));
|
||||||
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL));
|
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL, NULL));
|
||||||
cl_git_pass(git_remote_ls(&refs, &refs_len_before, remote));
|
cl_git_pass(git_remote_ls(&refs, &refs_len_before, remote));
|
||||||
git_remote_disconnect(remote);
|
git_remote_disconnect(remote);
|
||||||
cl_git_pass(git_remote_ls(&refs, &refs_len_after, remote));
|
cl_git_pass(git_remote_ls(&refs, &refs_len_after, remote));
|
||||||
@ -187,7 +187,7 @@ void test_online_fetch__remote_symrefs(void)
|
|||||||
|
|
||||||
cl_git_pass(git_remote_create(&remote, _repo, "test",
|
cl_git_pass(git_remote_create(&remote, _repo, "test",
|
||||||
"http://github.com/libgit2/TestGitRepository.git"));
|
"http://github.com/libgit2/TestGitRepository.git"));
|
||||||
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL));
|
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL, NULL));
|
||||||
git_remote_disconnect(remote);
|
git_remote_disconnect(remote);
|
||||||
cl_git_pass(git_remote_ls(&refs, &refs_len, remote));
|
cl_git_pass(git_remote_ls(&refs, &refs_len, remote));
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ void test_online_push__initialize(void)
|
|||||||
|
|
||||||
record_callbacks_data_clear(&_record_cbs_data);
|
record_callbacks_data_clear(&_record_cbs_data);
|
||||||
|
|
||||||
cl_git_pass(git_remote_connect(_remote, GIT_DIRECTION_PUSH, &_record_cbs, NULL));
|
cl_git_pass(git_remote_connect(_remote, GIT_DIRECTION_PUSH, &_record_cbs, NULL, NULL));
|
||||||
|
|
||||||
/* Clean up previously pushed branches. Fails if receive.denyDeletes is
|
/* Clean up previously pushed branches. Fails if receive.denyDeletes is
|
||||||
* set on the remote. Also, on Git 1.7.0 and newer, you must run
|
* set on the remote. Also, on Git 1.7.0 and newer, you must run
|
||||||
|
Loading…
Reference in New Issue
Block a user