@@ -289,6 +289,7 @@ func TestStrategyLoginConsentNext(t *testing.T) {
289289
290290 subject := "aeneas-rekkas"
291291 c := createDefaultClient (t )
292+ now := 1723546027 // Unix timestamps must round-trip through Hydra without converting to floats or similar
292293 testhelpers .NewLoginConsentUI (t , reg .Config (),
293294 acceptLoginHandler (t , subject , & hydra.AcceptOAuth2LoginRequest {
294295 Remember : pointerx .Bool (true ),
@@ -297,8 +298,14 @@ func TestStrategyLoginConsentNext(t *testing.T) {
297298 Remember : pointerx .Bool (true ),
298299 GrantScope : []string {"openid" },
299300 Session : & hydra.AcceptOAuth2ConsentRequestSession {
300- AccessToken : map [string ]interface {}{"foo" : "bar" },
301- IdToken : map [string ]interface {}{"bar" : "baz" },
301+ AccessToken : map [string ]interface {}{
302+ "foo" : "bar" ,
303+ "ts1" : now ,
304+ },
305+ IdToken : map [string ]interface {}{
306+ "bar" : "baz" ,
307+ "ts2" : now ,
308+ },
302309 },
303310 }))
304311
@@ -314,12 +321,14 @@ func TestStrategyLoginConsentNext(t *testing.T) {
314321 require .NoError (t , err )
315322
316323 claims := testhelpers .IntrospectToken (t , conf , token .AccessToken , adminTS )
317- assert .Equal (t , "bar" , claims .Get ("ext.foo" ).String (), "%s" , claims .Raw )
324+ assert .Equalf (t , `"bar"` , claims .Get ("ext.foo" ).Raw , "%s" , claims .Raw ) // Raw rather than .Int() or .Value() to verify the exact JSON payload
325+ assert .Equalf (t , "1723546027" , claims .Get ("ext.ts1" ).Raw , "%s" , claims .Raw ) // must round-trip as integer
318326
319327 idClaims := testhelpers .DecodeIDToken (t , token )
320- assert .Equal (t , "baz" , idClaims .Get ("bar" ).String (), "%s" , idClaims .Raw )
328+ assert .Equalf (t , `"baz"` , idClaims .Get ("bar" ).Raw , "%s" , idClaims .Raw ) // Raw rather than .Int() or .Value() to verify the exact JSON payload
329+ assert .Equalf (t , "1723546027" , idClaims .Get ("ts2" ).Raw , "%s" , idClaims .Raw ) // must round-trip as integer
321330 sid = idClaims .Get ("sid" ).String ()
322- assert .NotNil (t , sid )
331+ assert .NotEmpty (t , sid )
323332 }
324333
325334 t .Run ("perform first flow" , run )
@@ -334,21 +343,28 @@ func TestStrategyLoginConsentNext(t *testing.T) {
334343 assert .Empty (t , pointerx .StringR (res .Client .ClientSecret ))
335344 return hydra.AcceptOAuth2LoginRequest {
336345 Subject : subject ,
337- Context : map [string ]interface {}{"foo " : "bar " },
346+ Context : map [string ]interface {}{"xyz " : "abc " },
338347 }
339348 }),
340- checkAndAcceptConsentHandler (t , adminClient , func (t * testing.T , res * hydra.OAuth2ConsentRequest , err error ) hydra.AcceptOAuth2ConsentRequest {
349+ checkAndAcceptConsentHandler (t , adminClient , func (t * testing.T , req * hydra.OAuth2ConsentRequest , err error ) hydra.AcceptOAuth2ConsentRequest {
341350 require .NoError (t , err )
342- assert .True (t , * res .Skip )
343- assert .Equal (t , sid , * res .LoginSessionId )
344- assert .Equal (t , subject , * res .Subject )
345- assert .Empty (t , pointerx .StringR (res .Client .ClientSecret ))
351+ assert .True (t , * req .Skip )
352+ assert .Equal (t , sid , * req .LoginSessionId )
353+ assert .Equal (t , subject , * req .Subject )
354+ assert .Empty (t , pointerx .StringR (req .Client .ClientSecret ))
355+ assert .Equal (t , map [string ]interface {}{"xyz" : "abc" }, req .Context )
346356 return hydra.AcceptOAuth2ConsentRequest {
347357 Remember : pointerx .Bool (true ),
348358 GrantScope : []string {"openid" },
349359 Session : & hydra.AcceptOAuth2ConsentRequestSession {
350- AccessToken : map [string ]interface {}{"foo" : "bar" },
351- IdToken : map [string ]interface {}{"bar" : "baz" },
360+ AccessToken : map [string ]interface {}{
361+ "foo" : "bar" ,
362+ "ts1" : now ,
363+ },
364+ IdToken : map [string ]interface {}{
365+ "bar" : "baz" ,
366+ "ts2" : now ,
367+ },
352368 },
353369 }
354370 }))
0 commit comments