Check input schema (#33)

This commit is contained in:
Jonas Plum
2022-02-27 12:25:41 +01:00
committed by GitHub
parent 54312893a2
commit 338aba8342
38 changed files with 3221 additions and 1676 deletions
+49
View File
@@ -0,0 +1,49 @@
package test
import (
"bytes"
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"github.com/SecurityBrewery/catalyst/generated/model"
)
func TestJob(t *testing.T) {
_, _, _, _, _, _, _, server, cleanup, err := Server(t)
if err != nil {
t.Fatal(err)
}
defer cleanup()
// server.ConfigureRoutes()
w := httptest.NewRecorder()
// setup request
var req *http.Request
b, err := json.Marshal(model.JobForm{
Automation: "hash.sha1",
Origin: nil,
Payload: nil,
})
if err != nil {
t.Fatal(err)
}
req = httptest.NewRequest(http.MethodPost, "/jobs", bytes.NewBuffer(b))
req.Header.Set("Content-Type", "application/json")
// run request
server.ServeHTTP(w, req)
result := w.Result()
// assert results
if result.StatusCode != http.StatusNoContent {
t.Fatalf("Status got = %v, want %v", result.Status, http.StatusNoContent)
}
// if tt.want.status != http.StatusNoContent {
// jsonEqual(t, result.Body, tt.want.body)
// }
}