Fix askpass tests

This commit is contained in:
Tim Hockin 2019-12-30 15:13:41 -08:00
parent 0e422616a4
commit ece56840f8
2 changed files with 22 additions and 10 deletions

View File

@ -18,11 +18,11 @@ fi
# Askpass git only support repo started with "file://" which is used in test_e2e.sh. # Askpass git only support repo started with "file://" which is used in test_e2e.sh.
REPO=$(echo "$@" | grep -o "file://[^ ]*") REPO=$(echo "$@" | grep -o "file://[^ ]*")
OUTPUT=$(echo "url=${REPO}" | git credential fill) OUTPUT=$(echo "url=${REPO}" | git credential fill)
USERNAME=$(echo ${OUTPUT} | grep -o "username=.*") USERNAME=$(echo "${OUTPUT}" | grep "^username=.*")
PASSWD=$(echo ${OUTPUT} | grep -o "password=.*") PASSWD=$(echo "${OUTPUT}" | grep "^password=.*")
# Test case must match the magic username and password below. # Test case must match the magic username and password below.
if [ "${PASSWD}" != "password=Lov3!k0os" || "${USERNAME}" != "gitsync@example.com" ]; then if [ "${USERNAME}" != "username=my-username" -o "${PASSWD}" != "password=my-password" ]; then
echo "invalid username/password pair: ${USERNAME}:${PASSWD}, try gitsync@example.com:Lov3!k0os next time." echo "invalid test username/password pair: ${USERNAME}:${PASSWD}"
exit 1 exit 1
fi fi

View File

@ -641,8 +641,8 @@ git -C "$REPO" commit -qam "$TESTCASE 1"
# run with askpass_git but with wrong password # run with askpass_git but with wrong password
GIT_SYNC \ GIT_SYNC \
--git=$ASKPASS_GIT \ --git=$ASKPASS_GIT \
--username="gitsync@example.com" \ --username="my-username" \
--password="I have no idea what the password is." \ --password="wrong" \
--logtostderr \ --logtostderr \
--v=5 \ --v=5 \
--one-time \ --one-time \
@ -657,8 +657,8 @@ assert_file_absent "$ROOT"/link/file
# run with askpass_git with correct password # run with askpass_git with correct password
GIT_SYNC \ GIT_SYNC \
--git=$ASKPASS_GIT \ --git=$ASKPASS_GIT \
--username="gitsync@example.com" \ --username="my-username" \
--password="Lov3!k0os" \ --password="my-password" \
--logtostderr \ --logtostderr \
--v=5 \ --v=5 \
--one-time \ --one-time \
@ -682,7 +682,13 @@ echo "$TESTCASE 1" > "$REPO"/file
freencport freencport
git -C "$REPO" commit -qam "$TESTCASE 1" git -C "$REPO" commit -qam "$TESTCASE 1"
# run the askpass_url service with wrong password # run the askpass_url service with wrong password
{ (for i in 1 2; do echo -e 'HTTP/1.1 200 OK\r\n\r\nusername=you@example.com\npassword=dummypw' | nc -N -l $NCPORT > /dev/null; done) &} { (
for i in 1 2; do
echo -e 'HTTP/1.1 200 OK\r\n\r\nusername=my-username\npassword=wrong' \
| nc -N -l $NCPORT > /dev/null;
done
) &
}
GIT_SYNC \ GIT_SYNC \
--git=$ASKPASS_GIT \ --git=$ASKPASS_GIT \
--askpass-url="http://localhost:$NCPORT/git_askpass" \ --askpass-url="http://localhost:$NCPORT/git_askpass" \
@ -698,7 +704,13 @@ GIT_SYNC \
# check for failure # check for failure
assert_file_absent "$ROOT"/link/file assert_file_absent "$ROOT"/link/file
# run with askpass_url service with correct password # run with askpass_url service with correct password
{ (for i in 1 2; do echo -e 'HTTP/1.1 200 OK\r\n\r\nusername=you@example.com\npassword=Lov3!k0os' | nc -N -l $NCPORT > /dev/null; done) &} { (
for i in 1 2; do
echo -e 'HTTP/1.1 200 OK\r\n\r\nusername=my-username\npassword=my-password' \
| nc -N -l $NCPORT > /dev/null;
done
) &
}
GIT_SYNC \ GIT_SYNC \
--git=$ASKPASS_GIT \ --git=$ASKPASS_GIT \
--askpass-url="http://localhost:$NCPORT/git_askpass" \ --askpass-url="http://localhost:$NCPORT/git_askpass" \