(t *testing.T)
| 947 | } |
| 948 | |
| 949 | func TestBasicAuthSecretManager(t *testing.T) { |
| 950 | cfg, _, err := LoadHTTPConfigFile("testdata/http.conf.basic-auth.ref.yaml") |
| 951 | require.NoErrorf(t, err, "Error loading HTTP client config: %v", err) |
| 952 | manager := secretManager{ |
| 953 | data: map[string]string{ |
| 954 | "admin": "user", |
| 955 | "pass": "foobar", |
| 956 | }, |
| 957 | } |
| 958 | client, err := NewClientFromConfig(*cfg, "test", WithSecretManager(&manager)) |
| 959 | require.NoErrorf(t, err, "Error creating HTTP Client: %v", err) |
| 960 | |
| 961 | rt, ok := client.Transport.(*basicAuthRoundTripper) |
| 962 | require.Truef(t, ok, "Error casting to basic auth transport, %v", client.Transport) |
| 963 | |
| 964 | if username, _ := rt.username.Fetch(context.Background()); username != "user" { |
| 965 | t.Errorf("Bad HTTP client username: %s", username) |
| 966 | } |
| 967 | if password, _ := rt.password.Fetch(context.Background()); password != "foobar" { |
| 968 | t.Errorf("Bad HTTP client password: %s", password) |
| 969 | } |
| 970 | } |
| 971 | |
| 972 | func TestBasicAuthSecretManagerNotFound(t *testing.T) { |
| 973 | cfg, _, err := LoadHTTPConfigFile("testdata/http.conf.basic-auth.ref.yaml") |
nothing calls this directly
no test coverage detected
searching dependent graphs…