Files
threshold/sdk/wrapper/testing.go
T
Jim c8b29ded1c Events: Add outbound detail protobufs, request status code, and update event encrypt filter. (#1569)
* feat (events): Add status code to audit events

* feat (events): Add the resp proto msg to every audit event

* chore (events): Update eventlogger dep

This latest version will redact any map and/or map field which isn't
explicitly classified via a Taggable interface

* feat (events): Begin to add tagging to response proto msgs
2021-09-30 12:55:47 -04:00

34 lines
675 B
Go

package wrapper
import (
"crypto/rand"
"encoding/base64"
"testing"
wrapping "github.com/hashicorp/go-kms-wrapping"
"github.com/hashicorp/go-kms-wrapping/wrappers/aead"
)
// TestWrapper initializes an AEAD wrapping.Wrapper for testing
func TestWrapper(t *testing.T) wrapping.Wrapper {
rootKey := make([]byte, 32)
n, err := rand.Read(rootKey)
if err != nil {
t.Fatal(err)
}
if n != 32 {
t.Fatal(n)
}
root := aead.NewWrapper(nil)
_, err = root.SetConfig(map[string]string{
"key_id": base64.StdEncoding.EncodeToString(rootKey),
})
if err != nil {
t.Fatal(err)
}
if err := root.SetAESGCMKeyBytes(rootKey); err != nil {
t.Fatal(err)
}
return root
}