Skip to content

Commit

Permalink
test: remove duplicate t.Parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
zepatrik committed Aug 10, 2023
1 parent 03291f7 commit 9e2061c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
7 changes: 3 additions & 4 deletions cmd/daemon/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,9 @@ func ServePublic(r driver.Registry, cmd *cobra.Command, _ []string, slOpts *serv
r.PrometheusManager().RegisterRouter(router.Router)

var handler http.Handler = n
options, enabled := r.Config().CORS(ctx, "public")
if enabled {
handler = cors.New(options).Handler(handler)
}
options, _ := r.Config().CORS(ctx, "public")
// we need to always load the CORS middleware to allow hot-enabling CORS
handler = cors.New(options).Handler(handler)

certs := c.GetTLSCertificatesForPublic(ctx)

Expand Down
5 changes: 5 additions & 0 deletions driver/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,11 @@ func (p *Config) cors(ctx context.Context, prefix string) (cors.Options, bool) {
AllowCredentials: true,
})
opts.AllowOriginRequestFunc = func(r *http.Request, origin string) bool {
// if cors is not enabled, return false
// this enables hot-reloading on every request
if !p.GetProvider(r.Context()).Bool(prefix + ".cors.enabled") {
return false
}
// load the origins from the config on every request to allow hot-reloading
allowedOrigins := p.GetProvider(r.Context()).Strings(prefix + ".cors.allowed_origins")
return corsx.CheckOrigin(allowedOrigins, origin)
Expand Down
2 changes: 0 additions & 2 deletions driver/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func TestViperProvider(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)
t.Parallel()

t.Run("suite=loaders", func(t *testing.T) {
p := config.MustNew(t, logrusx.New("", ""), os.Stderr,
Expand Down Expand Up @@ -810,7 +809,6 @@ func newTestConfig(t *testing.T) (_ *config.Config, _ *test.Hook, exited *bool)
func TestLoadingTLSConfig(t *testing.T) {
t.Parallel()
ctx := context.Background()
t.Parallel()

certPath, keyPath, certBase64, keyBase64 := testhelpers.GenerateTLSCertificateFilesForTests(t)

Expand Down

0 comments on commit 9e2061c

Please sign in to comment.