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

[PATCH 3/5] t0300: make askpass tests a little more robust

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

Our fake askpass always just returned "askpass-result"; let's actually have it return a different fake value for usernames and passwords, to be sure values are getting routed correctly.

All tests should still pass.
Signed-off-by: Jeff King <peff@peff.net>
---
 t/t0300-credentials.sh |   77 ++++++++++++++++++++++++-----------------------
 1 files changed, 39 insertions(+), 38 deletions(-)
diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh
index 5d54976..09d5b15 100755
--- a/t/t0300-credentials.sh
+++ b/t/t0300-credentials.sh
@@ -52,7 +52,8 @@ test_expect_success 'setup helper scripts' '
 	cat >askpass <<-\EOF &&
 	#!/bin/sh
 	echo >&2 askpass: $*
-	echo askpass-result
+	what=`echo $1 | tr A-Z a-z | tr -cd a-z`
+	echo "askpass-$what"
 	EOF
 	chmod +x askpass &&
 	GIT_ASKPASS=askpass &&
@@ -155,8 +156,8 @@ test_expect_success 'do not bother completing already-full credential' '
 # askpass helper is run, we know the internal getpass is working.
 test_expect_success 'empty methods falls back to internal getpass' '
 	check <<-\EOF
-	username=askpass-result
-	password=askpass-result
+	username=askpass-username
+	password=askpass-password
 	--
 	askpass: Username:
 	askpass: Password:
@@ -166,7 +167,7 @@ test_expect_success 'empty methods falls back to internal getpass' '
 test_expect_success 'internal getpass does not ask for known username' '
 	check --username=foo <<-\EOF
 	username=foo
-	password=askpass-result
+	password=askpass-password
 	--
 	askpass: Password:
 	EOF
@@ -176,7 +177,7 @@ test_expect_success 'internal getpass can pull from config' '
 	git config credential.foo.username configured-username
 	check --unique=foo <<-\EOF
 	username=configured-username
-	password=askpass-result
+	password=askpass-password
 	--
 	askpass: Password:
 	EOF
@@ -185,15 +186,15 @@ test_expect_success 'internal getpass can pull from config' '
 test_expect_success 'credential-cache caches password' '
 	test_when_finished "git credential-cache --exit" &&
 	check --unique=host cache <<-\EOF &&
-	username=askpass-result
-	password=askpass-result
+	username=askpass-username
+	password=askpass-password
 	--
 	askpass: Username:
 	askpass: Password:
 	EOF
 	check --unique=host cache <<-\EOF
-	username=askpass-result
-	password=askpass-result
+	username=askpass-username
+	password=askpass-password
 	--
 	EOF
 '
@@ -201,15 +202,15 @@ test_expect_success 'credential-cache caches password' '
 test_expect_success 'credential-cache requires matching unique token' '
 	test_when_finished "git credential-cache --exit" &&
 	check --unique=host cache <<-\EOF &&
-	username=askpass-result
-	password=askpass-result
+	username=askpass-username
+	password=askpass-password
 	--
 	askpass: Username:
 	askpass: Password:
 	EOF
 	check --unique=host2 cache <<-\EOF
-	username=askpass-result
-	password=askpass-result
+	username=askpass-username
+	password=askpass-password
 	--
 	askpass: Username:
 	askpass: Password:
@@ -219,15 +220,15 @@ test_expect_success 'credential-cache requires matching unique token' '
 test_expect_success 'credential-cache requires matching usernames' '
 	test_when_finished "git credential-cache --exit" &&
 	check --unique=host cache <<-\EOF &&
-	username=askpass-result
-	password=askpass-result
+	username=askpass-username
+	password=askpass-password
 	--
 	askpass: Username:
 	askpass: Password:
 	EOF
 	check --unique=host --username=other cache <<-\EOF
 	username=other
-	password=askpass-result
+	password=askpass-password
 	--
 	askpass: Password:
 	EOF
@@ -236,16 +237,16 @@ test_expect_success 'credential-cache requires matching usernames' '
 test_expect_success 'credential-cache times out' '
 	test_when_finished "git credential-cache --exit || true" &&
 	check --unique=host "cache --timeout=1" <<-\EOF &&
-	username=askpass-result
-	password=askpass-result
+	username=askpass-username
+	password=askpass-password
 	--
 	askpass: Username:
 	askpass: Password:
 	EOF
 	sleep 2 &&
 	check --unique=host cache <<-\EOF
-	username=askpass-result
-	password=askpass-result
+	username=askpass-username
+	password=askpass-password
 	--
 	askpass: Username:
 	askpass: Password:
@@ -255,18 +256,18 @@ test_expect_success 'credential-cache times out' '
 test_expect_success 'credential-cache removes rejected credentials' '
 	test_when_finished "git credential-cache --exit || true" &&
 	check --unique=host cache <<-\EOF &&
-	username=askpass-result
-	password=askpass-result
+	username=askpass-username
+	password=askpass-password
 	--
 	askpass: Username:
 	askpass: Password:
 	EOF
-	check --reject --unique=host --username=askpass-result cache <<-\EOF &&
+	check --reject --unique=host --username=askpass-username cache <<-\EOF &&
 	--
 	EOF
 	check --unique=host cache <<-\EOF
-	username=askpass-result
-	password=askpass-result
+	username=askpass-username
+	password=askpass-password
 	--
 	askpass: Username:
 	askpass: Password:
@@ -276,15 +277,15 @@ test_expect_success 'credential-cache removes rejected credentials' '
 test_expect_success 'credential-store stores password' '
 	test_when_finished "rm -f .git-credentials" &&
 	check --unique=host store <<-\EOF &&
-	username=askpass-result
-	password=askpass-result
+	username=askpass-username
+	password=askpass-password
 	--
 	askpass: Username:
 	askpass: Password:
 	EOF
 	check --unique=host store <<-\EOF
-	username=askpass-result
-	password=askpass-result
+	username=askpass-username
+	password=askpass-password
 	--
 	EOF
 '
@@ -292,15 +293,15 @@ test_expect_success 'credential-store stores password' '
 test_expect_success 'credential-store requires matching unique token' '
 	test_when_finished "rm -f .git-credentials" &&
 	check --unique=host store <<-\EOF &&
-	username=askpass-result
-	password=askpass-result
+	username=askpass-username
+	password=askpass-password
 	--
 	askpass: Username:
 	askpass: Password:
 	EOF
 	check --unique=host2 store <<-\EOF
-	username=askpass-result
-	password=askpass-result
+	username=askpass-username
+	password=askpass-password
 	--
 	askpass: Username:
 	askpass: Password:
@@ -310,18 +311,18 @@ test_expect_success 'credential-store requires matching unique token' '
 test_expect_success 'credential-store removes rejected credentials' '
 	test_when_finished "rm -f .git-credentials" &&
 	check --unique=host store <<-\EOF &&
-	username=askpass-result
-	password=askpass-result
+	username=askpass-username
+	password=askpass-password
 	--
 	askpass: Username:
 	askpass: Password:
 	EOF
-	check --reject --unique=host --username=askpass-result store <<-\EOF &&
+	check --reject --unique=host --username=askpass-username store <<-\EOF &&
 	--
 	EOF
 	check --unique=host store <<-\EOF
-	username=askpass-result
-	password=askpass-result
+	username=askpass-username
+	password=askpass-password
 	--
 	askpass: Username:
 	askpass: Password:
-- 
1.7.6.252.ge9c18
Previous: Junio C HamanoNext: Jeff King
Message 9 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.