File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import (
1111 "fmt"
1212 "io"
1313 "io/ioutil"
14+ "math"
1415 "mime"
1516 "net/http"
1617 "net/url"
@@ -90,6 +91,9 @@ func (e *expirationTime) UnmarshalJSON(b []byte) error {
9091 if err != nil {
9192 return err
9293 }
94+ if i > math .MaxInt32 {
95+ i = math .MaxInt32
96+ }
9397 * e = expirationTime (i )
9498 return nil
9599}
Original file line number Diff line number Diff line change @@ -6,7 +6,9 @@ package internal
66
77import (
88 "context"
9+ "fmt"
910 "io"
11+ "math"
1012 "net/http"
1113 "net/http/httptest"
1214 "net/url"
@@ -62,3 +64,14 @@ func TestRetrieveTokenWithContexts(t *testing.T) {
6264 t .Errorf ("RetrieveToken (with cancelled context) = nil; want error" )
6365 }
6466}
67+
68+ func TestExpiresInUpperBound (t * testing.T ) {
69+ var e expirationTime
70+ if err := e .UnmarshalJSON ([]byte (fmt .Sprint (int64 (math .MaxInt32 ) + 1 ))); err != nil {
71+ t .Fatal (err )
72+ }
73+ const want = math .MaxInt32
74+ if e != want {
75+ t .Errorf ("expiration time = %v; want %v" , e , want )
76+ }
77+ }
You can’t perform that action at this time.
0 commit comments