Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
test: TestWithAuthorizationBearerToken
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Feb 27, 2023
1 parent 5c544ae commit ecd3d5e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions version_test.go → http_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,24 @@ func TestWithUserAgent(t *testing.T) {
_, err := client.Get(ts.URL)
assert.Nil(t, err)
}

func TestWithAuthorizationBearerToken(t *testing.T) {
secret := "secret"

client := &http.Client{
Transport: &customTransport{
AuthorizationBearerToken: secret,
RoundTripper: http.DefaultTransport,
},
}

ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
auth := r.Header.Get("Authorization")
assert.EqualValues(t, auth, "Bearer "+secret)
w.WriteHeader(http.StatusOK)
}))
defer ts.Close()

_, err := client.Get(ts.URL)
assert.Nil(t, err)
}

0 comments on commit ecd3d5e

Please sign in to comment.