Add backwards compat support for API env vars (#7135)

Several env vars got renamed in
https://github.com/hashicorp/vault/pull/6306. This re-adds support for
those.

Indirectly addresses
https://github.com/hashicorp/consul-template/pull/1233 although they
should still update to the new values.
This commit is contained in:
Jeff Mitchell
2019-07-17 06:29:25 -04:00
committed by GitHub
parent f9268b8d09
commit 61a1729264
2 changed files with 31 additions and 1 deletions

View File

@@ -2,12 +2,13 @@ package api
import (
"bytes"
"github.com/hashicorp/vault/sdk/helper/consts"
"io"
"net/http"
"os"
"strings"
"testing"
"github.com/hashicorp/vault/sdk/helper/consts"
)
func init() {
@@ -196,6 +197,22 @@ func TestClientEnvSettings(t *testing.T) {
}
}
func TestClientDeprecatedEnvSettings(t *testing.T) {
oldInsecure := os.Getenv(EnvVaultInsecure)
os.Setenv(EnvVaultInsecure, "true")
defer os.Setenv(EnvVaultInsecure, oldInsecure)
config := DefaultConfig()
if err := config.ReadEnvironment(); err != nil {
t.Fatalf("error reading environment: %v", err)
}
tlsConfig := config.HttpClient.Transport.(*http.Transport).TLSClientConfig
if tlsConfig.InsecureSkipVerify != true {
t.Fatalf("bad: %v", tlsConfig.InsecureSkipVerify)
}
}
func TestClientEnvNamespace(t *testing.T) {
var seenNamespace string
handler := func(w http.ResponseWriter, req *http.Request) {