Skip to content

Commit

Permalink
close
Browse files Browse the repository at this point in the history
  • Loading branch information
bmoylan committed Dec 18, 2024
1 parent 1f745a4 commit 7826479
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions conjure-go-client/httpclient/authn.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ type refreshableConfigAuthHeaderMiddleware struct {
cfg refreshingclient.RefreshableValidatedClientParams
}

// newRefreshableConfigAuthHeaderMiddleware returns a new Middleware that sets the Authorization header using the
// current API token or BasicAuth credentials from the provided RefreshableValidatedClientParams. If the request already
// has an Authorization header (e.g. set by a different Middleware), it will not be overwritten.
func newRefreshableConfigAuthHeaderMiddleware(cfg refreshingclient.RefreshableValidatedClientParams) Middleware {
return &refreshableConfigAuthHeaderMiddleware{cfg: cfg}
}
Expand Down
5 changes: 4 additions & 1 deletion conjure-go-client/httpclient/authn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,11 @@ func TestAuthHeaders(t *testing.T) {
resp, err := client.Get(context.Background(), requestParams...)
require.NoError(t, err)
require.NotNil(t, resp)
require.NoError(t, resp.Body.Close())
require.EqualValues(t, 200, resp.StatusCode)
})

// if testing request params, don't run the *http.Client test
if tc.RequestParams == nil {
t.Run("*http.Client", func(t *testing.T) {
server := tc.Server(t)
Expand All @@ -287,8 +290,8 @@ func TestAuthHeaders(t *testing.T) {
resp, err := client.Get(server.URL)
require.NoError(t, err)
require.NotNil(t, resp)
require.EqualValues(t, 200, resp.StatusCode)
require.NoError(t, resp.Body.Close())
require.EqualValues(t, 200, resp.StatusCode)
})
}
})
Expand Down

0 comments on commit 7826479

Please sign in to comment.