@@ -102,6 +102,24 @@ func TestLoadCachedToken(t *testing.T) {
102102},
103103},
104104},
105+ "non-utc token" : {
106+ filename : filepath .Join ("testdata" , "non_utc_token.json" ),
107+ expectToken : token {
108+ tokenKnownFields : tokenKnownFields {
109+ AccessToken : "dGhpcyBpcyBub3QgYSByZWFsIHZhbHVl" ,
110+ ExpiresAt : (* rfc3339 )(aws .Time (time .Date (2044 , 4 , 4 , 7 , 0 , 1 , 0 , time .UTC ))),
111+ ClientID : "client id" ,
112+ ClientSecret : "client secret" ,
113+ RefreshToken : "refresh token" ,
114+ },
115+ UnknownFields : map [string ]interface {}{
116+ "unknownField" : "some value" ,
117+ "registrationExpiresAt" : "2044-04-04T07:00:01Z" ,
118+ "region" : "region" ,
119+ "startURL" : "start URL" ,
120+ },
121+ },
122+ },
105123}
106124
107125for name , c := range cases {
@@ -120,7 +138,7 @@ func TestLoadCachedToken(t *testing.T) {
120138t .Fatalf ("expect no error, got %v" , err )
121139}
122140
123- if diff := cmpDiff (c .expectToken , actualToken ); diff != "" {
141+ if diff := cmpDiffToken (c .expectToken , actualToken ); diff != "" {
124142t .Errorf ("expect tokens match\n %s" , diff )
125143}
126144})
@@ -162,6 +180,25 @@ func TestStoreCachedToken(t *testing.T) {
162180},
163181},
164182},
183+ "non-utc token" : {
184+ filename : filepath .Join (tempDir , "token_file.json" ),
185+ fileMode : 0600 ,
186+ token : token {
187+ tokenKnownFields : tokenKnownFields {
188+ AccessToken : "dGhpcyBpcyBub3QgYSByZWFsIHZhbHVl" ,
189+ ExpiresAt : (* rfc3339 )(aws .Time (time .Date (2044 , 4 , 4 , 7 , 0 , 1 , 0 , time .FixedZone ("UTC-8" , - 8 * 60 * 60 )))),
190+ ClientID : "client id" ,
191+ ClientSecret : "client secret" ,
192+ RefreshToken : "refresh token" ,
193+ },
194+ UnknownFields : map [string ]interface {}{
195+ "unknownField" : "some value" ,
196+ "registrationExpiresAt" : "2044-04-04T07:00:01Z" ,
197+ "region" : "region" ,
198+ "startURL" : "start URL" ,
199+ },
200+ },
201+ },
165202}
166203
167204for name , c := range cases {
@@ -176,7 +213,7 @@ func TestStoreCachedToken(t *testing.T) {
176213t .Fatalf ("failed to load stored token, %v" , err )
177214}
178215
179- if diff := cmpDiff (c .token , actual ); diff != "" {
216+ if diff := cmpDiffToken (c .token , actual ); diff != "" {
180217t .Errorf ("expect tokens match\n %s" , diff )
181218}
182219})
0 commit comments