single user token in server tests

This commit is contained in:
Chen-I Lim 2021-02-09 16:07:41 -08:00
parent 3ba6f7fa0a
commit 656d1c7851
3 changed files with 7 additions and 4 deletions

View file

@ -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)

View file

@ -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}
}

View file

@ -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
}