Merge pull request #549 from thockin/v3-better_askpass_url
V3: beef up askpass-url test
This commit is contained in:
commit
fa8815953a
|
|
@ -24,7 +24,7 @@ touch "${XDG_CONFIG_HOME}/git/config"
|
|||
# outside the e2e test environment. See https://git-scm.com/docs/git-credential-store
|
||||
touch "${XDG_CONFIG_HOME}/git/credentials"
|
||||
|
||||
if [ "$1" != "clone" ]; then
|
||||
if [ "$1" != "clone" -a "$1" != "ls-remote" -a "$1" != "fetch" ]; then
|
||||
git "$@"
|
||||
exit $?
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -414,14 +414,6 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
if *flAskPassURL != "" {
|
||||
if err := callGitAskPassURL(ctx, *flAskPassURL); err != nil {
|
||||
askpassCount.WithLabelValues(metricKeyError).Inc()
|
||||
handleError(false, "ERROR: failed to call ASKPASS callback URL: %v", err)
|
||||
}
|
||||
askpassCount.WithLabelValues(metricKeySuccess).Inc()
|
||||
}
|
||||
|
||||
// Set additional configs we want, but users might override.
|
||||
if err := setupDefaultGitConfigs(ctx); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: can't set default git configs: %v\n", err)
|
||||
|
|
|
|||
104
test_e2e.sh
104
test_e2e.sh
|
|
@ -915,13 +915,14 @@ function e2e::password_correct_password() {
|
|||
}
|
||||
|
||||
##############################################
|
||||
# Test askpass-url
|
||||
# Test askpass-url with bad password
|
||||
##############################################
|
||||
function e2e::askpass_url() {
|
||||
echo "$FUNCNAME 1" > "$REPO"/file
|
||||
git -C "$REPO" commit -qam "$FUNCNAME 1"
|
||||
function e2e::askpass_url_wrong_password() {
|
||||
# run the askpass-url service with wrong password
|
||||
HITLOG="$WORK/hitlog"
|
||||
cat /dev/null > "$HITLOG"
|
||||
CTR=$(docker_run \
|
||||
-v "$HITLOG":/var/log/hits \
|
||||
e2e/test/test-ncsvr \
|
||||
80 '
|
||||
echo "HTTP/1.1 200 OK"
|
||||
|
|
@ -943,10 +944,17 @@ function e2e::askpass_url() {
|
|||
>> "$1" 2>&1 || true
|
||||
# check for failure
|
||||
assert_file_absent "$ROOT"/link/file
|
||||
}
|
||||
|
||||
##############################################
|
||||
# Test askpass-url
|
||||
##############################################
|
||||
function e2e::askpass_url() {
|
||||
# run with askpass_url service with correct password
|
||||
docker_kill "$CTR"
|
||||
HITLOG="$WORK/hitlog"
|
||||
cat /dev/null > "$HITLOG"
|
||||
CTR=$(docker_run \
|
||||
-v "$HITLOG":/var/log/hits \
|
||||
e2e/test/test-ncsvr \
|
||||
80 '
|
||||
echo "HTTP/1.1 200 OK"
|
||||
|
|
@ -956,16 +964,98 @@ function e2e::askpass_url() {
|
|||
')
|
||||
IP=$(docker_ip "$CTR")
|
||||
|
||||
# First sync
|
||||
echo "$FUNCNAME 1" > "$REPO"/file
|
||||
git -C "$REPO" commit -qam "$FUNCNAME 1"
|
||||
|
||||
GIT_SYNC \
|
||||
--git="$ASKPASS_GIT" \
|
||||
--askpass-url="http://$IP/git_askpass" \
|
||||
--one-time \
|
||||
--wait=0.1 \
|
||||
--repo="file://$REPO" \
|
||||
--branch="$MAIN_BRANCH" \
|
||||
--rev=HEAD \
|
||||
--root="$ROOT" \
|
||||
--dest="link" \
|
||||
>> "$1" 2>&1
|
||||
>> "$1" 2>&1 &
|
||||
sleep 3
|
||||
assert_link_exists "$ROOT"/link
|
||||
assert_file_exists "$ROOT"/link/file
|
||||
assert_file_eq "$ROOT"/link/file "$FUNCNAME 1"
|
||||
|
||||
# Move HEAD forward
|
||||
echo "$FUNCNAME 2" > "$REPO"/file
|
||||
git -C "$REPO" commit -qam "$FUNCNAME 2"
|
||||
sleep 3
|
||||
assert_link_exists "$ROOT"/link
|
||||
assert_file_exists "$ROOT"/link/file
|
||||
assert_file_eq "$ROOT"/link/file "$FUNCNAME 2"
|
||||
|
||||
# Move HEAD backward
|
||||
git -C "$REPO" reset -q --hard HEAD^
|
||||
sleep 3
|
||||
assert_link_exists "$ROOT"/link
|
||||
assert_file_exists "$ROOT"/link/file
|
||||
assert_file_eq "$ROOT"/link/file "$FUNCNAME 1"
|
||||
}
|
||||
|
||||
##############################################
|
||||
# Test askpass-url where the URL is flaky
|
||||
##############################################
|
||||
function e2e::askpass_url_flaky() {
|
||||
# run with askpass_url service which alternates good/bad replies.
|
||||
HITLOG="$WORK/hitlog"
|
||||
cat /dev/null > "$HITLOG"
|
||||
CTR=$(docker_run \
|
||||
-v "$HITLOG":/var/log/hits \
|
||||
e2e/test/test-ncsvr \
|
||||
80 '
|
||||
echo "HTTP/1.1 200 OK"
|
||||
echo
|
||||
if [ -f /tmp/flag ]; then
|
||||
echo "username=my-username"
|
||||
echo "password=my-password"
|
||||
rm /tmp/flag
|
||||
else
|
||||
echo "username=my-username"
|
||||
echo "password=wrong"
|
||||
touch /tmp/flag
|
||||
fi
|
||||
')
|
||||
IP=$(docker_ip "$CTR")
|
||||
|
||||
# First sync
|
||||
echo "$FUNCNAME 1" > "$REPO"/file
|
||||
git -C "$REPO" commit -qam "$FUNCNAME 1"
|
||||
|
||||
GIT_SYNC \
|
||||
--git="$ASKPASS_GIT" \
|
||||
--askpass-url="http://$IP/git_askpass" \
|
||||
--max-sync-failures=2 \
|
||||
--wait=0.1 \
|
||||
--repo="file://$REPO" \
|
||||
--branch="$MAIN_BRANCH" \
|
||||
--rev=HEAD \
|
||||
--root="$ROOT" \
|
||||
--dest="link" \
|
||||
>> "$1" 2>&1 &
|
||||
sleep 3
|
||||
assert_link_exists "$ROOT"/link
|
||||
assert_file_exists "$ROOT"/link/file
|
||||
assert_file_eq "$ROOT"/link/file "$FUNCNAME 1"
|
||||
|
||||
# Move HEAD forward
|
||||
echo "$FUNCNAME 2" > "$REPO"/file
|
||||
git -C "$REPO" commit -qam "$FUNCNAME 2"
|
||||
sleep 3
|
||||
assert_link_exists "$ROOT"/link
|
||||
assert_file_exists "$ROOT"/link/file
|
||||
assert_file_eq "$ROOT"/link/file "$FUNCNAME 2"
|
||||
|
||||
# Move HEAD backward
|
||||
git -C "$REPO" reset -q --hard HEAD^
|
||||
sleep 3
|
||||
|
||||
assert_link_exists "$ROOT"/link
|
||||
assert_file_exists "$ROOT"/link/file
|
||||
assert_file_eq "$ROOT"/link/file "$FUNCNAME 1"
|
||||
|
|
|
|||
Loading…
Reference in New Issue