feat: we made it better...aka i did too many things and don't remember
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package auth_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/StevanFreeborn/chirpy/internal/auth"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func TestJwtCreationAndValidation(t *testing.T) {
|
||||
userId := uuid.New()
|
||||
secret := []byte("RTCK2UTcOUkiswdrClC6Z3KmmEq/+QicpD9iRx7J0qY=")
|
||||
|
||||
jwtString, err := auth.MakeJWT(userId, secret, time.Hour)
|
||||
validatedUserId, err := auth.ValidateJWT(jwtString, secret)
|
||||
|
||||
if userId != validatedUserId {
|
||||
t.Fatalf("received %s expected %s: %v", validatedUserId, userId, err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user