return sendCoreError(ctx, http.StatusForbidden, fmt.Sprintf(errMsg, err))
}
- if err = im.validateInvoker(newInvoker, ctx); err != nil {
+ if err = im.validateInvoker(newInvoker); err != nil {
return sendCoreError(ctx, http.StatusBadRequest, fmt.Sprintf(errMsg, err))
}
defer im.lock.Unlock()
newInvoker.PrepareNewInvoker()
- im.addClientInKeycloak(newInvoker)
+
+ if im.keycloak != nil {
+ // The type assertion fails when unit testing from ServiceManager where we use Capif as a library, and we are not using Keycloak.
+ if _, ok := im.keycloak.(*keycloak.KeycloakManager); !ok {
+ // im.keycloak is not nil and its dynamic value is not nil.
+ im.addClientInKeycloak(newInvoker)
+ }
+ }
+
im.onboardedInvokers[*newInvoker.ApiInvokerId] = *newInvoker
}
return sendCoreError(ctx, http.StatusBadRequest, fmt.Sprintf(errMsg, errMismatch))
}
- if err := im.validateInvoker(newInvoker, ctx); err != nil {
+ if err := im.validateInvoker(newInvoker); err != nil {
return sendCoreError(ctx, http.StatusBadRequest, fmt.Sprintf(errMsg, err))
}
return ctx.NoContent(http.StatusNotImplemented)
}
-func (im *InvokerManager) validateInvoker(invoker invokerapi.APIInvokerEnrolmentDetails, ctx echo.Context) error {
+func (im *InvokerManager) validateInvoker(invoker invokerapi.APIInvokerEnrolmentDetails) error {
if err := invoker.Validate(); err != nil {
return err
}