photoprism/pkg/rnd/token_test.go
Michael Mayer f5a8c5a45d Auth: Session and ACL enhancements #98 #1746
Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-09-28 09:01:17 +02:00

37 lines
663 B
Go

package rnd
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestRandomToken(t *testing.T) {
t.Run("Size4", func(t *testing.T) {
token := GenerateToken(4)
assert.NotEmpty(t, token)
})
t.Run("Size8", func(t *testing.T) {
token := GenerateToken(9)
assert.NotEmpty(t, token)
})
t.Run("Log", func(t *testing.T) {
for n := 0; n < 10; n++ {
token := GenerateToken(8)
t.Logf("%d: %s", n, token)
assert.NotEmpty(t, token)
}
})
}
func BenchmarkGenerateToken4(b *testing.B) {
for n := 0; n < b.N; n++ {
GenerateToken(4)
}
}
func BenchmarkGenerateToken3(b *testing.B) {
for n := 0; n < b.N; n++ {
GenerateToken(3)
}
}