Fix gosec and tests

pull/900/head
Tom 2020-10-08 21:12:27 +01:00
parent 9269513917
commit bc3b69ccca
No known key found for this signature in database
GPG Key ID: D3E7EAA31B39637E
2 changed files with 8 additions and 3 deletions

View File

@ -191,7 +191,10 @@ func New(config ...Config) fiber.Handler {
}
// Store those bytes
cfg.Store.Set(key, buf.Bytes(), time.Duration(0))
err = cfg.Store.Set(key, buf.Bytes(), time.Duration(0))
if err != nil {
return err
}
} else {
sessions[key] = session
}

View File

@ -119,8 +119,10 @@ func Test_Limiter_Headers(t *testing.T) {
app.Handler()(fctx)
utils.AssertEqual(t, "50", string(fctx.Response.Header.Peek("X-RateLimit-Limit")))
utils.AssertEqual(t, "48", string(fctx.Response.Header.Peek("X-RateLimit-Remaining")))
if v := string(fctx.Response.Header.Peek("X-RateLimit-Reset")); v != "" {
t.Errorf("The X-RateLimit-Remaining header is not set correctly - value is an empty string.")
}
if v := string(fctx.Response.Header.Peek("X-RateLimit-Reset")); !(v == "1" || v == "2") {
t.Errorf("The X-RateLimit-Reset header is not set correctly - value is an empty string.")
t.Errorf("The X-RateLimit-Reset header is not set correctly - value is out of bounds.")
}
}