Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions internal/x402/buyer/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1831,17 +1831,21 @@ func TestProxy_UpstreamSuccessWithSettlementHeader_DoesNotIncrementUnsettledMetr

func TestProxy_ConfirmSpendFailure_IncrementsMetric(t *testing.T) {
dir := t.TempDir()
stateDir := filepath.Join(dir, "state")
if err := os.MkdirAll(stateDir, 0o500); err != nil {
t.Fatalf("mkdir state dir: %v", err)
}
statePath := filepath.Join(stateDir, "consumed.json")
statePath := filepath.Join(dir, "consumed.json")

st, err := LoadStateStore(statePath)
if err != nil {
t.Fatalf("LoadStateStore: %v", err)
}

// Force StateStore.writeLocked to fail deterministically by pre-creating
// the target state path as a directory: os.Rename(tmpfile, dir) returns
// EISDIR, which root cannot bypass. The previous 0o500-dir approach was
// silently skipped under CAP_DAC_OVERRIDE when tests run as uid 0.
if err := os.Mkdir(statePath, 0o755); err != nil {
t.Fatalf("block state path: %v", err)
}

upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("X-Payment") == "" {
w.Header().Set("Content-Type", "application/json")
Expand Down
Loading