Test_CORS_SubdomainMatch() — fiber Function Reference
Architecture documentation for the Test_CORS_SubdomainMatch() function in utils_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 7cfeddb1_6278_a6f4_f8d8_934c90dc0f58["Test_CORS_SubdomainMatch()"] 31acac19_a947_56a9_0afe_d7291e6d45a1["utils_test.go"] 7cfeddb1_6278_a6f4_f8d8_934c90dc0f58 -->|defined in| 31acac19_a947_56a9_0afe_d7291e6d45a1 style 7cfeddb1_6278_a6f4_f8d8_934c90dc0f58 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/cors/utils_test.go lines 132–214
func Test_CORS_SubdomainMatch(t *testing.T) {
tests := []struct {
name string
sub subdomain
origin string
expected bool
}{
{
name: "match with different scheme",
sub: subdomain{prefix: "http://api.", suffix: "example.com"},
origin: "https://api.service.example.com",
expected: false,
},
{
name: "match with different scheme",
sub: subdomain{prefix: "https://", suffix: "example.com"},
origin: "http://api.service.example.com",
expected: false,
},
{
name: "match with valid subdomain",
sub: subdomain{prefix: "https://", suffix: "example.com"},
origin: "https://api.service.example.com",
expected: true,
},
{
name: "match with valid nested subdomain",
sub: subdomain{prefix: "https://", suffix: "example.com"},
origin: "https://1.2.api.service.example.com",
expected: true,
},
{
name: "no match with invalid prefix",
sub: subdomain{prefix: "https://abc.", suffix: "example.com"},
origin: "https://service.example.com",
expected: false,
},
{
name: "no match with invalid suffix",
sub: subdomain{prefix: "https://", suffix: "example.com"},
origin: "https://api.example.org",
expected: false,
},
{
name: "no match with empty origin",
sub: subdomain{prefix: "https://", suffix: "example.com"},
origin: "",
expected: false,
},
{
name: "no match with malformed subdomain",
sub: subdomain{prefix: "https://", suffix: "example.com"},
origin: "https://evil.comexample.com",
expected: false,
},
{
name: "partial match not considered a match",
sub: subdomain{prefix: "https://service.", suffix: "example.com"},
origin: "https://api.example.com",
expected: false,
},
{
name: "no match with empty host label",
sub: subdomain{prefix: "https://", suffix: "example.com"},
origin: "https://.example.com",
expected: false,
},
{
name: "no match with malformed host label",
sub: subdomain{prefix: "https://", suffix: "example.com"},
origin: "https://..example.com",
expected: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := tt.sub.match(tt.origin)
assert.Equal(t, tt.expected, got, "subdomain.match()")
})
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_CORS_SubdomainMatch() do?
Test_CORS_SubdomainMatch() is a function in the fiber codebase, defined in middleware/cors/utils_test.go.
Where is Test_CORS_SubdomainMatch() defined?
Test_CORS_SubdomainMatch() is defined in middleware/cors/utils_test.go at line 132.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free