46
"$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/repo.git"
47
'
48
49
-test_expect_success 'setup askpass helpers' '
50
- cat >askpass <<-EOF &&
51
- #!/bin/sh
52
- echo >>"$PWD/askpass-query" "askpass: \$*" &&
53
- cat "$PWD/askpass-response"
54
- EOF
55
- chmod +x askpass &&
56
- GIT_ASKPASS="$PWD/askpass" &&
57
- export GIT_ASKPASS
58
-'
59
-
60
-expect_askpass() {
61
- dest=$HTTPD_DEST
62
- {
63
- case "$1" in
64
- none)
65
- ;;
66
- pass)
67
- echo "askpass: Password for 'http://$2@$dest': "
68
- ;;
69
- both)
70
- echo "askpass: Username for 'http://$dest': "
71
- echo "askpass: Password for 'http://$2@$dest': "
72
- ;;
73
- *)
74
- false
75
- ;;
76
- esac
77
- } >askpass-expect &&
78
- test_cmp askpass-expect askpass-query
79
-}
49
+setup_askpass_helper
50
51
test_expect_success 'cloning password-protected repository can fail' '
82
- >askpass-query &&
83
- echo wrong >askpass-response &&
52
+ set_askpass wrong &&
53
test_must_fail git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-fail &&
54
expect_askpass both wrong
55
'
56
57
test_expect_success 'http auth can use user/pass in URL' '
89
- >askpass-query &&
90
- echo wrong >askpass-response &&
58
+ set_askpass wrong &&
59
git clone "$HTTPD_URL_USER_PASS/auth/dumb/repo.git" clone-auth-none &&
60
expect_askpass none
61
'
62
63
test_expect_success 'http auth can use just user in URL' '
96
- >askpass-query &&
97
- echo user@host >askpass-response &&
64
+ set_askpass user@host &&
65
git clone "$HTTPD_URL_USER/auth/dumb/repo.git" clone-auth-pass &&
66
expect_askpass pass user@host
67
'
68
69
test_expect_success 'http auth can request both user and pass' '
103
- >askpass-query &&
104
- echo user@host >askpass-response &&
70
+ set_askpass user@host &&
71
git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-both &&
72
expect_askpass both user@host
73
'
78
echo username=user@host
79
echo password=user@host
80
}; f" &&
115
- >askpass-query &&
116
- echo wrong >askpass-response &&
81
+ set_askpass wrong &&
82
git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-helper &&
83
expect_askpass none
84
'
85
86
test_expect_success 'http auth can get username from config' '
87
test_config_global "credential.$HTTPD_URL.username" user@host &&
123
- >askpass-query &&
124
- echo user@host >askpass-response &&
88
+ set_askpass user@host &&
89
git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-user &&
90
expect_askpass pass user@host
91
'
92
93
test_expect_success 'configured username does not override URL' '
94
test_config_global "credential.$HTTPD_URL.username" wrong &&
131
- >askpass-query &&
132
- echo user@host >askpass-response &&
95
+ set_askpass user@host &&
96
git clone "$HTTPD_URL_USER/auth/dumb/repo.git" clone-auth-user2 &&
97
expect_askpass pass user@host
98
'