Add plugin user-agent helper (#5039)

This commit is contained in:
Jim Kalafut
2018-08-06 09:02:04 -07:00
committed by GitHub
parent 463455aa03
commit 7fbdbe7d93
2 changed files with 44 additions and 0 deletions

View File

@@ -2,6 +2,8 @@ package useragent
import (
"testing"
"github.com/hashicorp/vault/logical"
)
func TestUserAgent(t *testing.T) {
@@ -16,3 +18,27 @@ func TestUserAgent(t *testing.T) {
t.Errorf("expected %q to be %q", act, exp)
}
}
func TestUserAgentPlugin(t *testing.T) {
projectURL = "https://vault-test.com"
rt = "go5.0"
env := &logical.PluginEnvironment{
VaultVersion: "1.2.3",
}
pluginName := "azure-auth"
act := PluginString(env, pluginName)
exp := "Vault/1.2.3 (+https://vault-test.com; azure-auth; go5.0)"
if exp != act {
t.Errorf("expected %q to be %q", act, exp)
}
pluginName = ""
act = PluginString(env, pluginName)
exp = "Vault/1.2.3 (+https://vault-test.com; go5.0)"
if exp != act {
t.Errorf("expected %q to be %q", act, exp)
}
}