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

Function TestTLSRoundTripper_Inline

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

Source from the content-addressed store, hash-verified

1155}
1156
1157func TestTLSRoundTripper_Inline(t *testing.T) {
1158 handler := func(w http.ResponseWriter, r *http.Request) {
1159 fmt.Fprint(w, ExpectedMessage)
1160 }
1161 testServer, err := newTestServer(handler)
1162 if err != nil {
1163 t.Fatal(err.Error())
1164 }
1165 defer testServer.Close()
1166
1167 testCases := []struct {
1168 caText, caFile string
1169 certText, certFile string
1170 keyText, keyFile string
1171
1172 errMsg string
1173 }{
1174 {
1175 // File-based everything.
1176 caFile: TLSCAChainPath,
1177 certFile: ClientCertificatePath,
1178 keyFile: ClientKeyNoPassPath,
1179 },
1180 {
1181 // Inline CA.
1182 caText: readFile(t, TLSCAChainPath),
1183 certFile: ClientCertificatePath,
1184 keyFile: ClientKeyNoPassPath,
1185 },
1186 {
1187 // Inline cert.
1188 caFile: TLSCAChainPath,
1189 certText: readFile(t, ClientCertificatePath),
1190 keyFile: ClientKeyNoPassPath,
1191 },
1192 {
1193 // Inline key.
1194 caFile: TLSCAChainPath,
1195 certFile: ClientCertificatePath,
1196 keyText: readFile(t, ClientKeyNoPassPath),
1197 },
1198 {
1199 // Inline everything.
1200 caText: readFile(t, TLSCAChainPath),
1201 certText: readFile(t, ClientCertificatePath),
1202 keyText: readFile(t, ClientKeyNoPassPath),
1203 },
1204
1205 {
1206 // Invalid inline CA.
1207 caText: "badca",
1208 certText: readFile(t, ClientCertificatePath),
1209 keyText: readFile(t, ClientKeyNoPassPath),
1210
1211 errMsg: "unable to use inline CA cert",
1212 },
1213 {
1214 // Invalid cert.

Callers

nothing calls this directly

Calls 6

newTestServerFunction · 0.85
readFileFunction · 0.85
SecretTypeAlias · 0.85
NewClientFromConfigFunction · 0.85
ErrorMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected