mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-17 03:57:01 +02:00
* Use version to determine plugin protocol to use * Remove field from ServeOpts * Fix missing assignment, handle errors * contraint -> constraint * Inject the version string from the vault side * Fix the version check * Add grpc support check to database plugins * Default to use grpc unless missing env var or fail on contraint check * Add GRPCSupport test * Add greater than test case * Add go-version dep
58 lines
676 B
Go
58 lines
676 B
Go
package pluginutil
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestGRPCSupport(t *testing.T) {
|
|
cases := []struct {
|
|
envVersion string
|
|
expected bool
|
|
}{
|
|
{
|
|
"0.8.3",
|
|
false,
|
|
},
|
|
{
|
|
"0.9.2",
|
|
true,
|
|
},
|
|
{
|
|
"0.9.2+ent",
|
|
true,
|
|
},
|
|
{
|
|
"0.9.2-beta",
|
|
false,
|
|
},
|
|
{
|
|
"0.9.3",
|
|
true,
|
|
},
|
|
{
|
|
"unknown",
|
|
true,
|
|
},
|
|
{
|
|
"",
|
|
false,
|
|
},
|
|
}
|
|
|
|
for _, tc := range cases {
|
|
t.Run(tc.envVersion, func(t *testing.T) {
|
|
err := os.Setenv(PluginVaultVersionEnv, tc.envVersion)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
result := GRPCSupport()
|
|
|
|
if result != tc.expected {
|
|
t.Fatalf("got: %t, expected: %t", result, tc.expected)
|
|
}
|
|
})
|
|
}
|
|
}
|