google: fixing more nits

Change-Id: Ie637113fa2363a40e05f51345efbd87d22bfe54a
This commit is contained in:
Patrick Jones
2020-12-17 11:26:51 -08:00
parent 08114d04f5
commit 80e2eea187
4 changed files with 66 additions and 58 deletions

View File

@@ -1,3 +1,7 @@
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package externalaccount
import (
@@ -14,9 +18,8 @@ var testBaseCredSource = CredentialSource{
}
var testConfig = Config{
Audience: "32555940559.apps.googleusercontent.com",
SubjectTokenType: "urn:ietf:params:oauth:token-type:jwt",
//TokenURL: "http://localhost:8080/v1/token",
Audience: "32555940559.apps.googleusercontent.com",
SubjectTokenType: "urn:ietf:params:oauth:token-type:jwt",
TokenInfoURL: "http://localhost:8080/v1/tokeninfo",
ServiceAccountImpersonationURL: "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/service-gcs-admin@$PROJECT_ID.iam.gserviceaccount.com:generateAccessToken",
ClientSecret: "notsosecret",
@@ -38,9 +41,6 @@ var (
func TestToken_Func(t *testing.T) {
targetServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
/*I'm not sure whether this testing is necessary or not. There's an argument that it should be here for completeness,
but it's also just mimicking similar testing done in sts_exchange_test.go
*/
if got, want := r.URL.String(), "/"; got != want {
t.Errorf("Unexpected request URL: got %v but want %v", got, want)
}
@@ -62,6 +62,7 @@ func TestToken_Func(t *testing.T) {
w.Header().Set("Content-Type", "application/json")
w.Write([]byte(baseCredsResponseBody))
}))
defer targetServer.Close()
testConfig.TokenURL = targetServer.URL
ourTS := tokenSource{
@@ -88,6 +89,4 @@ func TestToken_Func(t *testing.T) {
t.Errorf("Unexpected Expiry: got %v, but wanted %v", got, want)
}
//We don't check the correct expiry here because that's dependent on the current time.
}