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

Function TestBasicAuthPasswordFile

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

Source from the content-addressed store, hash-verified

932}
933
934func TestBasicAuthPasswordFile(t *testing.T) {
935 cfg, _, err := LoadHTTPConfigFile("testdata/http.conf.basic-auth.good.yaml")
936 if err != nil {
937 t.Fatalf("Error loading HTTP client config: %v", err)
938 }
939 client, err := NewClientFromConfig(*cfg, "test")
940 if err != nil {
941 t.Fatalf("Error creating HTTP Client: %v", err)
942 }
943
944 rt, ok := client.Transport.(*basicAuthRoundTripper)
945 if !ok {
946 t.Fatalf("Error casting to basic auth transport, %v", client.Transport)
947 }
948
949 if rt.username != "user" {
950 t.Errorf("Bad HTTP client username: %s", rt.username)
951 }
952 if string(rt.password) != "" {
953 t.Errorf("Bad HTTP client password: %s", rt.password)
954 }
955 if string(rt.passwordFile) != "testdata/basic-auth-password" {
956 t.Errorf("Bad HTTP client passwordFile: %s", rt.passwordFile)
957 }
958}
959
960func TestBasicUsernameFile(t *testing.T) {
961 cfg, _, err := LoadHTTPConfigFile("testdata/http.conf.basic-auth.username-file.good.yaml")

Callers

nothing calls this directly

Calls 2

LoadHTTPConfigFileFunction · 0.85
NewClientFromConfigFunction · 0.85

Tested by

no test coverage detected