Skip to content

Commit

Permalink
oauth2: remove unneeded TokenSource implementation in transport test
Browse files Browse the repository at this point in the history
Change-Id: I2dca3a211f7b7e30ae023635c5ac44b6237ee01c
Reviewed-on: https://go-review.googlesource.com/c/oauth2/+/114957
Reviewed-by: Michael Pratt <[email protected]>
Auto-Submit: Sean Liao <[email protected]>
Reviewed-by: Sean Liao <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Junyang Shao <[email protected]>
  • Loading branch information
Tim Cooper authored and gopherbot committed Mar 3, 2025
1 parent 44967ab commit ce350bf
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ import (
"time"
)

type tokenSource struct{ token *Token }

func (t *tokenSource) Token() (*Token, error) {
return t.token, nil
}

func TestTransportNilTokenSource(t *testing.T) {
tr := &Transport{}
server := newMockServer(func(w http.ResponseWriter, r *http.Request) {})
Expand Down Expand Up @@ -88,13 +82,10 @@ func TestTransportCloseRequestBodySuccess(t *testing.T) {
}

func TestTransportTokenSource(t *testing.T) {
ts := &tokenSource{
token: &Token{
AccessToken: "abc",
},
}
tr := &Transport{
Source: ts,
Source: StaticTokenSource(&Token{
AccessToken: "abc",
}),
}
server := newMockServer(func(w http.ResponseWriter, r *http.Request) {
if got, want := r.Header.Get("Authorization"), "Bearer abc"; got != want {
Expand Down Expand Up @@ -123,14 +114,11 @@ func TestTransportTokenSourceTypes(t *testing.T) {
{key: "basic", val: val, want: "Basic abc"},
}
for _, tc := range tests {
ts := &tokenSource{
token: &Token{
tr := &Transport{
Source: StaticTokenSource(&Token{
AccessToken: tc.val,
TokenType: tc.key,
},
}
tr := &Transport{
Source: ts,
}),
}
server := newMockServer(func(w http.ResponseWriter, r *http.Request) {
if got, want := r.Header.Get("Authorization"), tc.want; got != want {
Expand Down

0 comments on commit ce350bf

Please sign in to comment.