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

Function TestBasicAuthNoPassword

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

Source from the content-addressed store, hash-verified

880}
881
882func TestBasicAuthNoPassword(t *testing.T) {
883 cfg, _, err := LoadHTTPConfigFile("testdata/http.conf.basic-auth.no-password.yaml")
884 if err != nil {
885 t.Fatalf("Error loading HTTP client config: %v", err)
886 }
887 client, err := NewClientFromConfig(*cfg, "test")
888 if err != nil {
889 t.Fatalf("Error creating HTTP Client: %v", err)
890 }
891
892 rt, ok := client.Transport.(*basicAuthRoundTripper)
893 if !ok {
894 t.Fatalf("Error casting to basic auth transport, %v", client.Transport)
895 }
896
897 if rt.username != "user" {
898 t.Errorf("Bad HTTP client username: %s", rt.username)
899 }
900 if string(rt.password) != "" {
901 t.Errorf("Expected empty HTTP client password: %s", rt.password)
902 }
903 if string(rt.passwordFile) != "" {
904 t.Errorf("Expected empty HTTP client passwordFile: %s", rt.passwordFile)
905 }
906}
907
908func TestBasicAuthNoUsername(t *testing.T) {
909 cfg, _, err := LoadHTTPConfigFile("testdata/http.conf.basic-auth.no-username.yaml")

Callers

nothing calls this directly

Calls 2

LoadHTTPConfigFileFunction · 0.85
NewClientFromConfigFunction · 0.85

Tested by

no test coverage detected