mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-11-04 04:28:08 +00:00 
			
		
		
		
	api.NewClient() now uses $VAULT_NAMESPACE as an input. (#6470)
* api.NewClient() now uses $VAULT_NAMESPACE as an input. * Remove bogus comments.
This commit is contained in:
		@@ -422,6 +422,10 @@ func NewClient(c *Config) (*Client, error) {
 | 
				
			|||||||
		client.token = token
 | 
							client.token = token
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if namespace := os.Getenv(EnvVaultNamespace); namespace != "" {
 | 
				
			||||||
 | 
							client.SetNamespace(namespace)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return client, nil
 | 
						return client, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@ package api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
 | 
						"github.com/hashicorp/vault/helper/consts"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
@@ -195,6 +196,33 @@ func TestClientEnvSettings(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func TestClientEnvNamespace(t *testing.T) {
 | 
				
			||||||
 | 
						var seenNamespace string
 | 
				
			||||||
 | 
						handler := func(w http.ResponseWriter, req *http.Request) {
 | 
				
			||||||
 | 
							seenNamespace = req.Header.Get(consts.NamespaceHeaderName)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						config, ln := testHTTPServer(t, http.HandlerFunc(handler))
 | 
				
			||||||
 | 
						defer ln.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						oldVaultNamespace := os.Getenv(EnvVaultNamespace)
 | 
				
			||||||
 | 
						defer os.Setenv(EnvVaultNamespace, oldVaultNamespace)
 | 
				
			||||||
 | 
						os.Setenv(EnvVaultNamespace, "test")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						client, err := NewClient(config)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							t.Fatalf("err: %s", err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err = client.RawRequest(client.NewRequest("GET", "/"))
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							t.Fatalf("err: %s", err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if seenNamespace != "test" {
 | 
				
			||||||
 | 
							t.Fatalf("Bad: %s", seenNamespace)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestParsingRateAndBurst(t *testing.T) {
 | 
					func TestParsingRateAndBurst(t *testing.T) {
 | 
				
			||||||
	var (
 | 
						var (
 | 
				
			||||||
		correctFormat                    = "400:400"
 | 
							correctFormat                    = "400:400"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user