File tree 2 files changed +17
-0
lines changed
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import (
11
11
"fmt"
12
12
"io"
13
13
"io/ioutil"
14
+ "math"
14
15
"mime"
15
16
"net/http"
16
17
"net/url"
@@ -90,6 +91,9 @@ func (e *expirationTime) UnmarshalJSON(b []byte) error {
90
91
if err != nil {
91
92
return err
92
93
}
94
+ if i > math .MaxInt32 {
95
+ i = math .MaxInt32
96
+ }
93
97
* e = expirationTime (i )
94
98
return nil
95
99
}
Original file line number Diff line number Diff line change @@ -6,7 +6,9 @@ package internal
6
6
7
7
import (
8
8
"context"
9
+ "fmt"
9
10
"io"
11
+ "math"
10
12
"net/http"
11
13
"net/http/httptest"
12
14
"net/url"
@@ -62,3 +64,14 @@ func TestRetrieveTokenWithContexts(t *testing.T) {
62
64
t .Errorf ("RetrieveToken (with cancelled context) = nil; want error" )
63
65
}
64
66
}
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