blob c0a47ce342b1b55c3cdfadb03719e7ddeafa150c 3690 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
| | #!/bin/sh
test_description='test http auth header and credential helper interop'
TEST_NO_CREATE_REPO=1
. ./test-lib.sh
test_set_port GIT_TEST_HTTP_PROTOCOL_PORT
# Setup a repository
#
REPO_DIR="$TRASH_DIRECTORY"/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="$TRASH_DIRECTORY"/pid-file.pid
SERVER_LOG="$TRASH_DIRECTORY"/OUT.server.log
PATH="$GIT_BUILD_DIR/t/helper/:$PATH" && export PATH
test_expect_success 'setup repos' '
test_create_repo "$REPO_DIR" &&
git -C "$REPO_DIR" branch -M main
'
run_http_server_worker() {
(
cd "$REPO_DIR"
test-http-server --worker "$@" 2>"$SERVER_LOG" | tr -d "\r"
)
}
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 IN.* &&
}
test_expect_success 'http auth server request parsing' '
test_when_finished "per_test_cleanup" &&
cat >auth.config <<-EOF &&
[auth]
allowAnonymous = true
EOF
echo "HTTP/1.1 400 Bad Request" >OUT.http400 &&
echo "HTTP/1.1 200 OK" >OUT.http200 &&
cat >IN.http.valid <<-EOF &&
GET /info/refs HTTP/1.1
Content-Length: 0
EOF
cat >IN.http.badfirstline <<-EOF &&
/info/refs GET HTTP
EOF
cat >IN.http.badhttpver <<-EOF &&
GET /info/refs HTTP/999.9
EOF
cat >IN.http.ltzlen <<-EOF &&
GET /info/refs HTTP/1.1
Content-Length: -1
EOF
cat >IN.http.badlen <<-EOF &&
GET /info/refs HTTP/1.1
Content-Length: not-a-number
EOF
cat >IN.http.overlen <<-EOF &&
GET /info/refs HTTP/1.1
Content-Length: 9223372036854775807
EOF
run_http_server_worker \
--auth-config="$TRASH_DIRECTORY/auth.config" <IN.http.valid \
| head -n1 >OUT.actual &&
test_cmp OUT.http200 OUT.actual &&
run_http_server_worker <IN.http.badfirstline | head -n1 >OUT.actual &&
test_cmp OUT.http400 OUT.actual &&
run_http_server_worker <IN.http.ltzlen | head -n1 >OUT.actual &&
test_cmp OUT.http400 OUT.actual &&
run_http_server_worker <IN.http.badlen | head -n1 >OUT.actual &&
test_cmp OUT.http400 OUT.actual &&
run_http_server_worker <IN.http.overlen | head -n1 >OUT.actual &&
test_cmp OUT.http400 OUT.actual
'
test_expect_success 'http auth anonymous no challenge' '
test_when_finished "per_test_cleanup" &&
start_http_server &&
# Attempt to read from a protected repository
git ls-remote $ORIGIN_URL
'
test_done
|
debug log:
solving c0a47ce342b ...
found c0a47ce342b in https://public-inbox.org/git/ca9c2787248688cd7d8e20043a6ed75d93654e35.1674252531.git.gitgitgadget@gmail.com/
found 06efc85ca53 in https://public-inbox.org/git/43f1cdcbb82022521558dc649213eb4538364870.1674252531.git.gitgitgadget@gmail.com/
applying [1/2] https://public-inbox.org/git/43f1cdcbb82022521558dc649213eb4538364870.1674252531.git.gitgitgadget@gmail.com/
diff --git a/t/t5556-http-auth.sh b/t/t5556-http-auth.sh
new file mode 100755
index 00000000000..06efc85ca53
applying [2/2] https://public-inbox.org/git/ca9c2787248688cd7d8e20043a6ed75d93654e35.1674252531.git.gitgitgadget@gmail.com/
diff --git a/t/t5556-http-auth.sh b/t/t5556-http-auth.sh
index 06efc85ca53..c0a47ce342b 100755
Checking patch t/t5556-http-auth.sh...
Applied patch t/t5556-http-auth.sh cleanly.
Checking patch t/t5556-http-auth.sh...
Applied patch t/t5556-http-auth.sh cleanly.
index at:
100755 c0a47ce342b1b55c3cdfadb03719e7ddeafa150c 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).