Hide setup key from non-admin users (#539)

This commit is contained in:
Misha Bragin
2022-11-03 17:02:31 +01:00
committed by GitHub
parent 2e0bf61e9a
commit 6aa7a2c5e1
5 changed files with 48 additions and 12 deletions

View File

@ -2,6 +2,7 @@ package http
import (
"bytes"
"context"
"encoding/json"
"fmt"
"github.com/gorilla/mux"
@ -159,6 +160,7 @@ func TestSetupKeysHandlers(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
recorder := httptest.NewRecorder()
req := httptest.NewRequest(tc.requestType, tc.requestPath, tc.requestBody)
req = req.Clone(context.WithValue(context.TODO(), "isAdminUser", true)) //nolint
router := mux.NewRouter()
router.HandleFunc("/api/setup-keys", handler.GetAllSetupKeysHandler).Methods("GET", "OPTIONS")