2022-12-31 10:22:38 +01:00
|
|
|
package tests
|
|
|
|
|
|
|
|
import (
|
2023-10-24 09:27:34 +02:00
|
|
|
"io"
|
|
|
|
"testing"
|
|
|
|
|
2022-12-31 10:22:38 +01:00
|
|
|
"github.com/stretchr/testify/assert"
|
2023-10-24 09:27:34 +02:00
|
|
|
"github.com/stretchr/testify/require"
|
2024-03-16 15:41:30 +01:00
|
|
|
"github.com/twofas/2fas-server/e2e-tests"
|
2022-12-31 10:22:38 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func Test_Default404Response(t *testing.T) {
|
2024-03-16 15:41:30 +01:00
|
|
|
response := e2e_tests.DoAPIGet(t, "some/not/existing/endpoint", nil)
|
2022-12-31 10:22:38 +01:00
|
|
|
|
2023-10-24 09:27:34 +02:00
|
|
|
rawBody, err := io.ReadAll(response.Body)
|
|
|
|
require.NoError(t, err)
|
2022-12-31 10:22:38 +01:00
|
|
|
|
|
|
|
expected := `{"Code":404,"Type":"NotFound","Description":"Requested resource can not be found","Reason":"URI not found"}`
|
|
|
|
|
|
|
|
assert.Equal(t, 404, response.StatusCode)
|
|
|
|
assert.JSONEq(t, expected, string(rawBody))
|
|
|
|
}
|