open-vault/physical/etcd/etcd3_test.go

47 lines
1.1 KiB
Go
Raw Normal View History

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package etcd
2017-01-03 19:43:46 +00:00
import (
"fmt"
"testing"
"time"
log "github.com/hashicorp/go-hclog"
"github.com/hashicorp/vault/helper/testhelpers/etcd"
"github.com/hashicorp/vault/sdk/helper/logging"
"github.com/hashicorp/vault/sdk/physical"
2017-01-03 19:43:46 +00:00
)
func TestEtcd3Backend(t *testing.T) {
cleanup, config := etcd.PrepareTestContainer(t, "v3.5.0")
defer cleanup()
2017-01-03 19:43:46 +00:00
logger := logging.NewVaultLogger(log.Debug)
configMap := map[string]string{
"address": config.URL().String(),
2017-01-03 19:43:46 +00:00
"path": fmt.Sprintf("/vault-%d", time.Now().Unix()),
"etcd_api": "3",
"username": "root",
"password": "insecure",
// Syncing advertised client urls should be disabled since docker port mapping confuses the client.
"sync": "false",
2018-11-01 17:31:09 +00:00
}
b, err := NewEtcdBackend(configMap, logger)
2018-11-01 17:31:09 +00:00
if err != nil {
t.Fatalf("err: %s", err)
}
b2, err := NewEtcdBackend(configMap, logger)
2017-01-03 19:43:46 +00:00
if err != nil {
t.Fatalf("err: %s", err)
}
physical.ExerciseBackend(t, b)
physical.ExerciseBackend_ListPrefix(t, b)
2018-11-01 17:31:09 +00:00
physical.ExerciseHABackend(t, b.(physical.HABackend), b2.(physical.HABackend))
2017-01-03 19:43:46 +00:00
}