Fix broken tests due to fmt.Errf compile errors
This commit is contained in:
parent
11399e4113
commit
5d73098854
9
server/auth/external/register.go
vendored
9
server/auth/external/register.go
vendored
@ -205,11 +205,11 @@ func staticValidateExternal(opt options.AuthOpt) error {
|
|||||||
)
|
)
|
||||||
p, err := url.Parse(strings.Replace(opt.ExternalRedirectURL, "{provider}", tpt, 1))
|
p, err := url.Parse(strings.Replace(opt.ExternalRedirectURL, "{provider}", tpt, 1))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("invalid redirect URL", err)
|
return fmt.Errorf("invalid redirect URL: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.Contains(p.Path, tpt+"/callback") {
|
if !strings.Contains(p.Path, tpt+"/callback") {
|
||||||
return fmt.Errorf("could find injected provider in the URL, make sure you use '%%s' as a placeholder", err)
|
return fmt.Errorf("could find injected provider in the URL, make sure you use '%%s' as a placeholder: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if opt.ExternalCookieSecret == "" {
|
if opt.ExternalCookieSecret == "" {
|
||||||
@ -236,11 +236,14 @@ func validateExternalRedirectURL(opt options.AuthOpt) error {
|
|||||||
|
|
||||||
rsp, err := http.DefaultClient.Get(url)
|
rsp, err := http.DefaultClient.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not get response from redirect URL", err)
|
return fmt.Errorf("could not get response from redirect URL: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer rsp.Body.Close()
|
defer rsp.Body.Close()
|
||||||
body, err := ioutil.ReadAll(rsp.Body)
|
body, err := ioutil.ReadAll(rsp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("could not read response body: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
if strings.Contains(string(body), tpt) {
|
if strings.Contains(string(body), tpt) {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -89,7 +89,7 @@ func NewSamlSPService(log *zap.Logger, args SamlSPArgs) (s *SamlSPService, err e
|
|||||||
// internal samlsp service
|
// internal samlsp service
|
||||||
handler, err := samlsp.New(opts)
|
handler, err := samlsp.New(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("could not init SAML SP handler", err)
|
err = fmt.Errorf("could not init SAML SP handler: %w", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -164,12 +164,12 @@ func (s server) probeService(ctx context.Context, addr string) (err error) {
|
|||||||
func (s server) probeServiceURL(ctx context.Context, u *url.URL) error {
|
func (s server) probeServiceURL(ctx context.Context, u *url.URL) error {
|
||||||
req, err := http.NewRequest("GET", u.String(), nil)
|
req, err := http.NewRequest("GET", u.String(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to assemble service request", err)
|
return fmt.Errorf("failed to assemble service request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
rsp, err := http.DefaultClient.Do(req.WithContext(ctx))
|
rsp, err := http.DefaultClient.Do(req.WithContext(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("service URL request failed", err)
|
return fmt.Errorf("service URL request failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer rsp.Body.Close()
|
defer rsp.Body.Close()
|
||||||
|
|||||||
@ -4,9 +4,10 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/cortezaproject/corteza/server/pkg/eventbus"
|
"github.com/cortezaproject/corteza/server/pkg/eventbus"
|
||||||
"github.com/cortezaproject/corteza/server/pkg/slice"
|
"github.com/cortezaproject/corteza/server/pkg/slice"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -72,7 +73,7 @@ func triggerToHandlerOps(t *Trigger) (oo []eventbus.HandlerRegOp, err error) {
|
|||||||
func constraintsToHandlerOps(cc []*TConstraint) (oo []eventbus.HandlerRegOp, err error) {
|
func constraintsToHandlerOps(cc []*TConstraint) (oo []eventbus.HandlerRegOp, err error) {
|
||||||
for _, raw := range cc {
|
for _, raw := range cc {
|
||||||
if c, err := eventbus.ConstraintMaker(raw.Name, raw.Op, raw.Value...); err != nil {
|
if c, err := eventbus.ConstraintMaker(raw.Name, raw.Op, raw.Value...); err != nil {
|
||||||
return nil, fmt.Errorf("cannot generate constraints", err)
|
return nil, fmt.Errorf("cannot generate constraints: %w", err)
|
||||||
} else {
|
} else {
|
||||||
oo = append(oo, eventbus.Constraint(c))
|
oo = append(oo, eventbus.Constraint(c))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,7 +103,7 @@ func (c *Client) Request(method, url string, body interface{}) (*http.Request, e
|
|||||||
|
|
||||||
req, err := request()
|
req, err := request()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("creating request failed", err)
|
return nil, fmt.Errorf("creating request failed: %w", err)
|
||||||
}
|
}
|
||||||
req.Header.Add("Content-Type", "application/json")
|
req.Header.Add("Content-Type", "application/json")
|
||||||
return req, nil
|
return req, nil
|
||||||
@ -145,7 +145,7 @@ func (c *Client) Do(req *http.Request) (*http.Response, error) {
|
|||||||
if c.debugLevel == INFO {
|
if c.debugLevel == INFO {
|
||||||
fmt.Println("HTTP <<< Response error", err)
|
fmt.Println("HTTP <<< Response error", err)
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("request failed", err)
|
return nil, fmt.Errorf("request failed: %w", err)
|
||||||
}
|
}
|
||||||
if c.debugLevel == INFO {
|
if c.debugLevel == INFO {
|
||||||
fmt.Println("HTTP <<< Response", resp.StatusCode)
|
fmt.Println("HTTP <<< Response", resp.StatusCode)
|
||||||
|
|||||||
@ -290,7 +290,7 @@ func (svc attachment) processImage(original io.ReadSeeker, att *types.Attachment
|
|||||||
}
|
}
|
||||||
|
|
||||||
if format, err = imaging.FormatFromExtension(att.Meta.Original.Extension); err != nil {
|
if format, err = imaging.FormatFromExtension(att.Meta.Original.Extension); err != nil {
|
||||||
return fmt.Errorf("could not get format from extension '%s'", att.Meta.Original.Extension, err)
|
return fmt.Errorf("could not get format from extension '%s': %w", att.Meta.Original.Extension, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
previewFormat = format
|
previewFormat = format
|
||||||
@ -311,7 +311,7 @@ func (svc attachment) processImage(original io.ReadSeeker, att *types.Attachment
|
|||||||
// Use first image for the preview
|
// Use first image for the preview
|
||||||
preview = cfg.Image[0]
|
preview = cfg.Image[0]
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("could not decode gif config", err)
|
return fmt.Errorf("could not decode gif config: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -326,7 +326,7 @@ func (svc attachment) processImage(original io.ReadSeeker, att *types.Attachment
|
|||||||
// other cases are handled here
|
// other cases are handled here
|
||||||
if preview == nil {
|
if preview == nil {
|
||||||
if preview, err = imaging.Decode(original); err != nil {
|
if preview, err = imaging.Decode(original); err != nil {
|
||||||
return fmt.Errorf("could not decode original image", err)
|
return fmt.Errorf("could not decode original image: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user