mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-02 10:09:02 +01:00
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
28 lines
705 B
Go
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)
|
|
}
|