git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/5] t0300: make alternate username tests more robust

From
Jeff King <peff@peff.net>
Date
Sep 14, 2011, 19:18 UTC
Message-ID
<20110914191857.GD28267@sigill.intra.peff.net>
In-Reply-To
<20110914191704.GA23201@sigill.intra.peff.net>

One of the tests is to make sure that if we have a cached credential "user/pass", that we ignore it when asking for "--username=other", and instead get a new password. But since askpass returns only a single fake value, we couldn't differentiate between using the cached password and the new one.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/t0300-credentials.sh |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh
index 09d5b15..41ab8cc 100755
--- a/t/t0300-credentials.sh
+++ b/t/t0300-credentials.sh
@@ -53,7 +53,11 @@ test_expect_success 'setup helper scripts' '
 	#!/bin/sh
 	echo >&2 askpass: $*
 	what=`echo $1 | tr A-Z a-z | tr -cd a-z`
-	echo "askpass-$what"
+	if test -f "askpass-$what"; then
+		cat "askpass-$what"
+	else
+		echo "askpass-$what"
+	fi
 	EOF
 	chmod +x askpass &&
 	GIT_ASKPASS=askpass &&
@@ -226,9 +230,11 @@ test_expect_success 'credential-cache requires matching usernames' '
 	askpass: Username:
 	askpass: Password:
 	EOF
+	test_when_finished "rm -f askpass-password" &&
+	echo other-password >askpass-password &&
 	check --unique=host --username=other cache <<-\EOF
 	username=other
-	password=askpass-password
+	password=other-password
 	--
 	askpass: Password:
 	EOF
-- 
1.7.6.252.ge9c18
Previous: Jeff KingNext: Jeff King
Message 10 of 12 in “credential helper super fun pak”
  1. 0/5 credential helper super fun pakJeff King, Sep 14, 2011
  2. 1/5 docs: minor tweaks to credentials APIJeff King, Sep 14, 2011
  3. 2/5 credential-cache: fix expiration calculation corner casesJeff King, Sep 14, 2011
  4. Thomas RastSep 15, 2011
  5. 1/2 t0300: add missing EOF terminator for <<Thomas Rast, Sep 16, 2011
  6. 2/2 check_expirations: don't copy over same elementThomas Rast, Sep 16, 2011
  7. Jeff KingSep 16, 2011
  8. Junio C HamanoSep 18, 2011
  9. 3/5 t0300: make askpass tests a little more robustJeff King, Sep 14, 2011
  10. 4/5 t0300: make alternate username tests more robustJeff King, Sep 14, 2011
  11. 5/5 credential-store: use a better storage formatJeff King, Sep 14, 2011
  12. Junio C HamanoSep 14, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.