forked from Mirrors/oauth2
go fmt
Change-Id: Ie9d82a9c162eb72f63ebd75a284083eb4318d6d1
This commit is contained in:
parent
bf1e0506de
commit
3454980053
|
@ -115,14 +115,13 @@ type credentialsFile struct {
|
||||||
RefreshToken string `json:"refresh_token"`
|
RefreshToken string `json:"refresh_token"`
|
||||||
|
|
||||||
// External Account fields
|
// External Account fields
|
||||||
Audience string `json:"audience"`
|
Audience string `json:"audience"`
|
||||||
SubjectTokenType string `json:"subject_token_type"`
|
SubjectTokenType string `json:"subject_token_type"`
|
||||||
TokenURLExternal string `json:"token_url"`
|
TokenURLExternal string `json:"token_url"`
|
||||||
TokenInfoURL string `json:"token_info_url"`
|
TokenInfoURL string `json:"token_info_url"`
|
||||||
ServiceAccountImpersonationURL string `json:"service_account_impersonation_url"`
|
ServiceAccountImpersonationURL string `json:"service_account_impersonation_url"`
|
||||||
CredentialSource externalaccount.CredentialSource `json:"credential_source"`
|
CredentialSource externalaccount.CredentialSource `json:"credential_source"`
|
||||||
QuotaProjectID string `json:"quota_project_id"`
|
QuotaProjectID string `json:"quota_project_id"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *credentialsFile) jwtConfig(scopes []string) *jwt.Config {
|
func (f *credentialsFile) jwtConfig(scopes []string) *jwt.Config {
|
||||||
|
@ -155,16 +154,16 @@ func (f *credentialsFile) tokenSource(ctx context.Context, scopes []string) (oau
|
||||||
return cfg.TokenSource(ctx, tok), nil
|
return cfg.TokenSource(ctx, tok), nil
|
||||||
case externalAccountKey:
|
case externalAccountKey:
|
||||||
cfg := &externalaccount.Config{
|
cfg := &externalaccount.Config{
|
||||||
Audience: f.Audience,
|
Audience: f.Audience,
|
||||||
SubjectTokenType: f.SubjectTokenType,
|
SubjectTokenType: f.SubjectTokenType,
|
||||||
TokenURL: f.TokenURLExternal,
|
TokenURL: f.TokenURLExternal,
|
||||||
TokenInfoURL: f.TokenInfoURL,
|
TokenInfoURL: f.TokenInfoURL,
|
||||||
ServiceAccountImpersonationURL: f.ServiceAccountImpersonationURL,
|
ServiceAccountImpersonationURL: f.ServiceAccountImpersonationURL,
|
||||||
ClientSecret: f.ClientSecret,
|
ClientSecret: f.ClientSecret,
|
||||||
ClientID: f.ClientID,
|
ClientID: f.ClientID,
|
||||||
CredentialSource: f.CredentialSource,
|
CredentialSource: f.CredentialSource,
|
||||||
QuotaProjectID: f.QuotaProjectID,
|
QuotaProjectID: f.QuotaProjectID,
|
||||||
Scopes: scopes,
|
Scopes: scopes,
|
||||||
}
|
}
|
||||||
return cfg.TokenSource(ctx), nil
|
return cfg.TokenSource(ctx), nil
|
||||||
case "":
|
case "":
|
||||||
|
|
|
@ -15,9 +15,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type urlCredentialSource struct {
|
type urlCredentialSource struct {
|
||||||
URL string
|
URL string
|
||||||
Headers map[string]string
|
Headers map[string]string
|
||||||
Format format
|
Format format
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs urlCredentialSource) subjectToken() (string, error) {
|
func (cs urlCredentialSource) subjectToken() (string, error) {
|
||||||
|
@ -64,4 +64,4 @@ func (cs urlCredentialSource) subjectToken() (string, error) {
|
||||||
return "", errors.New("oauth2/google: invalid credential_source file format type")
|
return "", errors.New("oauth2/google: invalid credential_source file format type")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,6 @@ import (
|
||||||
|
|
||||||
var myURLToken = "testTokenValue"
|
var myURLToken = "testTokenValue"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func TestRetrieveURLSubjectToken_Text(t *testing.T) {
|
func TestRetrieveURLSubjectToken_Text(t *testing.T) {
|
||||||
|
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -24,7 +22,7 @@ func TestRetrieveURLSubjectToken_Text(t *testing.T) {
|
||||||
w.Write([]byte("testTokenValue"))
|
w.Write([]byte("testTokenValue"))
|
||||||
}))
|
}))
|
||||||
cs := CredentialSource{
|
cs := CredentialSource{
|
||||||
URL: ts.URL,
|
URL: ts.URL,
|
||||||
Format: format{Type: fileTypeText},
|
Format: format{Type: fileTypeText},
|
||||||
}
|
}
|
||||||
tfc := testFileConfig
|
tfc := testFileConfig
|
||||||
|
@ -81,7 +79,7 @@ func TestRetrieveURLSubjectToken_JSON(t *testing.T) {
|
||||||
w.Write(jsonResp)
|
w.Write(jsonResp)
|
||||||
}))
|
}))
|
||||||
cs := CredentialSource{
|
cs := CredentialSource{
|
||||||
URL: ts.URL,
|
URL: ts.URL,
|
||||||
Format: format{Type: fileTypeJSON, SubjectTokenFieldName: "SubjToken"},
|
Format: format{Type: fileTypeJSON, SubjectTokenFieldName: "SubjToken"},
|
||||||
}
|
}
|
||||||
tfc := testFileConfig
|
tfc := testFileConfig
|
||||||
|
@ -89,7 +87,6 @@ func TestRetrieveURLSubjectToken_JSON(t *testing.T) {
|
||||||
|
|
||||||
out, err := tfc.parse().subjectToken()
|
out, err := tfc.parse().subjectToken()
|
||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("%v", err)
|
t.Fatalf("%v", err)
|
||||||
}
|
}
|
||||||
|
@ -97,4 +94,4 @@ func TestRetrieveURLSubjectToken_JSON(t *testing.T) {
|
||||||
t.Errorf("got %v but want %v", out, myURLToken)
|
t.Errorf("got %v but want %v", out, myURLToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue