Merge branch 'aws-signature' of https://github.com/ScruffyProdigy/oauth2 into aws-signature

This commit is contained in:
Ryan Kohler 2021-01-20 10:51:17 -08:00
commit 3aaffc9d6a
1 changed files with 19 additions and 19 deletions

View File

@ -1,6 +1,7 @@
// Copyright 2021 The Go Authors. All rights reserved. // Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package externalaccount package externalaccount
import ( import (
@ -13,8 +14,7 @@ import (
var defaultTime = time.Date(2011, 9, 9, 23, 36, 0, 0, time.UTC) var defaultTime = time.Date(2011, 9, 9, 23, 36, 0, 0, time.UTC)
var secondDefaultTime = time.Date(2020, 8, 11, 6, 55, 22, 0, time.UTC) var secondDefaultTime = time.Date(2020, 8, 11, 6, 55, 22, 0, time.UTC)
func setTime(testTime time.Time) (func() time.Time) {
func setTime(testTime time.Time) func() time.Time {
return func() time.Time { return func() time.Time {
return testTime return testTime
} }
@ -72,7 +72,7 @@ func TestAwsV4Signature_GetRequest(t *testing.T) {
} }
oldNow := now oldNow := now
defer func() { now = oldNow }() defer func() {now = oldNow}()
now = setTime(defaultTime) now = setTime(defaultTime)
testRequestSigner(t, defaultRequestSigner, input, output) testRequestSigner(t, defaultRequestSigner, input, output)
@ -90,7 +90,7 @@ func TestAwsV4Signature_GetRequestWithRelativePath(t *testing.T) {
} }
oldNow := now oldNow := now
defer func() { now = oldNow }() defer func() {now = oldNow}()
now = setTime(defaultTime) now = setTime(defaultTime)
testRequestSigner(t, defaultRequestSigner, input, output) testRequestSigner(t, defaultRequestSigner, input, output)
@ -108,7 +108,7 @@ func TestAwsV4Signature_GetRequestWithDotPath(t *testing.T) {
} }
oldNow := now oldNow := now
defer func() { now = oldNow }() defer func() {now = oldNow}()
now = setTime(defaultTime) now = setTime(defaultTime)
testRequestSigner(t, defaultRequestSigner, input, output) testRequestSigner(t, defaultRequestSigner, input, output)
@ -126,7 +126,7 @@ func TestAwsV4Signature_GetRequestWithPointlessDotPath(t *testing.T) {
} }
oldNow := now oldNow := now
defer func() { now = oldNow }() defer func() {now = oldNow}()
now = setTime(defaultTime) now = setTime(defaultTime)
testRequestSigner(t, defaultRequestSigner, input, output) testRequestSigner(t, defaultRequestSigner, input, output)
@ -144,7 +144,7 @@ func TestAwsV4Signature_GetRequestWithUtf8Path(t *testing.T) {
} }
oldNow := now oldNow := now
defer func() { now = oldNow }() defer func() {now = oldNow}()
now = setTime(defaultTime) now = setTime(defaultTime)
testRequestSigner(t, defaultRequestSigner, input, output) testRequestSigner(t, defaultRequestSigner, input, output)
@ -162,7 +162,7 @@ func TestAwsV4Signature_GetRequestWithDuplicateQuery(t *testing.T) {
} }
oldNow := now oldNow := now
defer func() { now = oldNow }() defer func() {now = oldNow}()
now = setTime(defaultTime) now = setTime(defaultTime)
testRequestSigner(t, defaultRequestSigner, input, output) testRequestSigner(t, defaultRequestSigner, input, output)
@ -180,7 +180,7 @@ func TestAwsV4Signature_GetRequestWithMisorderedQuery(t *testing.T) {
} }
oldNow := now oldNow := now
defer func() { now = oldNow }() defer func() {now = oldNow}()
now = setTime(defaultTime) now = setTime(defaultTime)
testRequestSigner(t, defaultRequestSigner, input, output) testRequestSigner(t, defaultRequestSigner, input, output)
@ -198,7 +198,7 @@ func TestAwsV4Signature_GetRequestWithUtf8Query(t *testing.T) {
} }
oldNow := now oldNow := now
defer func() { now = oldNow }() defer func() {now = oldNow}()
now = setTime(defaultTime) now = setTime(defaultTime)
testRequestSigner(t, defaultRequestSigner, input, output) testRequestSigner(t, defaultRequestSigner, input, output)
@ -218,7 +218,7 @@ func TestAwsV4Signature_PostRequest(t *testing.T) {
} }
oldNow := now oldNow := now
defer func() { now = oldNow }() defer func() {now = oldNow}()
now = setTime(defaultTime) now = setTime(defaultTime)
testRequestSigner(t, defaultRequestSigner, input, output) testRequestSigner(t, defaultRequestSigner, input, output)
@ -238,7 +238,7 @@ func TestAwsV4Signature_PostRequestWithCapitalizedHeaderValue(t *testing.T) {
} }
oldNow := now oldNow := now
defer func() { now = oldNow }() defer func() {now = oldNow}()
now = setTime(defaultTime) now = setTime(defaultTime)
testRequestSigner(t, defaultRequestSigner, input, output) testRequestSigner(t, defaultRequestSigner, input, output)
@ -258,7 +258,7 @@ func TestAwsV4Signature_PostRequestPhfft(t *testing.T) {
} }
oldNow := now oldNow := now
defer func() { now = oldNow }() defer func() {now = oldNow}()
now = setTime(defaultTime) now = setTime(defaultTime)
testRequestSigner(t, defaultRequestSigner, input, output) testRequestSigner(t, defaultRequestSigner, input, output)
@ -278,7 +278,7 @@ func TestAwsV4Signature_PostRequestWithBody(t *testing.T) {
} }
oldNow := now oldNow := now
defer func() { now = oldNow }() defer func() {now = oldNow}()
now = setTime(defaultTime) now = setTime(defaultTime)
testRequestSigner(t, defaultRequestSigner, input, output) testRequestSigner(t, defaultRequestSigner, input, output)
@ -296,7 +296,7 @@ func TestAwsV4Signature_PostRequestWithQueryString(t *testing.T) {
} }
oldNow := now oldNow := now
defer func() { now = oldNow }() defer func() {now = oldNow}()
now = setTime(defaultTime) now = setTime(defaultTime)
testRequestSigner(t, defaultRequestSigner, input, output) testRequestSigner(t, defaultRequestSigner, input, output)
@ -314,7 +314,7 @@ func TestAwsV4Signature_GetRequestWithSecurityToken(t *testing.T) {
} }
oldNow := now oldNow := now
defer func() { now = oldNow }() defer func() {now = oldNow}()
now = setTime(secondDefaultTime) now = setTime(secondDefaultTime)
testRequestSigner(t, requestSignerWithToken, input, output) testRequestSigner(t, requestSignerWithToken, input, output)
@ -332,7 +332,7 @@ func TestAwsV4Signature_PostRequestWithSecurityToken(t *testing.T) {
} }
oldNow := now oldNow := now
defer func() { now = oldNow }() defer func() {now = oldNow}()
now = setTime(secondDefaultTime) now = setTime(secondDefaultTime)
testRequestSigner(t, requestSignerWithToken, input, output) testRequestSigner(t, requestSignerWithToken, input, output)
@ -355,7 +355,7 @@ func TestAwsV4Signature_PostRequestWithSecurityTokenAndAdditionalHeaders(t *test
} }
oldNow := now oldNow := now
defer func() { now = oldNow }() defer func() {now = oldNow}()
now = setTime(secondDefaultTime) now = setTime(secondDefaultTime)
testRequestSigner(t, requestSignerWithToken, input, output) testRequestSigner(t, requestSignerWithToken, input, output)
@ -377,7 +377,7 @@ func TestAwsV4Signature_PostRequestWithAmzDateButNoSecurityToken(t *testing.T) {
} }
oldNow := now oldNow := now
defer func() { now = oldNow }() defer func() {now = oldNow}()
now = setTime(secondDefaultTime) now = setTime(secondDefaultTime)
testRequestSigner(t, requestSigner, input, output) testRequestSigner(t, requestSigner, input, output)