Skip to content

Commit

Permalink
Merge pull request #278 from canonical/validation/disable
Browse files Browse the repository at this point in the history
validation/disable
  • Loading branch information
shipperizer authored Apr 17, 2024
2 parents 6cc4e95 + ae95fa8 commit 5031c7b
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pkg/clients/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (a *API) RegisterEndpoints(mux *chi.Mux) {
func (a *API) RegisterValidation(v validation.ValidationRegistryInterface) {
err := v.RegisterPayloadValidator(a.apiKey, a.payloadValidator)
if err != nil {
a.logger.Fatal("unexpected validatingFunc already registered for clients")
a.logger.Fatalf("unexpected validatingFunc already registered for clients, %s", err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/groups/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (a *API) RegisterEndpoints(mux *chi.Mux) {
func (a *API) RegisterValidation(v validation.ValidationRegistryInterface) {
err := v.RegisterPayloadValidator(a.apiKey, a.payloadValidator)
if err != nil {
a.logger.Fatal("unexpected validatingFunc already registered for groups")
a.logger.Fatalf("unexpected validatingFunc already registered for groups, %s", err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/groups/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,7 @@ func TestRegisterValidation(t *testing.T) {
// first registration of `apiKey` is successful
NewAPI(mockService, mockTracer, mockMonitor, mockLogger).RegisterValidation(mockValidationRegistry)

mockLogger.EXPECT().Fatal(gomock.Any()).Times(1)
mockLogger.EXPECT().Fatalf(gomock.Any(), gomock.Any()).Times(1)

// second registration of `apiKey` causes logger.Fatal invocation
NewAPI(mockService, mockTracer, mockMonitor, mockLogger).RegisterValidation(mockValidationRegistry)
Expand Down
2 changes: 1 addition & 1 deletion pkg/identities/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (a *API) RegisterValidation(v validation.ValidationRegistryInterface) {
err := v.RegisterPayloadValidator(a.apiKey, a.payloadValidator)

if err != nil {
a.logger.Fatal("unexpected PayloadValidator already registered for identities")
a.logger.Fatalf("unexpected validatingFunc already registered for identities, %s", err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/identities/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ func TestRegisterValidation(t *testing.T) {
// first registration of `apiKey` is successful
NewAPI(mockService, mockLogger).RegisterValidation(mockValidationRegistry)

mockLogger.EXPECT().Fatal(gomock.Any()).Times(1)
mockLogger.EXPECT().Fatalf(gomock.Any(), gomock.Any()).Times(1)

// second registration of `apiKey` causes logger.Fatal invocation
NewAPI(mockService, mockLogger).RegisterValidation(mockValidationRegistry)
Expand Down
2 changes: 1 addition & 1 deletion pkg/idp/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (a *API) RegisterEndpoints(mux *chi.Mux) {
func (a *API) RegisterValidation(v validation.ValidationRegistryInterface) {
err := v.RegisterPayloadValidator(a.apiKey, a.payloadValidator)
if err != nil {
a.logger.Fatal("unexpected validatingFunc already registered for idps")
a.logger.Fatalf("unexpected validatingFunc already registered for idps, %s", err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/roles/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (a *API) RegisterEndpoints(mux *chi.Mux) {
func (a *API) RegisterValidation(v validation.ValidationRegistryInterface) {
err := v.RegisterPayloadValidator("roles", a.payloadValidator)
if err != nil {
a.logger.Fatal("unexpected PayloadValidator already registered for roles")
a.logger.Fatalf("unexpected validatingFunc already registered for roles, %s", err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/rules/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (a *API) RegisterEndpoints(mux *chi.Mux) {
func (a *API) RegisterValidation(v validation.ValidationRegistryInterface) {
err := v.RegisterPayloadValidator(a.apiKey, a.payloadValidator)
if err != nil {
a.logger.Fatal("unexpected PayloadValidator already registered for rules")
a.logger.Fatalf("unexpected validatingFunc already registered for rules, %s", err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/schemas/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (a *API) RegisterEndpoints(mux *chi.Mux) {
func (a *API) RegisterValidation(v validation.ValidationRegistryInterface) {
err := v.RegisterPayloadValidator(a.apiKey, a.payloadValidator)
if err != nil {
a.logger.Fatal("unexpected validatingFunc already registered for schemas")
a.logger.Fatalf("unexpected validatingFunc already registered for schemas, %s", err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/schemas/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ func TestRegisterValidation(t *testing.T) {
// first registration of `apiKey` is successful
NewAPI(mockService, mockLogger).RegisterValidation(mockValidationRegistry)

mockLogger.EXPECT().Fatal(gomock.Any()).Times(1)
mockLogger.EXPECT().Fatalf(gomock.Any(), gomock.Any()).Times(1)

// second registration of `apiKey` causes logger.Fatal invocation
NewAPI(mockService, mockLogger).RegisterValidation(mockValidationRegistry)
Expand Down
14 changes: 7 additions & 7 deletions pkg/web/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,35 +69,35 @@ func NewRouter(idpConfig *idp.Config, schemasConfig *schemas.Config, rulesConfig
logger,
)
identitiesAPI.RegisterEndpoints(router)
identitiesAPI.RegisterValidation(vldtr)
// identitiesAPI.RegisterValidation(vldtr)

clientsAPI := clients.NewAPI(
clients.NewService(externalConfig.HydraAdmin(), tracer, monitor, logger),
logger,
)
clientsAPI.RegisterEndpoints(router)
clientsAPI.RegisterValidation(vldtr)
// clientsAPI.RegisterValidation(vldtr)

idpAPI := idp.NewAPI(
idp.NewService(idpConfig, tracer, monitor, logger),
logger,
)
idpAPI.RegisterEndpoints(router)
idpAPI.RegisterValidation(vldtr)
// idpAPI.RegisterValidation(vldtr)

schemasAPI := schemas.NewAPI(
schemas.NewService(schemasConfig, tracer, monitor, logger),
logger,
)
schemasAPI.RegisterEndpoints(router)
schemasAPI.RegisterValidation(vldtr)
// schemasAPI.RegisterValidation(vldtr)

rulesAPI := rules.NewAPI(
rules.NewService(rulesConfig, tracer, monitor, logger),
logger,
)
rulesAPI.RegisterEndpoints(router)
rulesAPI.RegisterValidation(vldtr)
// rulesAPI.RegisterValidation(vldtr)

rolesAPI := roles.NewAPI(
roles.NewService(externalConfig.OpenFGA(), wpool, tracer, monitor, logger),
Expand All @@ -106,7 +106,7 @@ func NewRouter(idpConfig *idp.Config, schemasConfig *schemas.Config, rulesConfig
logger,
)
rolesAPI.RegisterEndpoints(router)
rolesAPI.RegisterValidation(vldtr)
// rolesAPI.RegisterValidation(vldtr)

groupsAPI := groups.NewAPI(
groups.NewService(externalConfig.OpenFGA(), wpool, tracer, monitor, logger),
Expand All @@ -115,7 +115,7 @@ func NewRouter(idpConfig *idp.Config, schemasConfig *schemas.Config, rulesConfig
logger,
)
groupsAPI.RegisterEndpoints(router)
groupsAPI.RegisterValidation(vldtr)
// groupsAPI.RegisterValidation(vldtr)

return tracing.NewMiddleware(monitor, logger).OpenTelemetry(router)
}

0 comments on commit 5031c7b

Please sign in to comment.