MCPcopy Create free account
hub / github.com/prometheus/common / TestBasicAuthPasswordFile

Function TestBasicAuthPasswordFile

config/http_config_test.go:920–935  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

918}
919
920func TestBasicAuthPasswordFile(t *testing.T) {
921 cfg, _, err := LoadHTTPConfigFile("testdata/http.conf.basic-auth.good.yaml")
922 require.NoErrorf(t, err, "Error loading HTTP client config: %v", err)
923 client, err := NewClientFromConfig(*cfg, "test")
924 require.NoErrorf(t, err, "Error creating HTTP Client: %v", err)
925
926 rt, ok := client.Transport.(*basicAuthRoundTripper)
927 require.Truef(t, ok, "Error casting to basic auth transport, %v", client.Transport)
928
929 if username, _ := rt.username.Fetch(context.Background()); username != "user" {
930 t.Errorf("Bad HTTP client username: %s", username)
931 }
932 if password, _ := rt.password.Fetch(context.Background()); password != "foobar" {
933 t.Errorf("Bad HTTP client password: %s", password)
934 }
935}
936
937type secretManager struct {
938 data map[string]string

Callers

nothing calls this directly

Calls 3

LoadHTTPConfigFileFunction · 0.85
NewClientFromConfigFunction · 0.85
FetchMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…