Files
Pulse/internal/api/auth_snapshot_linux_test.go
pulse-triage[bot] b3f74ac528 Publish browser authority from private owned snapshots
Session and CSRF saves must not follow or reuse stale predictable temporary paths. Create an exclusive owner-private regular file, check its complete write and close, atomically publish it, and clean only that attempt's temporary file on failure. Preserve detached locks, authority formats, encryption and startup recovery.

Retain real descriptor-I/O isolation and queued revocation proof without relying on FIFO publication. Exercise stale path types, linked storage, partial and failed writes, close/rename/cleanup errors, saved withdrawal and recovery.

Contract-Neutral: Existing API, agent and storage formats, grants, synchronous save boundaries and recovery contracts are unchanged. Only private auth snapshot publication mechanics change; the security-privacy contract and registered real-I/O proofs are updated together.
Change-source: pulse-maintainer
2026-11-15 15:05:39 +00:00

49 lines
1.3 KiB
Go

//go:build linux
package api
import (
"os"
"path/filepath"
"syscall"
"testing"
"time"
)
func TestAuthSnapshotPublicationIgnoresLegacyFIFO(t *testing.T) {
for _, kind := range []string{"sessions", "csrf"} {
t.Run(kind, func(t *testing.T) {
f := newAuthSnapshotFixture(t, kind)
legacy := filepath.Join(f.dir, f.name+".tmp")
if err := syscall.Mkfifo(legacy, 0600); err != nil {
t.Fatal(err)
}
done := make(chan struct{})
go func() { defer close(done); f.revoke() }()
select {
case <-done:
case <-time.After(2 * time.Second):
// Release a regressed writer without leaving a blocked goroutine.
// These small snapshots fit the FIFO buffer without a drainer.
reader, err := os.OpenFile(legacy, os.O_RDWR|syscall.O_NONBLOCK, 0)
if err != nil {
t.Fatal(err)
}
defer reader.Close()
select {
case <-done:
case <-time.After(5 * time.Second):
t.Fatal("regressed FIFO writer did not join")
}
t.Fatal("save opened an unowned FIFO instead of an exclusive regular file")
}
if info, err := os.Lstat(legacy); err != nil || info.Mode()&os.ModeNamedPipe == 0 {
t.Fatal("save changed or removed an unowned FIFO")
}
checkPrivateAuthSnapshot(t, f)
f.checkLive(t)
f.checkReload(t)
})
}
}