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

Function TestBasicAuthNoPassword

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

Source from the content-addressed store, hash-verified

887}
888
889func TestBasicAuthNoPassword(t *testing.T) {
890 cfg, _, err := LoadHTTPConfigFile("testdata/http.conf.basic-auth.no-password.yaml")
891 require.NoErrorf(t, err, "Error loading HTTP client config: %v", err)
892 client, err := NewClientFromConfig(*cfg, "test")
893 require.NoErrorf(t, err, "Error creating HTTP Client: %v", err)
894
895 rt, ok := client.Transport.(*basicAuthRoundTripper)
896 require.Truef(t, ok, "Error casting to basic auth transport, %v", client.Transport)
897
898 username, _ := rt.username.Fetch(context.Background())
899 require.Equalf(t, "user", username, "Bad HTTP client username: %s", username)
900 require.Nilf(t, rt.password, "Expected empty HTTP client password")
901}
902
903func TestBasicAuthNoUsername(t *testing.T) {
904 cfg, _, err := LoadHTTPConfigFile("testdata/http.conf.basic-auth.no-username.yaml")

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…