Skip to content
This repository
Browse code

Merge branch 'jk/maint-push-over-dav' into next

* jk/maint-push-over-dav:
  http-push: enable "proactive auth"
  t5540: test DAV push with authentication

Conflicts:
	http.c
  • Loading branch information...
commit 45e376c184cc6857be89b9fc58e4949ed36ba5d4 2 parents 805c018 + a4ddbc3
Junio C Hamano gitster authored
2  http-fetch.c
@@ -67,7 +67,7 @@ int main(int argc, const char **argv)
67 67
68 68 git_config(git_default_config, NULL);
69 69
70   - http_init(NULL, url);
  70 + http_init(NULL, url, 0);
71 71 walker = get_http_walker(url);
72 72 walker->get_tree = get_tree;
73 73 walker->get_history = get_history;
2  http-push.c
@@ -1820,7 +1820,7 @@ int main(int argc, char **argv)
1820 1820
1821 1821 memset(remote_dir_exists, -1, 256);
1822 1822
1823   - http_init(NULL, repo->url);
  1823 + http_init(NULL, repo->url, 1);
1824 1824
1825 1825 #ifdef USE_CURL_MULTI
1826 1826 is_running_queue = 0;
8 http.c
@@ -43,6 +43,7 @@ static int curl_ftp_no_epsv;
43 43 static const char *curl_http_proxy;
44 44 static const char *curl_cookie_file;
45 45 static struct credential http_auth = CREDENTIAL_INIT;
  46 +static int http_proactive_auth;
46 47 static const char *user_agent;
47 48
48 49 #if LIBCURL_VERSION_NUM >= 0x071700
@@ -252,6 +253,9 @@ static CURL *get_curl_handle(void)
252 253 curl_easy_setopt(result, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
253 254 #endif
254 255
  256 + if (http_proactive_auth)
  257 + init_curl_http_auth(result);
  258 +
255 259 if (ssl_cert != NULL)
256 260 curl_easy_setopt(result, CURLOPT_SSLCERT, ssl_cert);
257 261 if (has_cert_password())
@@ -304,7 +308,7 @@ static void set_from_env(const char **var, const char *envname)
304 308 *var = val;
305 309 }
306 310
307   -void http_init(struct remote *remote, const char *url)
  311 +void http_init(struct remote *remote, const char *url, int proactive_auth)
308 312 {
309 313 char *low_speed_limit;
310 314 char *low_speed_time;
@@ -315,6 +319,8 @@ void http_init(struct remote *remote, const char *url)
315 319
316 320 curl_global_init(CURL_GLOBAL_ALL);
317 321
  322 + http_proactive_auth = proactive_auth;
  323 +
318 324 if (remote && remote->http_proxy)
319 325 curl_http_proxy = xstrdup(remote->http_proxy);
320 326
3  http.h
@@ -85,7 +85,8 @@ extern void add_fill_function(void *data, int (*fill)(void *));
85 85 extern void step_active_slots(void);
86 86 #endif
87 87
88   -extern void http_init(struct remote *remote, const char *url);
  88 +extern void http_init(struct remote *remote, const char *url,
  89 + int proactive_auth);
89 90 extern void http_cleanup(void);
90 91
91 92 extern int active_requests;
2  remote-curl.c
@@ -859,7 +859,7 @@ int main(int argc, const char **argv)
859 859
860 860 url = strbuf_detach(&buf, NULL);
861 861
862   - http_init(remote, url);
  862 + http_init(remote, url, 0);
863 863
864 864 do {
865 865 if (strbuf_getline(&buf, stdin, '\n') == EOF) {
3  t/lib-httpd/apache.conf
@@ -92,6 +92,9 @@ SSLEngine On
92 92 <Location /dumb/>
93 93 Dav on
94 94 </Location>
  95 + <Location /auth/dumb>
  96 + Dav on
  97 + </Location>
95 98 </IfDefine>
96 99
97 100 <IfDefine SVN>
34 t/t5540-http-push.sh
@@ -40,6 +40,22 @@ test_expect_success 'setup remote repository' '
40 40 mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
41 41 '
42 42
  43 +test_expect_success 'create password-protected repository' '
  44 + mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb" &&
  45 + cp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
  46 + "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git"
  47 +'
  48 +
  49 +test_expect_success 'setup askpass helper' '
  50 + cat >askpass <<-\EOF &&
  51 + #!/bin/sh
  52 + echo user@host
  53 + EOF
  54 + chmod +x askpass &&
  55 + GIT_ASKPASS="$PWD/askpass" &&
  56 + export GIT_ASKPASS
  57 +'
  58 +
43 59 test_expect_success 'clone remote repository' '
44 60 cd "$ROOT_PATH" &&
45 61 git clone $HTTPD_URL/dumb/test_repo.git test_repo_clone
@@ -144,6 +160,24 @@ test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
144 160 test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
145 161 "$ROOT_PATH"/test_repo_clone master
146 162
  163 +test_expect_success 'push to password-protected repository (user in URL)' '
  164 + test_commit pw-user &&
  165 + git push "$HTTPD_URL_USER/auth/dumb/test_repo.git" HEAD &&
  166 + git rev-parse --verify HEAD >expect &&
  167 + git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \
  168 + rev-parse --verify HEAD >actual &&
  169 + test_cmp expect actual
  170 +'
  171 +
  172 +test_expect_failure 'push to password-protected repository (no user in URL)' '
  173 + test_commit pw-nouser &&
  174 + git push "$HTTPD_URL/auth/dumb/test_repo.git" HEAD &&
  175 + git rev-parse --verify HEAD >expect &&
  176 + git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \
  177 + rev-parse --verify HEAD >actual &&
  178 + test_cmp expect actual
  179 +'
  180 +
147 181 stop_httpd
148 182
149 183 test_done

0 comments on commit 45e376c

Please sign in to comment.
Something went wrong with that request. Please try again.