blob 541fa32bd772d534c5cd8f9b8af2f28ef2bc7488 5216 bytes (raw)
name: t/t5556-http-auth.sh # note: path name is non-authoritative(*)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
| | #!/bin/sh
test_description='test http auth header and credential helper interop'
. ./test-lib.sh
test_set_port GIT_TEST_HTTP_PROTOCOL_PORT
# Setup a repository
#
REPO_DIR="$(pwd)"/repo
# Setup some lookback URLs where test-http-server will be listening.
# We will spawn it directly inside the repo directory, so we avoid
# any need to configure directory mappings etc - we only serve this
# repository from the root '/' of the server.
#
HOST_PORT=127.0.0.1:$GIT_TEST_HTTP_PROTOCOL_PORT
ORIGIN_URL=http://$HOST_PORT/
# The pid-file is created by test-http-server when it starts.
# The server will shutdown if/when we delete it (this is easier than
# killing it by PID).
#
PID_FILE="$(pwd)"/pid-file.pid
SERVER_LOG="$(pwd)"/OUT.server.log
PATH="$GIT_BUILD_DIR/t/helper/:$PATH" && export PATH
CREDENTIAL_HELPER="$GIT_BUILD_DIR/t/helper/test-credential-helper-replay.sh" \
&& export CREDENTIAL_HELPER
test_expect_success 'setup repos' '
test_create_repo "$REPO_DIR" &&
git -C "$REPO_DIR" branch -M main
'
stop_http_server () {
if ! test -f "$PID_FILE"
then
return 0
fi
#
# The server will shutdown automatically when we delete the pid-file.
#
rm -f "$PID_FILE"
#
# Give it a few seconds to shutdown (mainly to completely release the
# port before the next test start another instance and it attempts to
# bind to it).
#
for k in 0 1 2 3 4
do
if grep -q "Starting graceful shutdown" "$SERVER_LOG"
then
return 0
fi
sleep 1
done
echo "stop_http_server: timeout waiting for server shutdown"
return 1
}
start_http_server () {
#
# Launch our server into the background in repo_dir.
#
(
cd "$REPO_DIR"
test-http-server --verbose \
--listen=127.0.0.1 \
--port=$GIT_TEST_HTTP_PROTOCOL_PORT \
--reuseaddr \
--pid-file="$PID_FILE" \
"$@" \
2>"$SERVER_LOG" &
)
#
# Give it a few seconds to get started.
#
for k in 0 1 2 3 4
do
if test -f "$PID_FILE"
then
return 0
fi
sleep 1
done
echo "start_http_server: timeout waiting for server startup"
return 1
}
per_test_cleanup () {
stop_http_server &&
rm -f OUT.* &&
rm -f *.cred
}
test_expect_success 'http auth anonymous no challenge' '
test_when_finished "per_test_cleanup" &&
start_http_server --allow-anonymous &&
# Attempt to read from a protected repository
git ls-remote $ORIGIN_URL
'
test_expect_success 'http auth www-auth headers to credential helper basic valid' '
test_when_finished "per_test_cleanup" &&
# base64("alice:secret-passwd")
USERPASS64=YWxpY2U6c2VjcmV0LXBhc3N3ZA== &&
export USERPASS64 &&
start_http_server \
--auth=basic:realm=\"example.com\" \
--auth-token=basic:$USERPASS64 &&
cat >get-expected.cred <<-EOF &&
protocol=http
host=$HOST_PORT
wwwauth[]=basic realm="example.com"
EOF
cat >store-expected.cred <<-EOF &&
protocol=http
host=$HOST_PORT
username=alice
password=secret-passwd
EOF
cat >get-response.cred <<-EOF &&
protocol=http
host=$HOST_PORT
username=alice
password=secret-passwd
EOF
git -c credential.helper="$CREDENTIAL_HELPER" ls-remote $ORIGIN_URL &&
test_cmp get-expected.cred get-actual.cred &&
test_cmp store-expected.cred store-actual.cred
'
test_expect_success 'http auth www-auth headers to credential helper custom schemes' '
test_when_finished "per_test_cleanup" &&
# base64("alice:secret-passwd")
USERPASS64=YWxpY2U6c2VjcmV0LXBhc3N3ZA== &&
export USERPASS64 &&
start_http_server \
--auth=foobar:alg=test\ widget=1 \
--auth=bearer:authority=\"id.example.com\"\ q=1\ p=0 \
--auth=basic:realm=\"example.com\" \
--auth-token=basic:$USERPASS64 &&
cat >get-expected.cred <<-EOF &&
protocol=http
host=$HOST_PORT
wwwauth[]=foobar alg=test widget=1
wwwauth[]=bearer authority="id.example.com" q=1 p=0
wwwauth[]=basic realm="example.com"
EOF
cat >store-expected.cred <<-EOF &&
protocol=http
host=$HOST_PORT
username=alice
password=secret-passwd
EOF
cat >get-response.cred <<-EOF &&
protocol=http
host=$HOST_PORT
username=alice
password=secret-passwd
EOF
git -c credential.helper="$CREDENTIAL_HELPER" ls-remote $ORIGIN_URL &&
test_cmp get-expected.cred get-actual.cred &&
test_cmp store-expected.cred store-actual.cred
'
test_expect_success 'http auth www-auth headers to credential helper invalid' '
test_when_finished "per_test_cleanup" &&
# base64("alice:secret-passwd")
USERPASS64=YWxpY2U6c2VjcmV0LXBhc3N3ZA== &&
export USERPASS64 &&
start_http_server \
--auth=bearer:authority=\"id.example.com\"\ q=1\ p=0 \
--auth=basic:realm=\"example.com\" \
--auth-token=basic:$USERPASS64 &&
cat >get-expected.cred <<-EOF &&
protocol=http
host=$HOST_PORT
wwwauth[]=bearer authority="id.example.com" q=1 p=0
wwwauth[]=basic realm="example.com"
EOF
cat >erase-expected.cred <<-EOF &&
protocol=http
host=$HOST_PORT
username=alice
password=invalid-passwd
wwwauth[]=bearer authority="id.example.com" q=1 p=0
wwwauth[]=basic realm="example.com"
EOF
cat >get-response.cred <<-EOF &&
protocol=http
host=$HOST_PORT
username=alice
password=invalid-passwd
EOF
test_must_fail git -c credential.helper="$CREDENTIAL_HELPER" ls-remote $ORIGIN_URL &&
test_cmp get-expected.cred get-actual.cred &&
test_cmp erase-expected.cred erase-actual.cred
'
test_done
|
debug log:
solving 541fa32bd77 ...
found 541fa32bd77 in https://public-inbox.org/git/8ecf63835229676677e3f7e33f634eb5d3a568b7.1670880984.git.gitgitgadget@gmail.com/
found 78da151f122 in https://public-inbox.org/git/5fb248c074acff1552874d98b28f746e1e43eac5.1667426970.git.gitgitgadget@gmail.com/ ||
https://public-inbox.org/git/0a0f4fd10c8b29f327c35dadc7b17881f22b253a.1670880984.git.gitgitgadget@gmail.com/
applying [1/2] https://public-inbox.org/git/5fb248c074acff1552874d98b28f746e1e43eac5.1667426970.git.gitgitgadget@gmail.com/
diff --git a/t/t5556-http-auth.sh b/t/t5556-http-auth.sh
new file mode 100755
index 00000000000..78da151f122
Checking patch t/t5556-http-auth.sh...
Applied patch t/t5556-http-auth.sh cleanly.
skipping https://public-inbox.org/git/0a0f4fd10c8b29f327c35dadc7b17881f22b253a.1670880984.git.gitgitgadget@gmail.com/ for 78da151f122
index at:
100755 78da151f122f464360ae5105d5164b9e34817234 t/t5556-http-auth.sh
applying [2/2] https://public-inbox.org/git/8ecf63835229676677e3f7e33f634eb5d3a568b7.1670880984.git.gitgitgadget@gmail.com/
diff --git a/t/t5556-http-auth.sh b/t/t5556-http-auth.sh
index 78da151f122..541fa32bd77 100755
Checking patch t/t5556-http-auth.sh...
Applied patch t/t5556-http-auth.sh cleanly.
index at:
100755 541fa32bd772d534c5cd8f9b8af2f28ef2bc7488 t/t5556-http-auth.sh
(*) Git path names are given by the tree(s) the blob belongs to.
Blobs themselves have no identifier aside from the hash of its contents.^
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).