Skip to content
Snippets Groups Projects
Commit 5b42dbda authored by Odin K. Henriksen's avatar Odin K. Henriksen
Browse files

Added test to see if an unspecified endpoint returns 404

parent 5e7272ad
No related branches found
No related tags found
1 merge request!2Merge react-branch into main.
...@@ -294,3 +294,31 @@ func TestHash_IntelligenceValidOutput(t *testing.T) { ...@@ -294,3 +294,31 @@ func TestHash_IntelligenceValidOutput(t *testing.T) {
t.Fatalf("The status of AlienVault has is not as expected Risk, Status is: %s", jsonResponse.FrontendResponse[1].EN.Status) t.Fatalf("The status of AlienVault has is not as expected Risk, Status is: %s", jsonResponse.FrontendResponse[1].EN.Status)
} }
} }
/**
* This API test checks if an unspecified endpoint in the API returns 404 as expected
*
*/
func TestNotSpecifiedEndpoint(t *testing.T){
url := "http://localhost:8081/ThisShouldNotExist"
req, err := http.NewRequest("GET", url, nil)
if err != nil {
t.Fatalf("Error in request")
}
req.Header.Set("Content-Type", "application/json; charset=UTF-8")
client := &http.Client{}
res, err := client.Do(req)
if err != nil {
t.Fatalf("Request to Hash-Intelligence failed")
}
defer res.Body.Close()
if res.StatusCode != http.StatusNotFound {
t.Fatalf("Staus code did not return 404 as expected, code returned %d", res.StatusCode)
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment