forked from Mirrors/oauth2
Small tweaks.
Change-Id: I77b1f7b362c3ed9972e278f06045c603abcdd9d4
This commit is contained in:
parent
82dc24d404
commit
95713928e4
|
@ -25,6 +25,10 @@ type urlCredentialSource struct {
|
|||
func (cs urlCredentialSource) subjectToken() (string, error) {
|
||||
client := oauth2.NewClient(cs.ctx, nil)
|
||||
req, err := http.NewRequest("GET", cs.URL, nil)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("oauth2/google: HTTP request for URL-sourced credential failed: %v", err)
|
||||
}
|
||||
req = req.WithContext(cs.ctx)
|
||||
|
||||
for key, val := range cs.Headers {
|
||||
req.Header.Add(key, val)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package externalaccount
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
|
@ -27,7 +28,7 @@ func TestRetrieveURLSubjectToken_Text(t *testing.T) {
|
|||
tfc := testFileConfig
|
||||
tfc.CredentialSource = cs
|
||||
|
||||
out, err := tfc.parse().subjectToken()
|
||||
out, err := tfc.parse(context.Background()).subjectToken()
|
||||
if err != nil {
|
||||
t.Fatalf("retrieveSubjectToken() failed: %v", err)
|
||||
}
|
||||
|
@ -50,7 +51,7 @@ func TestRetrieveURLSubjectToken_Untyped(t *testing.T) {
|
|||
tfc := testFileConfig
|
||||
tfc.CredentialSource = cs
|
||||
|
||||
out, err := tfc.parse().subjectToken()
|
||||
out, err := tfc.parse(context.Background()).subjectToken()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to retrieve URL subject token: %v", err)
|
||||
}
|
||||
|
@ -81,7 +82,7 @@ func TestRetrieveURLSubjectToken_JSON(t *testing.T) {
|
|||
tfc := testFileConfig
|
||||
tfc.CredentialSource = cs
|
||||
|
||||
out, err := tfc.parse().subjectToken()
|
||||
out, err := tfc.parse(context.Background()).subjectToken()
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue