MCPcopy
hub / github.com/cloudflare/cloudflared / TestProxyMultipleOrigins

Function TestProxyMultipleOrigins

proxy/proxy_test.go:306–356  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

304}
305
306func TestProxyMultipleOrigins(t *testing.T) {
307 api := httptest.NewServer(mockAPI{})
308 defer api.Close()
309
310 unvalidatedIngress := []config.UnvalidatedIngressRule{
311 {
312 Hostname: "api.example.com",
313 Service: api.URL,
314 },
315 {
316 Hostname: "hello.example.com",
317 Service: "hello-world",
318 },
319 {
320 Hostname: "health.example.com",
321 Path: "/health",
322 Service: "http_status:200",
323 },
324 {
325 Hostname: "*",
326 Service: "http_status:404",
327 },
328 }
329
330 tests := []MultipleIngressTest{
331 {
332 url: "http://api.example.com",
333 expectedStatus: http.StatusCreated,
334 expectedBody: []byte("Created"),
335 },
336 {
337 url: fmt.Sprintf("http://hello.example.com%s", hello.HealthRoute),
338 expectedStatus: http.StatusOK,
339 expectedBody: []byte("ok"),
340 },
341 {
342 url: "http://health.example.com/health",
343 expectedStatus: http.StatusOK,
344 },
345 {
346 url: "http://health.example.com/",
347 expectedStatus: http.StatusNotFound,
348 },
349 {
350 url: "http://not-found.example.com",
351 expectedStatus: http.StatusNotFound,
352 },
353 }
354
355 runIngressTestScenarios(t, unvalidatedIngress, tests)
356}
357
358type MultipleIngressTest struct {
359 url string

Callers

nothing calls this directly

Calls 2

runIngressTestScenariosFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected