mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 05:40:11 +01:00
parent
5709b14650
commit
0848143a0b
7 changed files with 16 additions and 19 deletions
|
|
@ -49,10 +49,10 @@ func Test_downloadJSON(t *testing.T) {
|
|||
test := testToRun
|
||||
t.Run(test.name, func(tt *testing.T) {
|
||||
tt.Parallel()
|
||||
found := func(r io.Reader) error {
|
||||
found := func(_ io.Reader) error {
|
||||
return nil
|
||||
}
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.Header().Add("Content-Type", test.contentType)
|
||||
w.WriteHeader(test.statusCode)
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -24,12 +24,10 @@ import (
|
|||
func checkIfFileExists(path string, t *testing.T) bool {
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
return true
|
||||
} else if errors.Is(err, os.ErrNotExist) {
|
||||
return false
|
||||
} else {
|
||||
} else if !errors.Is(err, os.ErrNotExist) {
|
||||
t.Fatalf("Failed to check if file exists: %v", err)
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func TestShaMarking(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -224,12 +224,12 @@ func (f *forwarder) storeFailed(filename, doc, sha256, sha512 string) {
|
|||
|
||||
// limitedString reads max bytes from reader and returns it as a string.
|
||||
// Longer strings are indicated by "..." as a suffix.
|
||||
func limitedString(r io.Reader, max int) (string, error) {
|
||||
func limitedString(r io.Reader, maxLength int) (string, error) {
|
||||
var msg strings.Builder
|
||||
if _, err := io.Copy(&msg, io.LimitReader(r, int64(max))); err != nil {
|
||||
if _, err := io.Copy(&msg, io.LimitReader(r, int64(maxLength))); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if msg.Len() >= max {
|
||||
if msg.Len() >= maxLength {
|
||||
msg.WriteString("...")
|
||||
}
|
||||
return msg.String(), nil
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ func main() {
|
|||
|
||||
cfg, err := loadConfig()
|
||||
if err != nil {
|
||||
cgi.Serve(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||
cgi.Serve(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) {
|
||||
http.Error(rw, "Something went wrong. Check server logs for more details",
|
||||
http.StatusInternalServerError)
|
||||
}))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue