MCPcopy Index your code
hub / github.com/prometheus/prometheus / TestNewHTTPBasicAuth

Function TestNewHTTPBasicAuth

scrape/target_test.go:192–215  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

190}
191
192func TestNewHTTPBasicAuth(t *testing.T) {
193 server := httptest.NewServer(
194 http.HandlerFunc(
195 func(_ http.ResponseWriter, r *http.Request) {
196 username, password, ok := r.BasicAuth()
197 require.True(t, ok, "Basic authorization header was not set correctly.")
198 require.Equal(t, "user", username)
199 require.Equal(t, "password123", password)
200 },
201 ),
202 )
203 defer server.Close()
204
205 cfg := config_util.HTTPClientConfig{
206 BasicAuth: &config_util.BasicAuth{
207 Username: "user",
208 Password: "password123",
209 },
210 }
211 c, err := config_util.NewClientFromConfig(cfg, "test")
212 require.NoError(t, err)
213 _, err = c.Get(server.URL)
214 require.NoError(t, err)
215}
216
217func TestNewHTTPCACert(t *testing.T) {
218 server := httptest.NewUnstartedServer(

Callers

nothing calls this directly

Calls 2

CloseMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…