mirror of
https://github.com/cloudflare/redoctober.git
synced 2026-01-03 19:54:19 +00:00
This is a rather large change. It consists of the following changes: + Direct access to the keycache has been removed from the core package. This forces all interaction with the cache to go through the Cryptor, which is required for persistence. The Cryptor needs to know when the cache has changed, and the only way to do this effectively is to make the Cryptor responsible for managing the keycache. + A new persist package has been added. This provides a Store interface, for which two implementations are provided. The first is a null persister: this is used when no persistence is configured. The second is a file-backed persistence store. + The Cryptor now persists the cache every time it changes. Additionally, a number of missing returns in a function in the core package have been added.
27 lines
503 B
Go
27 lines
503 B
Go
package persist
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/cloudflare/redoctober/config"
|
|
)
|
|
|
|
func TestNew(t *testing.T) {
|
|
cfg := &config.Delegations{
|
|
Persist: true,
|
|
Policy: "policy",
|
|
Users: []string{"alice"},
|
|
Mechanism: FileMechanism,
|
|
Location: "testdata/store.bin",
|
|
}
|
|
|
|
store, err := New(cfg)
|
|
if err != nil {
|
|
t.Fatalf("persist: failed to create a new store: %s", err)
|
|
}
|
|
|
|
if _, ok := store.(*File); !ok {
|
|
t.Fatalf("persist: New should return a *File, but returned a %T", store)
|
|
}
|
|
}
|