mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-11 17:17:01 +02:00
Add convergence tests to transit backend
This commit is contained in:
parent
bd682621e0
commit
4fd83816bf
@ -56,6 +56,19 @@ func TestBackend_upsert(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBackend_upsert_convergent(t *testing.T) {
|
||||||
|
decryptData := make(map[string]interface{})
|
||||||
|
logicaltest.Test(t, logicaltest.TestCase{
|
||||||
|
Factory: Factory,
|
||||||
|
Steps: []logicaltest.TestStep{
|
||||||
|
testAccStepReadPolicy(t, "test", true, false),
|
||||||
|
testAccStepEncryptUpsertConvergent(t, "test", testPlaintext, decryptData),
|
||||||
|
testAccStepReadPolicy(t, "test", false, false),
|
||||||
|
testAccStepDecrypt(t, "test", testPlaintext, decryptData),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestBackend_datakey(t *testing.T) {
|
func TestBackend_datakey(t *testing.T) {
|
||||||
dataKeyInfo := make(map[string]interface{})
|
dataKeyInfo := make(map[string]interface{})
|
||||||
logicaltest.Test(t, logicaltest.TestCase{
|
logicaltest.Test(t, logicaltest.TestCase{
|
||||||
@ -310,6 +323,30 @@ func testAccStepEncryptUpsert(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testAccStepEncryptUpsertConvergent(
|
||||||
|
t *testing.T, name, plaintext string, decryptData map[string]interface{}) logicaltest.TestStep {
|
||||||
|
return logicaltest.TestStep{
|
||||||
|
Operation: logical.CreateOperation,
|
||||||
|
Path: "encrypt/" + name,
|
||||||
|
Data: map[string]interface{}{
|
||||||
|
"plaintext": base64.StdEncoding.EncodeToString([]byte(plaintext)),
|
||||||
|
},
|
||||||
|
Check: func(resp *logical.Response) error {
|
||||||
|
var d struct {
|
||||||
|
Ciphertext string `mapstructure:"ciphertext"`
|
||||||
|
}
|
||||||
|
if err := mapstructure.Decode(resp.Data, &d); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if d.Ciphertext == "" {
|
||||||
|
return fmt.Errorf("missing ciphertext")
|
||||||
|
}
|
||||||
|
decryptData["ciphertext"] = d.Ciphertext
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func testAccStepEncryptContext(
|
func testAccStepEncryptContext(
|
||||||
t *testing.T, name, plaintext, context string, decryptData map[string]interface{}) logicaltest.TestStep {
|
t *testing.T, name, plaintext, context string, decryptData map[string]interface{}) logicaltest.TestStep {
|
||||||
return logicaltest.TestStep{
|
return logicaltest.TestStep{
|
||||||
|
Loading…
Reference in New Issue
Block a user