diff --git a/internal/sessiontest/handle_test.go b/internal/sessiontest/handle_test.go new file mode 100644 index 000000000..2bcfb1ee8 --- /dev/null +++ b/internal/sessiontest/handle_test.go @@ -0,0 +1,34 @@ +package sessiontest + +import ( + "net/http" + "testing" + + irma "github.com/privacybydesign/irmago" + "github.com/privacybydesign/irmago/internal/common" + "github.com/stretchr/testify/require" +) + +func init() { + common.ForceHTTPS = false + irma.SetLogger(logger) +} + +func TestHandleSessionDelete(t *testing.T) { + StartIrmaServer(t, false, "") + defer StopIrmaServer() + + // Setup a new disclosure session + id := irma.NewAttributeTypeIdentifier("irma-demo.RU.studentCard.studentID") + session := startSession(t, getDisclosureRequest(id), "verification") + + // Attempt to delete the disclosed session + req, reqErr := http.NewRequest(http.MethodDelete, "http://localhost:48682/session/"+session.Token, nil) + require.NoError(t, reqErr) + + // Verify the API response + // TODO: Also test the actual deletion of the session + res, resErr := (&http.Client{}).Do(req) + require.NoError(t, resErr) + require.Equal(t, res.StatusCode, http.StatusNoContent) +} diff --git a/server/irmaserver/handle.go b/server/irmaserver/handle.go index 03e5e91b4..047c136bc 100644 --- a/server/irmaserver/handle.go +++ b/server/irmaserver/handle.go @@ -12,7 +12,7 @@ import ( "github.com/go-chi/chi" "github.com/privacybydesign/gabi" "github.com/privacybydesign/gabi/signed" - "github.com/privacybydesign/irmago" + irma "github.com/privacybydesign/irmago" "github.com/privacybydesign/irmago/internal/common" "github.com/privacybydesign/irmago/server" "github.com/sirupsen/logrus" @@ -284,7 +284,7 @@ func (s *Server) handleSessionStatusEvents(w http.ResponseWriter, r *http.Reques func (s *Server) handleSessionDelete(w http.ResponseWriter, r *http.Request) { r.Context().Value("session").(*session).handleDelete() - w.WriteHeader(200) + w.WriteHeader(http.StatusNoContent) } func (s *Server) handleSessionGet(w http.ResponseWriter, r *http.Request) {