Files
Pulse/pkg/pulsecli/config_export_file_unix_test.go
pulse-triage[bot] 57d43f32e7 Preserve private CLI backups until export completes
Publish CLI configuration exports from an exclusively created owner-only file in the selected output directory, after full write, sync and close. Preserve the prior backup on every pre-publication error, report cleanup errors, refuse non-regular final destinations and do not rewrite another hard-linked file. Keep existing encrypted archives, stdout, flags and token/SSO authority unchanged; exercise fault paths and actual CLI recovery.

Contract-Neutral: Native CLI file publication only; command flags, encrypted archive and saved formats, authorization rules, routes, web responses and rendered states remain unchanged.
Change-source: pulse-maintainer
2026-11-11 02:30:20 +00:00

28 lines
705 B
Go

//go:build !windows
package pulsecli
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
"golang.org/x/sys/unix"
)
func TestConfigExportFileRejectsFIFO(t *testing.T) {
dir := t.TempDir()
path := filepath.Join(dir, "backup.enc")
require.NoError(t, unix.Mkfifo(path, 0o600))
// No opening the FIFO, hence no reader/writer rendezvous or timing race.
err := writeConfigExportFile(path, []byte("synthetic encrypted export"))
require.ErrorContains(t, err, "not a regular file")
info, err := os.Lstat(path)
require.NoError(t, err)
require.NotZero(t, info.Mode()&os.ModeNamedPipe)
entries, err := os.ReadDir(dir)
require.NoError(t, err)
require.Len(t, entries, 1)
}