@@ -1253,6 +1253,31 @@ func testFositeJWTBearerGrantStorage(x *driver.RegistrySQL) func(t *testing.T) {
12531253 require .NotEmpty (t , jwks .Keys )
12541254 })
12551255
1256+ t .Run ("case=does not found expired grant" , func (t * testing.T ) {
1257+ keySet , err := jwk .GenerateJWK (jose .RS256 , uuid .Must (uuid .NewV4 ()).String (), "sig" )
1258+ require .NoError (t , err )
1259+
1260+ publicKey := keySet .Keys [0 ].Public ()
1261+ issuer := uuid .Must (uuid .NewV4 ()).String ()
1262+ subject := uuid .Must (uuid .NewV4 ()).String ()
1263+ grant := trust.Grant {
1264+ ID : uuid .Must (uuid .NewV4 ()),
1265+ Issuer : issuer ,
1266+ Subject : subject ,
1267+ AllowAnySubject : true ,
1268+ Scope : []string {"openid" , "offline" },
1269+ PublicKey : trust.PublicKey {Set : issuer , KeyID : publicKey .KeyID },
1270+ CreatedAt : time .Now ().UTC ().Round (time .Second ),
1271+ ExpiresAt : time .Now ().UTC ().Round (time .Second ).AddDate (- 1 , 0 , 0 ),
1272+ }
1273+
1274+ require .NoError (t , grantManager .CreateGrant (ctx , grant , publicKey ))
1275+
1276+ key , err := grantStorage .GetPublicKey (ctx , issuer , subject , publicKey .KeyID )
1277+ require .NoError (t , err )
1278+ assert .Nil (t , key )
1279+ })
1280+
12561281 t .Run ("case=does not return expired values" , func (t * testing.T ) {
12571282 keySet , err := jwk .GenerateJWK (jose .RS256 , uuid .Must (uuid .NewV4 ()).String (), "sig" )
12581283 require .NoError (t , err )
0 commit comments