Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge branch 'jk/maint-push-over-dav' into next
Browse files Browse the repository at this point in the history
* jk/maint-push-over-dav:
  http-push: enable "proactive auth"
  t5540: test DAV push with authentication

Conflicts:
	http.c
  • Loading branch information
gitster committed Dec 14, 2011
2 parents 805c018 + a4ddbc3 commit 45e376c
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 5 deletions.
2 changes: 1 addition & 1 deletion http-fetch.c
Expand Up @@ -67,7 +67,7 @@ int main(int argc, const char **argv)


git_config(git_default_config, NULL); git_config(git_default_config, NULL);


http_init(NULL, url); http_init(NULL, url, 0);
walker = get_http_walker(url); walker = get_http_walker(url);
walker->get_tree = get_tree; walker->get_tree = get_tree;
walker->get_history = get_history; walker->get_history = get_history;
Expand Down
2 changes: 1 addition & 1 deletion http-push.c
Expand Up @@ -1820,7 +1820,7 @@ int main(int argc, char **argv)


memset(remote_dir_exists, -1, 256); memset(remote_dir_exists, -1, 256);


http_init(NULL, repo->url); http_init(NULL, repo->url, 1);


#ifdef USE_CURL_MULTI #ifdef USE_CURL_MULTI
is_running_queue = 0; is_running_queue = 0;
Expand Down
8 changes: 7 additions & 1 deletion http.c
Expand Up @@ -43,6 +43,7 @@ static int curl_ftp_no_epsv;
static const char *curl_http_proxy; static const char *curl_http_proxy;
static const char *curl_cookie_file; static const char *curl_cookie_file;
static struct credential http_auth = CREDENTIAL_INIT; static struct credential http_auth = CREDENTIAL_INIT;
static int http_proactive_auth;
static const char *user_agent; static const char *user_agent;


#if LIBCURL_VERSION_NUM >= 0x071700 #if LIBCURL_VERSION_NUM >= 0x071700
Expand Down Expand Up @@ -252,6 +253,9 @@ static CURL *get_curl_handle(void)
curl_easy_setopt(result, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_easy_setopt(result, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
#endif #endif


if (http_proactive_auth)
init_curl_http_auth(result);

if (ssl_cert != NULL) if (ssl_cert != NULL)
curl_easy_setopt(result, CURLOPT_SSLCERT, ssl_cert); curl_easy_setopt(result, CURLOPT_SSLCERT, ssl_cert);
if (has_cert_password()) if (has_cert_password())
Expand Down Expand Up @@ -304,7 +308,7 @@ static void set_from_env(const char **var, const char *envname)
*var = val; *var = val;
} }


void http_init(struct remote *remote, const char *url) void http_init(struct remote *remote, const char *url, int proactive_auth)
{ {
char *low_speed_limit; char *low_speed_limit;
char *low_speed_time; char *low_speed_time;
Expand All @@ -315,6 +319,8 @@ void http_init(struct remote *remote, const char *url)


curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);


http_proactive_auth = proactive_auth;

if (remote && remote->http_proxy) if (remote && remote->http_proxy)
curl_http_proxy = xstrdup(remote->http_proxy); curl_http_proxy = xstrdup(remote->http_proxy);


Expand Down
3 changes: 2 additions & 1 deletion http.h
Expand Up @@ -85,7 +85,8 @@ extern void add_fill_function(void *data, int (*fill)(void *));
extern void step_active_slots(void); extern void step_active_slots(void);
#endif #endif


extern void http_init(struct remote *remote, const char *url); extern void http_init(struct remote *remote, const char *url,
int proactive_auth);
extern void http_cleanup(void); extern void http_cleanup(void);


extern int active_requests; extern int active_requests;
Expand Down
2 changes: 1 addition & 1 deletion remote-curl.c
Expand Up @@ -859,7 +859,7 @@ int main(int argc, const char **argv)


url = strbuf_detach(&buf, NULL); url = strbuf_detach(&buf, NULL);


http_init(remote, url); http_init(remote, url, 0);


do { do {
if (strbuf_getline(&buf, stdin, '\n') == EOF) { if (strbuf_getline(&buf, stdin, '\n') == EOF) {
Expand Down
3 changes: 3 additions & 0 deletions t/lib-httpd/apache.conf
Expand Up @@ -92,6 +92,9 @@ SSLEngine On
<Location /dumb/> <Location /dumb/>
Dav on Dav on
</Location> </Location>
<Location /auth/dumb>
Dav on
</Location>
</IfDefine> </IfDefine>


<IfDefine SVN> <IfDefine SVN>
Expand Down
34 changes: 34 additions & 0 deletions t/t5540-http-push.sh
Expand Up @@ -40,6 +40,22 @@ test_expect_success 'setup remote repository' '
mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH" mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
' '


test_expect_success 'create password-protected repository' '
mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb" &&
cp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
"$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git"
'

test_expect_success 'setup askpass helper' '
cat >askpass <<-\EOF &&
#!/bin/sh
echo user@host
EOF
chmod +x askpass &&
GIT_ASKPASS="$PWD/askpass" &&
export GIT_ASKPASS
'

test_expect_success 'clone remote repository' ' test_expect_success 'clone remote repository' '
cd "$ROOT_PATH" && cd "$ROOT_PATH" &&
git clone $HTTPD_URL/dumb/test_repo.git test_repo_clone git clone $HTTPD_URL/dumb/test_repo.git test_repo_clone
Expand Down Expand Up @@ -144,6 +160,24 @@ test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \ test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
"$ROOT_PATH"/test_repo_clone master "$ROOT_PATH"/test_repo_clone master


test_expect_success 'push to password-protected repository (user in URL)' '
test_commit pw-user &&
git push "$HTTPD_URL_USER/auth/dumb/test_repo.git" HEAD &&
git rev-parse --verify HEAD >expect &&
git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \
rev-parse --verify HEAD >actual &&
test_cmp expect actual
'

test_expect_failure 'push to password-protected repository (no user in URL)' '
test_commit pw-nouser &&
git push "$HTTPD_URL/auth/dumb/test_repo.git" HEAD &&
git rev-parse --verify HEAD >expect &&
git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \
rev-parse --verify HEAD >actual &&
test_cmp expect actual
'

stop_httpd stop_httpd


test_done test_done

0 comments on commit 45e376c

Please sign in to comment.