mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-04-28 11:30:15 +00:00
- Add persistent volume mounts for Go/npm caches (faster rebuilds) - Add shell config with helpful aliases and custom prompt - Add comprehensive devcontainer documentation - Add pre-commit hooks for Go formatting and linting - Use go-version-file in CI workflows instead of hardcoded versions - Simplify docker compose commands with --wait flag - Add gitignore entries for devcontainer auth files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestNewConfigPersistenceFailsWhenEncryptedDataPresentWithoutKey(t *testing.T) {
|
|
dir := t.TempDir()
|
|
|
|
// The crypto package tries to migrate keys from /etc/pulse/.encryption.key
|
|
// We need to temporarily rename it if it exists to properly test this scenario
|
|
systemKeyPath := "/etc/pulse/.encryption.key"
|
|
backupKeyPath := "/etc/pulse/.encryption.key.test-backup"
|
|
|
|
if _, err := os.Stat(systemKeyPath); err == nil {
|
|
// Key exists - temporarily rename it
|
|
if err := os.Rename(systemKeyPath, backupKeyPath); err != nil {
|
|
t.Skipf("cannot rename system encryption key for test isolation: %v", err)
|
|
}
|
|
t.Cleanup(func() {
|
|
// Restore the key after test
|
|
os.Rename(backupKeyPath, systemKeyPath)
|
|
})
|
|
}
|
|
|
|
// 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")
|
|
}
|
|
}
|