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

Function TestNewClientFromConfig

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

Source from the content-addressed store, hash-verified

172}
173
174func TestNewClientFromConfig(t *testing.T) {
175 newClientValidConfig := []struct {
176 clientConfig HTTPClientConfig
177 handler func(w http.ResponseWriter, r *http.Request)
178 }{
179 {
180 clientConfig: HTTPClientConfig{
181 TLSConfig: TLSConfig{
182 CAFile: "",
183 CertFile: ClientCertificatePath,
184 KeyFile: ClientKeyNoPassPath,
185 ServerName: "",
186 InsecureSkipVerify: true,
187 },
188 },
189 handler: func(w http.ResponseWriter, _ *http.Request) {
190 fmt.Fprint(w, ExpectedMessage)
191 },
192 },
193 {
194 clientConfig: HTTPClientConfig{
195 TLSConfig: TLSConfig{
196 CAFile: TLSCAChainPath,
197 CertFile: ClientCertificatePath,
198 KeyFile: ClientKeyNoPassPath,
199 ServerName: "",
200 InsecureSkipVerify: false,
201 },
202 },
203 handler: func(w http.ResponseWriter, _ *http.Request) {
204 fmt.Fprint(w, ExpectedMessage)
205 },
206 },
207 {
208 clientConfig: HTTPClientConfig{
209 BearerToken: BearerToken,
210 TLSConfig: TLSConfig{
211 CAFile: TLSCAChainPath,
212 CertFile: ClientCertificatePath,
213 KeyFile: ClientKeyNoPassPath,
214 ServerName: "",
215 InsecureSkipVerify: false,
216 },
217 },
218 handler: func(w http.ResponseWriter, r *http.Request) {
219 bearer := r.Header.Get("Authorization")
220 if bearer != ExpectedBearer {
221 fmt.Fprintf(w, "The expected Bearer Authorization (%s) differs from the obtained Bearer Authorization (%s)",
222 ExpectedBearer, bearer)
223 } else {
224 fmt.Fprint(w, ExpectedMessage)
225 }
226 },
227 },
228 {
229 clientConfig: HTTPClientConfig{
230 BearerTokenFile: BearerTokenFile,
231 TLSConfig: TLSConfig{

Callers

nothing calls this directly

Calls 7

newTestServerFunction · 0.85
NewClientFromConfigFunction · 0.85
GetMethod · 0.80
AddMethod · 0.80
CloseMethod · 0.65
SetMethod · 0.45
ValidateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…