Skip to content

Commit

Permalink
Prevent empty access_token (#31) (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverpool authored Nov 8, 2020
1 parent 2438b33 commit ca2ed0e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,16 @@ func (c *CSAPI) MustDoRaw(t *testing.T, method string, paths []string, body []by
// DoWithAuth a JSON request. The access token for this user will automatically be added.
func (c *CSAPI) DoWithAuth(t *testing.T, method string, paths []string, jsonBody interface{}) (*http.Response, error) {
t.Helper()
return c.Do(t, method, paths, jsonBody, url.Values{
"access_token": []string{c.AccessToken},
})
var query url.Values
if c.AccessToken != "" {
query = url.Values{
"access_token": []string{c.AccessToken},
}
}
return c.Do(t, method, paths, jsonBody, query)
}

func (c *CSAPI) DoWithAuthRaw(t *testing.T, method string, paths[] string, body []byte, contentType string, query url.Values) (*http.Response, error) {
func (c *CSAPI) DoWithAuthRaw(t *testing.T, method string, paths []string, body []byte, contentType string, query url.Values) (*http.Response, error) {
t.Helper()
if query == nil {
query = url.Values{}
Expand Down

0 comments on commit ca2ed0e

Please sign in to comment.