From 42ba0765c80ba173e0fad6a53d732f02fbfd7a21 Mon Sep 17 00:00:00 2001 From: Pascal Fischer Date: Tue, 28 Mar 2023 14:54:06 +0200 Subject: [PATCH] fix linter --- go.mod | 2 +- management/server/http/pat_handler.go | 5 +++++ management/server/http/pat_handler_test.go | 3 +-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d6518467f..c74fee409 100644 --- a/go.mod +++ b/go.mod @@ -37,6 +37,7 @@ require ( github.com/getlantern/systray v1.2.1 github.com/gliderlabs/ssh v0.3.4 github.com/godbus/dbus/v5 v5.1.0 + github.com/google/go-cmp v0.5.9 github.com/google/nftables v0.0.0-20220808154552-2eca00135732 github.com/hashicorp/go-secure-stdlib/base62 v0.1.2 github.com/hashicorp/go-version v1.6.0 @@ -89,7 +90,6 @@ require ( github.com/go-stack/stack v1.8.0 // indirect github.com/gobwas/glob v0.2.3 // indirect github.com/goki/freetype v0.0.0-20181231101311-fa8a33aabaff // indirect - github.com/google/go-cmp v0.5.9 // indirect github.com/google/gopacket v1.1.19 // indirect github.com/hashicorp/go-uuid v1.0.2 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect diff --git a/management/server/http/pat_handler.go b/management/server/http/pat_handler.go index ab356b8c9..654ea44f8 100644 --- a/management/server/http/pat_handler.go +++ b/management/server/http/pat_handler.go @@ -133,6 +133,11 @@ func (h *PATHandler) CreateToken(w http.ResponseWriter, r *http.Request) { } pat, err := server.CreateNewPAT(req.Name, req.ExpiresIn, user.Id) + if err != nil { + util.WriteError(err, w) + return + } + err = h.accountManager.AddPATToUser(account.Id, userID, &pat.PersonalAccessToken) if err != nil { util.WriteError(err, w) diff --git a/management/server/http/pat_handler_test.go b/management/server/http/pat_handler_test.go index c0a7185cb..0d29f1ad4 100644 --- a/management/server/http/pat_handler_test.go +++ b/management/server/http/pat_handler_test.go @@ -3,7 +3,6 @@ package http import ( "bytes" "encoding/json" - "fmt" "io" "net/http" "net/http/httptest" @@ -148,7 +147,7 @@ func TestTokenHandlers(t *testing.T) { requestType: http.MethodPost, requestPath: "/api/users/" + existingUserID + "/tokens", requestBody: bytes.NewBuffer( - []byte(fmt.Sprint("{\"name\":\"name\",\"expires_in\":7}"))), + []byte("{\"name\":\"name\",\"expires_in\":7}")), expectedStatus: http.StatusOK, expectedBody: true, },