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

Function TestBasicAuthNoUsername

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

Source from the content-addressed store, hash-verified

901}
902
903func TestBasicAuthNoUsername(t *testing.T) {
904 cfg, _, err := LoadHTTPConfigFile("testdata/http.conf.basic-auth.no-username.yaml")
905 require.NoErrorf(t, err, "Error loading HTTP client config: %v", err)
906 client, err := NewClientFromConfig(*cfg, "test")
907 require.NoErrorf(t, err, "Error creating HTTP Client: %v", err)
908
909 rt, ok := client.Transport.(*basicAuthRoundTripper)
910 require.Truef(t, ok, "Error casting to basic auth transport, %v", client.Transport)
911
912 if rt.username != nil {
913 t.Errorf("Got unexpected username")
914 }
915 if password, _ := rt.password.Fetch(context.Background()); password != "secret" {
916 t.Errorf("Unexpected HTTP client password: %s", password)
917 }
918}
919
920func TestBasicAuthPasswordFile(t *testing.T) {
921 cfg, _, err := LoadHTTPConfigFile("testdata/http.conf.basic-auth.good.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…