mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-04-28 11:30:15 +00:00
20 lines
551 B
Go
20 lines
551 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestNewConfigPersistenceFailsWhenEncryptedDataPresentWithoutKey(t *testing.T) {
|
|
dir := t.TempDir()
|
|
|
|
// Simulate existing encrypted data without providing the encryption key.
|
|
if err := os.WriteFile(filepath.Join(dir, "nodes.enc"), []byte("ciphertext"), 0600); err != nil {
|
|
t.Fatalf("failed to write simulated encrypted file: %v", err)
|
|
}
|
|
|
|
if _, err := newConfigPersistence(dir); err == nil {
|
|
t.Fatalf("expected error when initializing persistence without encryption key")
|
|
}
|
|
}
|