Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/webserver/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package webserver

import (
"errors"
"fmt"
"net/http"
"time"

Expand Down Expand Up @@ -48,8 +47,9 @@ func (s *WebUIServer) handleLogin(w http.ResponseWriter, r *http.Request) {
}
_, err = w.Write([]byte(token))

case "GET":
fmt.Fprintf(w, "only POST methods is allowed.")
default:
w.Header().Set("Allow", "POST")
http.Error(w, "only POST method is allowed", http.StatusMethodNotAllowed)
return
}
}
Expand Down
4 changes: 1 addition & 3 deletions internal/webserver/jwt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ func TestHandleLogin_GET(t *testing.T) {
w := httptest.NewRecorder()
ts.handleLogin(w, r)
resp := w.Result()
assert.Equal(t, http.StatusOK, resp.StatusCode)
body, _ := io.ReadAll(resp.Body)
assert.Equal(t, "only POST methods is allowed.", string(body))
assert.Equal(t, http.StatusMethodNotAllowed, resp.StatusCode)
}

func TestGenerateAndValidateJWT(t *testing.T) {
Expand Down
Loading