photoprism/internal/entity/auth_user_fixtures_test.go
Michael Mayer 884dea17de Security: Use individual preview tokens for each user account #98
Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-10-13 22:11:02 +02:00

46 lines
1.1 KiB
Go

package entity
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/photoprism/photoprism/internal/acl"
)
func TestUserMap_Get(t *testing.T) {
t.Run("Alice", func(t *testing.T) {
r := UserFixtures.Get("alice")
assert.Equal(t, "alice", r.UserName)
assert.Equal(t, "alice", r.Name())
assert.IsType(t, User{}, r)
})
t.Run("Invalid", func(t *testing.T) {
r := UserFixtures.Get("monstera")
assert.Equal(t, "", r.UserName)
assert.Equal(t, "", r.Name())
assert.IsType(t, User{}, r)
})
}
func TestUserMap_Pointer(t *testing.T) {
t.Run("Alice", func(t *testing.T) {
r := UserFixtures.Pointer("alice")
assert.Equal(t, "alice", r.Name())
assert.Equal(t, "alice", r.UserName)
assert.Equal(t, "alice@example.com", r.Email())
assert.Equal(t, "alice@example.com", r.UserEmail)
assert.Equal(t, acl.RoleAdmin, r.AclRole())
assert.IsType(t, &User{}, r)
})
t.Run("Invalid", func(t *testing.T) {
r := UserFixtures.Pointer("monstera")
assert.Equal(t, "", r.UserName)
assert.Equal(t, "", r.Email())
assert.Equal(t, acl.RoleUnknown, r.AclRole())
assert.IsType(t, &User{}, r)
})
}