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

Function TestBasicUsernameFile

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

Source from the content-addressed store, hash-verified

958}
959
960func TestBasicUsernameFile(t *testing.T) {
961 cfg, _, err := LoadHTTPConfigFile("testdata/http.conf.basic-auth.username-file.good.yaml")
962 if err != nil {
963 t.Fatalf("Error loading HTTP client config: %v", err)
964 }
965 client, err := NewClientFromConfig(*cfg, "test")
966 if err != nil {
967 t.Fatalf("Error creating HTTP Client: %v", err)
968 }
969
970 rt, ok := client.Transport.(*basicAuthRoundTripper)
971 if !ok {
972 t.Fatalf("Error casting to basic auth transport, %v", client.Transport)
973 }
974
975 if rt.username != "" {
976 t.Errorf("Bad HTTP client username: %s", rt.username)
977 }
978 if string(rt.usernameFile) != "testdata/basic-auth-username" {
979 t.Errorf("Bad HTTP client usernameFile: %s", rt.usernameFile)
980 }
981 if string(rt.passwordFile) != "testdata/basic-auth-password" {
982 t.Errorf("Bad HTTP client passwordFile: %s", rt.passwordFile)
983 }
984}
985
986func getCertificateBlobs(t *testing.T) map[string][]byte {
987 files := []string{

Callers

nothing calls this directly

Calls 2

LoadHTTPConfigFileFunction · 0.85
NewClientFromConfigFunction · 0.85

Tested by

no test coverage detected