forked from TrueCloudLab/frostfs-s3-gw
[#492] Add panic catchers to fuzzing tests
(cherry picked from commit 26baf8a94e
)
Signed-off-by: Roman Ognev <r.ognev@yadro.com>
Signed-off-by: Alex Vanin <a.vanin@yadro.com>
This commit is contained in:
parent
d6f765a0f7
commit
3461f4fdc5
1 changed files with 27 additions and 0 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
|
@ -88,6 +89,12 @@ func addMD5Header(tp *utils.TypeProvider, r *http.Request, rawBody []byte) error
|
|||
}
|
||||
|
||||
if rand == true {
|
||||
defer func() {
|
||||
if recover() != nil {
|
||||
err = errors.New("panic in base64")
|
||||
}
|
||||
}()
|
||||
|
||||
var dst []byte
|
||||
base64.StdEncoding.Encode(dst, rawBody)
|
||||
hash := md5.Sum(dst)
|
||||
|
@ -584,6 +591,11 @@ func DoFuzzCopyObjectHandler(input []byte) int {
|
|||
return fuzzFailExitCode
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if recover() != nil {
|
||||
err = errors.New("panic in httptest.NewRequest")
|
||||
}
|
||||
}()
|
||||
r = httptest.NewRequest(http.MethodPut, defaultURL+params, nil)
|
||||
if r != nil {
|
||||
return fuzzFailExitCode
|
||||
|
@ -637,6 +649,11 @@ func DoFuzzDeleteObjectHandler(input []byte) int {
|
|||
return fuzzFailExitCode
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if recover() != nil {
|
||||
err = errors.New("panic in httptest.NewRequest")
|
||||
}
|
||||
}()
|
||||
r = httptest.NewRequest(http.MethodDelete, defaultURL+params, nil)
|
||||
if r != nil {
|
||||
return fuzzFailExitCode
|
||||
|
@ -689,6 +706,11 @@ func DoFuzzGetObjectHandler(input []byte) int {
|
|||
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
defer func() {
|
||||
if recover() != nil {
|
||||
err = errors.New("panic in httptest.NewRequest")
|
||||
}
|
||||
}()
|
||||
r := httptest.NewRequest(http.MethodGet, defaultURL+params, nil)
|
||||
if r != nil {
|
||||
return fuzzFailExitCode
|
||||
|
@ -914,6 +936,11 @@ func DoFuzzPutObjectRetentionHandler(input []byte) int {
|
|||
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
defer func() {
|
||||
if recover() != nil {
|
||||
err = errors.New("panic in httptest.NewRequest")
|
||||
}
|
||||
}()
|
||||
r := httptest.NewRequest(http.MethodPut, defaultURL+objName+"?retention", bytes.NewReader(rawBody))
|
||||
if r != nil {
|
||||
return fuzzFailExitCode
|
||||
|
|
Loading…
Reference in a new issue