mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-04-30 04:20:20 +00:00
test: fix TestLoad_Errors to provide valid encryption key
Test was creating .enc files without a valid encryption key, which triggers the crypto safety check that prevents generating new keys when encrypted data exists.
This commit is contained in:
parent
d71b6bd756
commit
f2be9b60f0
1 changed files with 11 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
|
@ -56,6 +57,16 @@ func TestLoad_Errors(t *testing.T) {
|
|||
tempDir := t.TempDir()
|
||||
t.Setenv("PULSE_DATA_DIR", tempDir)
|
||||
|
||||
// First create encryption key so crypto doesn't fail when it sees .enc files
|
||||
// Key must be base64-encoded 32-byte value
|
||||
keyPath := filepath.Join(tempDir, ".encryption.key")
|
||||
key := make([]byte, 32)
|
||||
for i := range key {
|
||||
key[i] = byte(i) // Non-zero key
|
||||
}
|
||||
encoded := base64.StdEncoding.EncodeToString(key)
|
||||
require.NoError(t, os.WriteFile(keyPath, []byte(encoded), 0600))
|
||||
|
||||
// 1. Corrupted Nodes
|
||||
nodesPath := filepath.Join(tempDir, "nodes.enc")
|
||||
require.NoError(t, os.WriteFile(nodesPath, []byte("corrupted"), 0644))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue