mirror of
https://github.com/luxfi/cli.git
synced 2026-10-30 17:01:20 +00:00
- Add `lux snapshot` command with native BadgerDB backup API - Incremental backups (only changes since last backup) - ~96MB vs 5GB+ for raw file copies (160x smaller) - Zstd compression with manifest tracking - Add `lux snapshot clean` for disk cleanup - Removes old logs, stale runs, backup directories - Dry-run mode for preview - Update `lux network stop` to use incremental by default - --incremental (default: true) - --full flag to force full backup - --cleanup flag to clean logs on stop - Add key migration and session cache improvements - Secure memory locking (mlock) for sensitive data - Session-based key caching - Key migration tooling
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
// Copyright (C) 2022-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package key
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestSessionTimeout(t *testing.T) {
|
|
// Default session timeout is 30 seconds
|
|
assert.Equal(t, 30*time.Second, SessionTimeout)
|
|
}
|
|
|
|
func TestGetPasswordFromEnv(t *testing.T) {
|
|
t.Run("returns empty when not set", func(t *testing.T) {
|
|
_ = os.Unsetenv(EnvKeyPassword)
|
|
assert.Empty(t, GetPasswordFromEnv())
|
|
})
|
|
|
|
t.Run("returns value when set", func(t *testing.T) {
|
|
_ = os.Setenv(EnvKeyPassword, "testpassword")
|
|
defer func() { _ = os.Unsetenv(EnvKeyPassword) }()
|
|
|
|
assert.Equal(t, "testpassword", GetPasswordFromEnv())
|
|
})
|
|
}
|
|
|
|
func TestIsKeyLocked(t *testing.T) {
|
|
// Without a backend, keys should be considered locked
|
|
t.Run("returns true when no backend available", func(t *testing.T) {
|
|
// Clear backends for this test
|
|
backendMu.Lock()
|
|
oldBackends := backends
|
|
backends = make(map[BackendType]KeyBackend)
|
|
backendMu.Unlock()
|
|
|
|
defer func() {
|
|
backendMu.Lock()
|
|
backends = oldBackends
|
|
backendMu.Unlock()
|
|
}()
|
|
|
|
assert.True(t, IsKeyLocked("nonexistent"))
|
|
})
|
|
}
|