From 4fcd4319dd5166fae195e6c048836eda19f59287 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 17 Jun 2026 02:24:06 +0000 Subject: [PATCH] test: make auth fetch test deterministic Co-authored-by: Ben Schellenberger --- internal/git/command_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/git/command_test.go b/internal/git/command_test.go index 26d9cc0..790adbf 100644 --- a/internal/git/command_test.go +++ b/internal/git/command_test.go @@ -1,6 +1,8 @@ package git import ( + "net/http" + "net/http/httptest" "os/exec" "strings" "testing" @@ -16,11 +18,17 @@ func TestFetchFailureReason_TerminalPromptsDisabled(t *testing.T) { } } -func TestNetworkFetch_UnauthenticatedHTTPSFailsWithoutPrompt(t *testing.T) { +func TestNetworkFetch_UnauthenticatedHTTPFailsWithoutPrompt(t *testing.T) { + authServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("WWW-Authenticate", `Basic realm="git-rain-test"`) + http.Error(w, "authentication required", http.StatusUnauthorized) + })) + defer authServer.Close() + repo := testutil.CreateTestRepo(t, testutil.RepoOptions{ Name: "https-fetch-repo", Remotes: map[string]string{ - "origin": "https://github.com/git-rain/nonexistent-repo-auth-test.git", + "origin": authServer.URL + "/private-repo.git", }, })