chore: add test
This commit is contained in:
parent
126b43a9b7
commit
489ae0006f
1 changed files with 27 additions and 0 deletions
|
@ -2109,3 +2109,30 @@ func TestCleanConf(t *testing.T) {
|
||||||
t.Errorf("cleanConf result don't match with expected: %s", diff)
|
t.Errorf("cleanConf result don't match with expected: %s", diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBuildCorsOriginRegex(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
allowCredentials string
|
||||||
|
allowedOrigins []string
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"true",
|
||||||
|
[]string{"*"},
|
||||||
|
"set $cors_origin $http_origin;\nset $cors 'true';",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"false",
|
||||||
|
[]string{"*"},
|
||||||
|
"set $cors_origin *;\nset $cors 'true';",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
actual := buildCorsOriginRegex(testCase.allowCredentials, testCase.allowedOrigins)
|
||||||
|
|
||||||
|
if testCase.expected != actual {
|
||||||
|
t.Errorf("CORS origin block not matching. Actual: '%s', Expected '%s'", actual, testCase.expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue