Skip to content

Commit 6ac2b3a

Browse files
peffgitster
authored andcommitted
t: test basic smart-http authentication
We do not currently test authentication over smart-http at all. In theory, it should work exactly as it does for dumb http (which we do test). It does indeed work for these simple tests, but this patch lays the groundwork for more complex tests in future patches. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 666aae9 commit 6ac2b3a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

t/t5541-http-push.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ test_expect_success 'setup remote repository' '
3636
mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
3737
'
3838

39+
setup_askpass_helper
40+
3941
cat >exp <<EOF
4042
GET /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
4143
POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200
@@ -266,5 +268,17 @@ test_expect_success 'http push respects GIT_COMMITTER_* in reflog' '
266268
test_cmp expect actual
267269
'
268270

271+
test_expect_success 'push over smart http with auth' '
272+
cd "$ROOT_PATH/test_repo_clone" &&
273+
echo push-auth-test >expect &&
274+
test_commit push-auth-test &&
275+
set_askpass user@host &&
276+
git push "$HTTPD_URL"/auth/smart/test_repo.git &&
277+
git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
278+
log -1 --format=%s >actual &&
279+
expect_askpass both user@host &&
280+
test_cmp expect actual
281+
'
282+
269283
stop_httpd
270284
test_done

t/t5551-http-fetch.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ test_expect_success 'create http-accessible bare repository' '
2727
git push public master:master
2828
'
2929

30+
setup_askpass_helper
31+
3032
cat >exp <<EOF
3133
> GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1
3234
> Accept: */*
@@ -109,6 +111,15 @@ test_expect_success 'follow redirects (302)' '
109111
git clone $HTTPD_URL/smart-redir-temp/repo.git --quiet repo-t
110112
'
111113

114+
test_expect_success 'clone from password-protected repository' '
115+
echo two >expect &&
116+
set_askpass user@host &&
117+
git clone --bare "$HTTPD_URL/auth/smart/repo.git" smart-auth &&
118+
expect_askpass both user@host &&
119+
git --git-dir=smart-auth log -1 --format=%s >actual &&
120+
test_cmp expect actual
121+
'
122+
112123
test -n "$GIT_TEST_LONG" && test_set_prereq EXPENSIVE
113124

114125
test_expect_success EXPENSIVE 'create 50,000 tags in the repo' '

0 commit comments

Comments
 (0)