From ece56840f8522088902ce1919ffd4580df38e2fb Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Mon, 30 Dec 2019 15:13:41 -0800 Subject: [PATCH] Fix askpass tests --- askpass_git.sh | 8 ++++---- test_e2e.sh | 24 ++++++++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/askpass_git.sh b/askpass_git.sh index 8558362..9cb2afd 100755 --- a/askpass_git.sh +++ b/askpass_git.sh @@ -18,11 +18,11 @@ fi # Askpass git only support repo started with "file://" which is used in test_e2e.sh. REPO=$(echo "$@" | grep -o "file://[^ ]*") OUTPUT=$(echo "url=${REPO}" | git credential fill) -USERNAME=$(echo ${OUTPUT} | grep -o "username=.*") -PASSWD=$(echo ${OUTPUT} | grep -o "password=.*") +USERNAME=$(echo "${OUTPUT}" | grep "^username=.*") +PASSWD=$(echo "${OUTPUT}" | grep "^password=.*") # Test case must match the magic username and password below. -if [ "${PASSWD}" != "password=Lov3!k0os" || "${USERNAME}" != "gitsync@example.com" ]; then - echo "invalid username/password pair: ${USERNAME}:${PASSWD}, try gitsync@example.com:Lov3!k0os next time." +if [ "${USERNAME}" != "username=my-username" -o "${PASSWD}" != "password=my-password" ]; then + echo "invalid test username/password pair: ${USERNAME}:${PASSWD}" exit 1 fi diff --git a/test_e2e.sh b/test_e2e.sh index 6178115..d4f351c 100755 --- a/test_e2e.sh +++ b/test_e2e.sh @@ -641,8 +641,8 @@ git -C "$REPO" commit -qam "$TESTCASE 1" # run with askpass_git but with wrong password GIT_SYNC \ --git=$ASKPASS_GIT \ - --username="gitsync@example.com" \ - --password="I have no idea what the password is." \ + --username="my-username" \ + --password="wrong" \ --logtostderr \ --v=5 \ --one-time \ @@ -657,8 +657,8 @@ assert_file_absent "$ROOT"/link/file # run with askpass_git with correct password GIT_SYNC \ --git=$ASKPASS_GIT \ - --username="gitsync@example.com" \ - --password="Lov3!k0os" \ + --username="my-username" \ + --password="my-password" \ --logtostderr \ --v=5 \ --one-time \ @@ -682,7 +682,13 @@ echo "$TESTCASE 1" > "$REPO"/file freencport git -C "$REPO" commit -qam "$TESTCASE 1" # 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=$ASKPASS_GIT \ --askpass-url="http://localhost:$NCPORT/git_askpass" \ @@ -698,7 +704,13 @@ GIT_SYNC \ # check for failure assert_file_absent "$ROOT"/link/file # 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=$ASKPASS_GIT \ --askpass-url="http://localhost:$NCPORT/git_askpass" \