MCPcopy Index your code
hub / github.com/labstack/echo / TestStartConfig_StartTLS

Function TestStartConfig_StartTLS

server_test.go:242–321  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

240}
241
242func TestStartConfig_StartTLS(t *testing.T) {
243 var testCases = []struct {
244 name string
245 addr string
246 certFile string
247 keyFile string
248 expectError string
249 }{
250 {
251 name: "ok",
252 addr: ":0",
253 },
254 {
255 name: "nok, invalid certFile",
256 addr: ":0",
257 certFile: "not existing",
258 expectError: "open not existing: no such file or directory",
259 },
260 {
261 name: "nok, invalid keyFile",
262 addr: ":0",
263 keyFile: "not existing",
264 expectError: "open not existing: no such file or directory",
265 },
266 {
267 name: "nok, failed to create cert out of certFile and keyFile",
268 addr: ":0",
269 keyFile: "_fixture/certs/cert.pem", // we are passing cert instead of key
270 expectError: "tls: found a certificate rather than a key in the PEM for the private key",
271 },
272 {
273 name: "nok, invalid tls address",
274 addr: "nope",
275 expectError: "listen tcp: address nope: missing port in address",
276 },
277 }
278
279 for _, tc := range testCases {
280 t.Run(tc.name, func(t *testing.T) {
281 e := New()
282
283 addrChan := make(chan string)
284 errCh := make(chan error)
285
286 ctx, shutdown := stdContext.WithTimeout(stdContext.Background(), 200*time.Millisecond)
287 defer shutdown()
288 go func() {
289 certFile := "_fixture/certs/cert.pem"
290 if tc.certFile != "" {
291 certFile = tc.certFile
292 }
293 keyFile := "_fixture/certs/key.pem"
294 if tc.keyFile != "" {
295 keyFile = tc.keyFile
296 }
297
298 s := &StartConfig{
299 Address: tc.addr,

Callers

nothing calls this directly

Calls 5

StartTLSMethod · 0.95
NewFunction · 0.85
waitForServerStartFunction · 0.85
StringMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…