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

Function TestBasicUsernameFile

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

Source from the content-addressed store, hash-verified

993}
994
995func TestBasicUsernameFile(t *testing.T) {
996 cfg, _, err := LoadHTTPConfigFile("testdata/http.conf.basic-auth.username-file.good.yaml")
997 require.NoErrorf(t, err, "Error loading HTTP client config: %v", err)
998 client, err := NewClientFromConfig(*cfg, "test")
999 require.NoErrorf(t, err, "Error creating HTTP Client: %v", err)
1000
1001 rt, ok := client.Transport.(*basicAuthRoundTripper)
1002 require.Truef(t, ok, "Error casting to basic auth transport, %v", client.Transport)
1003
1004 if username, _ := rt.username.Fetch(context.Background()); username != "testuser" {
1005 t.Errorf("Bad HTTP client username: %s", username)
1006 }
1007 if password, _ := rt.password.Fetch(context.Background()); password != "foobar" {
1008 t.Errorf("Bad HTTP client passwordFile: %s", password)
1009 }
1010}
1011
1012func getCertificateBlobs(t *testing.T) map[string][]byte {
1013 files := []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…