Skip to content

Commit

Permalink
Test for invalid regex
Browse files Browse the repository at this point in the history
  • Loading branch information
z4kn4fein committed Oct 11, 2023
1 parent 29230df commit 6517013
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,22 @@ http:
assert.Equal(t, `.*\.example1\.com`, conf.Http.Sse.CORS.AllowedOriginsRegex.Patterns[0])
assert.Equal(t, `.*\.example2\.com`, conf.Http.Sse.CORS.AllowedOriginsRegex.Patterns[1])
assert.Equal(t, "https://example1.com", conf.Http.Sse.CORS.AllowedOriginsRegex.IfNoMatch)
})
}

func TestCORSConfigInvalidRegex_YAML(t *testing.T) {
utils.UseTempFile(`
http:
sse:
cors:
enabled: true
allowed_origins_regex:
patterns:
- "*"
if_no_match: https://example1.com
`, func(file string) {
_, err := LoadConfigFromFileAndEnvironment(file)
require.ErrorContains(t, err, "error parsing regexp: missing argument to repetition operator: `*`")
})
}

Expand Down

0 comments on commit 6517013

Please sign in to comment.