@@ -19,6 +19,7 @@ import (
1919 "github.com/stretchr/testify/suite"
2020 "github.com/supabase/auth/internal/api/apierrors"
2121 "github.com/supabase/auth/internal/conf"
22+ "github.com/supabase/auth/internal/crypto"
2223 "github.com/supabase/auth/internal/models"
2324)
2425
@@ -435,9 +436,11 @@ func (ts *TokenTestSuite) TestRefreshTokenReuseRevocation() {
435436
436437 // ensure that the 4 refresh tokens are setup correctly
437438 for i , refreshToken := range refreshTokens {
438- _ , token , _ , err := models .FindUserWithRefreshToken (ts .API .db , refreshToken , false )
439+ _ , anyToken , _ , err := models .FindUserWithRefreshToken (ts .API .db , ts . Config . Security . DBEncryption , refreshToken , false )
439440 require .NoError (ts .T (), err )
440441
442+ token := anyToken .(* models.RefreshToken )
443+
441444 if i == len (refreshTokens )- 1 {
442445 require .False (ts .T (), token .Revoked )
443446 } else {
@@ -470,9 +473,10 @@ func (ts *TokenTestSuite) TestRefreshTokenReuseRevocation() {
470473
471474 // ensure that the refresh tokens are marked as revoked in the database
472475 for _ , refreshToken := range refreshTokens {
473- _ , token , _ , err := models .FindUserWithRefreshToken (ts .API .db , refreshToken , false )
476+ _ , anyToken , _ , err := models .FindUserWithRefreshToken (ts .API .db , ts . Config . Security . DBEncryption , refreshToken , false )
474477 require .NoError (ts .T (), err )
475478
479+ token := anyToken .(* models.RefreshToken )
476480 require .True (ts .T (), token .Revoked )
477481 }
478482
@@ -887,3 +891,26 @@ $$;`
887891 })
888892 }
889893}
894+
895+ func TestRefreshTokenGrantParamsValidate (t * testing.T ) {
896+ examples := []string {
897+ "" ,
898+ "01234567890" ,
899+ "AAAAAAAAAAAA" ,
900+ "------------" ,
901+ "0000000000000" ,
902+ }
903+
904+ p := & RefreshTokenGrantParams {}
905+
906+ for _ , example := range examples {
907+ p .RefreshToken = example
908+ require .Error (t , p .Validate ())
909+ }
910+
911+ p .RefreshToken = "0123456abcde"
912+ require .NoError (t , p .Validate ())
913+
914+ p .RefreshToken = (& crypto.RefreshToken {}).Encode (make ([]byte , 32 ))
915+ require .NoError (t , p .Validate ())
916+ }
0 commit comments