package security

import (
	"github.com/google/uuid"
	"github.com/stretchr/testify/assert"
	"testing"
)

func TestJwtClaims(t *testing.T) {
	email := "testing@example.com"
	customerId := uuid.New()
	authTokens, err := NewAuthenticationTokens(email, customerId)
	assert.NoError(t, err)
	accessToken, err := ParseRegisteredClaimToken(authTokens.AccessToken)
	assert.NoError(t, err)
	assert.Equal(t, accessToken.Subject, email)
	assert.NoError(t, ClaimExpired(*accessToken))
	refreshToken, err := ParseRegisteredClaimToken(authTokens.RefreshToken)
	assert.NoError(t, err)
	assert.Equal(t, refreshToken.Subject, email)
	assert.NoError(t, ClaimExpired(*refreshToken))
	resetNKode, err := ResetNKodeToken(email, customerId)
	assert.NoError(t, err)
	resetToken, err := ParseRestNKodeToken(resetNKode)
	assert.NoError(t, err)
	assert.True(t, resetToken.Reset)
	assert.Equal(t, resetToken.Subject, email)
}
