Skip to content

Commit 2e8d934

Browse files
joelferriercodyoss
authored andcommitted
google: Use bytes.Buffer for go 1.9 compatability
Update test cases to use const test data file references. Change-Id: Ic08b6de5a84db7b2ae2c649ee676c5a2c13f4227 Reviewed-on: https://go-review.googlesource.com/c/oauth2/+/306749 Reviewed-by: Cody Oss <codyoss@google.com> Trust: Cody Oss <codyoss@google.com> Trust: Tyler Bui-Palsulich <tbp@google.com> Run-TryBot: Cody Oss <codyoss@google.com> TryBot-Result: Go Bot <gobot@golang.org>
1 parent 22b0ada commit 2e8d934

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

‎google/internal/externalaccount/aws.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package externalaccount
66

77
import (
8+
"bytes"
89
"context"
910
"crypto/hmac"
1011
"crypto/sha256"
@@ -127,7 +128,7 @@ func canonicalHeaders(req *http.Request) (string, string) {
127128
}
128129
sort.Strings(headers)
129130

130-
var fullHeaders strings.Builder
131+
var fullHeaders bytes.Buffer
131132
for _, header := range headers {
132133
headerValue := strings.Join(lowerCaseHeaders[header], ",")
133134
fullHeaders.WriteString(header)

‎google/internal/externalaccount/basecredentials_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ import (
1313
"time"
1414
)
1515

16+
const (
17+
textBaseCredPath = "testdata/3pi_cred.txt"
18+
jsonBaseCredPath = "testdata/3pi_cred.json"
19+
)
20+
1621
var testBaseCredSource = CredentialSource{
17-
File: "./testdata/3pi_cred.txt",
22+
File: textBaseCredPath,
1823
Format: format{Type: fileTypeText},
1924
}
2025

‎google/internal/externalaccount/filecredsource_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@ func TestRetrieveFileSubjectToken(t *testing.T) {
2828
{
2929
name: "UntypedFileSource",
3030
cs: CredentialSource{
31-
File: "./testdata/3pi_cred.txt",
31+
File: textBaseCredPath,
3232
},
3333
want: "street123",
3434
},
3535
{
3636
name: "TextFileSource",
3737
cs: CredentialSource{
38-
File: "./testdata/3pi_cred.txt",
38+
File: textBaseCredPath,
3939
Format: format{Type: fileTypeText},
4040
},
4141
want: "street123",
4242
},
4343
{
4444
name: "JSONFileSource",
4545
cs: CredentialSource{
46-
File: "./testdata/3pi_cred.json",
46+
File: jsonBaseCredPath,
4747
Format: format{Type: fileTypeJSON, SubjectTokenFieldName: "SubjToken"},
4848
},
4949
want: "321road",

0 commit comments

Comments
 (0)