2016-04-25 19:39:04 +00:00
|
|
|
package vault
|
|
|
|
|
|
|
|
import (
|
2018-01-19 06:44:44 +00:00
|
|
|
"context"
|
2016-04-25 19:39:04 +00:00
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestDefaultSeal_Config(t *testing.T) {
|
|
|
|
bc, _ := TestSealDefConfigs()
|
|
|
|
// Change these to non-default values to ensure we are seeing the real
|
|
|
|
// config we set
|
|
|
|
bc.SecretShares = 4
|
|
|
|
bc.SecretThreshold = 2
|
|
|
|
|
|
|
|
core, _, _ := TestCoreUnsealed(t)
|
|
|
|
|
|
|
|
defSeal := &DefaultSeal{}
|
|
|
|
defSeal.SetCore(core)
|
2018-01-19 06:44:44 +00:00
|
|
|
err := defSeal.SetBarrierConfig(context.Background(), bc)
|
2016-04-25 19:39:04 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2018-01-19 06:44:44 +00:00
|
|
|
newBc, err := defSeal.BarrierConfig(context.Background())
|
2016-04-25 19:39:04 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if !reflect.DeepEqual(*bc, *newBc) {
|
|
|
|
t.Fatal("config mismatch")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now, test without the benefit of the cached value in the seal
|
|
|
|
defSeal = &DefaultSeal{}
|
|
|
|
defSeal.SetCore(core)
|
2018-01-19 06:44:44 +00:00
|
|
|
newBc, err = defSeal.BarrierConfig(context.Background())
|
2016-04-25 19:39:04 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if !reflect.DeepEqual(*bc, *newBc) {
|
|
|
|
t.Fatal("config mismatch")
|
|
|
|
}
|
|
|
|
}
|