From 656d1c7851d709919af1e34962bd0fcf5cb97504 Mon Sep 17 00:00:00 2001 From: Chen-I Lim Date: Tue, 9 Feb 2021 16:07:41 -0800 Subject: [PATCH] single user token in server tests --- server/app/blocks_test.go | 3 ++- server/client/client.go | 3 ++- server/integrationtests/clienttestlib.go | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/server/app/blocks_test.go b/server/app/blocks_test.go index 105417e26..b9fc3e735 100644 --- a/server/app/blocks_test.go +++ b/server/app/blocks_test.go @@ -20,7 +20,8 @@ func TestGetParentID(t *testing.T) { cfg := config.Configuration{} store := mockstore.NewMockStore(ctrl) auth := auth.New(&cfg, store) - wsserver := ws.NewServer(auth, true) + sessionToken := "TESTTOKEN" + wsserver := ws.NewServer(auth, sessionToken) webhook := webhook.NewClient(&cfg) app := New(&cfg, store, auth, wsserver, &mocks.FileBackend{}, webhook) diff --git a/server/client/client.go b/server/client/client.go index c6814f3ba..58f3c19d8 100644 --- a/server/client/client.go +++ b/server/client/client.go @@ -63,10 +63,11 @@ type Client struct { HttpHeader map[string]string } -func NewClient(url string) *Client { +func NewClient(url string, sessionToken string) *Client { url = strings.TrimRight(url, "/") headers := map[string]string{ "X-Requested-With": "XMLHttpRequest", + "Authorization": "Bearer " + sessionToken, } return &Client{url, url + API_URL_SUFFIX, &http.Client{}, headers} } diff --git a/server/integrationtests/clienttestlib.go b/server/integrationtests/clienttestlib.go index 6dea83133..7daa0b7fb 100644 --- a/server/integrationtests/clienttestlib.go +++ b/server/integrationtests/clienttestlib.go @@ -27,13 +27,14 @@ func getTestConfig() *config.Configuration { } func SetupTestHelper() *TestHelper { + sessionToken := "TESTTOKEN" th := &TestHelper{} - srv, err := server.New(getTestConfig(), true) + srv, err := server.New(getTestConfig(), sessionToken) if err != nil { panic(err) } th.Server = srv - th.Client = client.NewClient(srv.Config().ServerRoot) + th.Client = client.NewClient(srv.Config().ServerRoot, sessionToken) return th }