Home / Function/ Test_CORS_AllowOriginHeader_NoMatch() — fiber Function Reference

Test_CORS_AllowOriginHeader_NoMatch() — fiber Function Reference

Architecture documentation for the Test_CORS_AllowOriginHeader_NoMatch() function in cors_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  afa86ad9_4726_088a_58dc_52863010727c["Test_CORS_AllowOriginHeader_NoMatch()"]
  e59a43fd_cfa4_0f6b_1938_4a08e36ad74e["cors_test.go"]
  afa86ad9_4726_088a_58dc_52863010727c -->|defined in| e59a43fd_cfa4_0f6b_1938_4a08e36ad74e
  style afa86ad9_4726_088a_58dc_52863010727c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/cors/cors_test.go lines 538–565

func Test_CORS_AllowOriginHeader_NoMatch(t *testing.T) {
	t.Parallel()
	// New fiber instance
	app := fiber.New()
	app.Use("/", New(Config{
		AllowOrigins: []string{"http://example-1.com", "https://example-1.com"},
	}))

	// Get handler pointer
	handler := app.Handler()

	// Make request with disallowed origin
	ctx := &fasthttp.RequestCtx{}
	ctx.Request.SetRequestURI("/")
	ctx.Request.Header.SetMethod(fiber.MethodOptions)
	ctx.Request.Header.Set(fiber.HeaderOrigin, "http://google.com")

	// Perform request
	handler(ctx)

	var headerExists bool
	for key := range ctx.Response.Header.All() {
		if string(key) == fiber.HeaderAccessControlAllowOrigin {
			headerExists = true
		}
	}
	require.False(t, headerExists, "Access-Control-Allow-Origin header should not be set")
}

Domain

Subdomains

Frequently Asked Questions

What does Test_CORS_AllowOriginHeader_NoMatch() do?
Test_CORS_AllowOriginHeader_NoMatch() is a function in the fiber codebase, defined in middleware/cors/cors_test.go.
Where is Test_CORS_AllowOriginHeader_NoMatch() defined?
Test_CORS_AllowOriginHeader_NoMatch() is defined in middleware/cors/cors_test.go at line 538.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free