open-nomad/client/fingerprint/vault_test.go

40 lines
1.1 KiB
Go
Raw Normal View History

2016-09-01 18:02:19 +00:00
package fingerprint
import (
"testing"
"github.com/hashicorp/nomad/client/config"
cstructs "github.com/hashicorp/nomad/client/structs"
2016-09-01 18:02:19 +00:00
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/testutil"
)
func TestVaultFingerprint(t *testing.T) {
2017-07-23 23:21:25 +00:00
tv := testutil.NewTestVault(t)
2016-09-01 18:02:19 +00:00
defer tv.Stop()
fp := NewVaultFingerprint(testLogger())
node := &structs.Node{
Attributes: make(map[string]string),
}
conf := config.DefaultConfig()
conf.VaultConfig = tv.Config
2016-09-01 18:02:19 +00:00
request := &cstructs.FingerprintRequest{Config: conf, Node: node}
var response cstructs.FingerprintResponse
err := fp.Fingerprint(request, &response)
2016-09-01 18:02:19 +00:00
if err != nil {
t.Fatalf("Failed to fingerprint: %s", err)
}
2018-01-31 22:03:55 +00:00
if !response.Detected {
t.Fatalf("expected response to be applicable")
}
assertNodeAttributeContains(t, response.Attributes, "vault.accessible")
assertNodeAttributeContains(t, response.Attributes, "vault.version")
assertNodeAttributeContains(t, response.Attributes, "vault.cluster_id")
assertNodeAttributeContains(t, response.Attributes, "vault.cluster_name")
2016-09-01 18:02:19 +00:00
}