github.com/bigcommerce/nomad@v0.9.3-bc/client/fingerprint/vault_test.go (about) 1 package fingerprint 2 3 import ( 4 "testing" 5 6 "github.com/hashicorp/nomad/client/config" 7 "github.com/hashicorp/nomad/helper/testlog" 8 "github.com/hashicorp/nomad/nomad/structs" 9 "github.com/hashicorp/nomad/testutil" 10 ) 11 12 func TestVaultFingerprint(t *testing.T) { 13 tv := testutil.NewTestVault(t) 14 defer tv.Stop() 15 16 fp := NewVaultFingerprint(testlog.HCLogger(t)) 17 node := &structs.Node{ 18 Attributes: make(map[string]string), 19 } 20 21 conf := config.DefaultConfig() 22 conf.VaultConfig = tv.Config 23 24 request := &FingerprintRequest{Config: conf, Node: node} 25 var response FingerprintResponse 26 err := fp.Fingerprint(request, &response) 27 if err != nil { 28 t.Fatalf("Failed to fingerprint: %s", err) 29 } 30 31 if !response.Detected { 32 t.Fatalf("expected response to be applicable") 33 } 34 35 assertNodeAttributeContains(t, response.Attributes, "vault.accessible") 36 assertNodeAttributeContains(t, response.Attributes, "vault.version") 37 assertNodeAttributeContains(t, response.Attributes, "vault.cluster_id") 38 assertNodeAttributeContains(t, response.Attributes, "vault.cluster_name") 39 }