Author SHA1 Message Date
Nirav Patel 835d6705d6 test: preserve empty credential helper reset 2026-08-24 03:30:14 -04:00
+12 -12
View File
@@ -29,9 +29,11 @@ GIT_ENV = {
} }
def run_git(cwd, *args): def run_git(cwd, *args, strip=True):
return subprocess.run(["git", "-C", cwd] + list(args), check=True, stdout = subprocess.run(["git", "-C", cwd] + list(args), check=True,
capture_output=True, text=True, env=GIT_ENV).stdout.strip() capture_output=True, text=True,
env=GIT_ENV).stdout
return stdout.strip() if strip else stdout
@@ -905,15 +907,13 @@ class TestCredentialHelperIsolation(GitScenarioBase):
def test_install_leaves_exactly_one_helper(self): def test_install_leaves_exactly_one_helper(self):
run_git(self.local, "config", "--add", "credential.helper", "store") run_git(self.local, "config", "--add", "credential.helper", "store")
client.install_credential_helper(self.local) client.install_credential_helper(self.local)
# --get-all merges system + global + local, so entries inherited from # Inspect the repo-local list so this assertion is deterministic even
# the machine still appear. What matters is that the last two are the # when the machine has no inherited helper. Keep the leading newline:
# reset and ours: git reads an empty value as "forget every helper # it represents the empty reset value, not disposable whitespace.
# inherited so far", so nothing before it can answer. helpers = run_git(self.local, "config", "--local", "--get-all",
helpers = run_git(self.local, "config", "--get-all", "credential.helper", strip=False).splitlines()
"credential.helper").splitlines() self.assertEqual(helpers, ["", client.credential_helper_value()])
self.assertEqual(helpers[-2], "", helpers) # The repo-level 'store' this test added is gone, not merely outvoted.
self.assertIn("git-credential", helpers[-1])
# the repo-level 'store' this test added is gone, not merely outvoted
self.assertNotIn("store", helpers) self.assertNotIn("store", helpers)
def test_inherited_helper_cannot_answer_for_the_forge(self): def test_inherited_helper_cannot_answer_for_the_forge(self):