2022-09-02 21:30:50 +02:00
|
|
|
package entity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/photoprism/photoprism/internal/acl"
|
2023-03-09 15:12:10 +01:00
|
|
|
"github.com/photoprism/photoprism/pkg/authn"
|
2022-09-02 21:30:50 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type UserMap map[string]User
|
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
// Get returns a user fixture for use in tests.
|
2022-09-02 21:30:50 +02:00
|
|
|
func (m UserMap) Get(name string) User {
|
|
|
|
if result, ok := m[name]; ok {
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
return User{}
|
|
|
|
}
|
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
// Pointer returns a user fixture pointer for use in tests.
|
2022-09-02 21:30:50 +02:00
|
|
|
func (m UserMap) Pointer(name string) *User {
|
|
|
|
if result, ok := m[name]; ok {
|
|
|
|
return &result
|
|
|
|
}
|
|
|
|
|
|
|
|
return &User{}
|
|
|
|
}
|
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
// UserFixtures specifies user fixtures for use in tests.
|
2022-09-02 21:30:50 +02:00
|
|
|
var UserFixtures = UserMap{
|
|
|
|
"alice": {
|
2023-03-09 15:12:10 +01:00
|
|
|
ID: 5,
|
|
|
|
UserUID: "uqxetse3cy5eo9z2",
|
|
|
|
UserName: "alice",
|
|
|
|
DisplayName: "Alice",
|
|
|
|
UserEmail: "alice@example.com",
|
|
|
|
UserRole: acl.RoleAdmin.String(),
|
|
|
|
AuthProvider: authn.ProviderLocal.String(),
|
|
|
|
SuperAdmin: true,
|
|
|
|
CanLogin: true,
|
|
|
|
WebDAV: true,
|
|
|
|
CanInvite: true,
|
|
|
|
InviteToken: GenerateToken(),
|
2022-09-28 09:01:17 +02:00
|
|
|
UserSettings: &UserSettings{
|
|
|
|
UITheme: "",
|
|
|
|
MapsStyle: "",
|
|
|
|
MapsAnimate: -1,
|
|
|
|
UILanguage: "",
|
|
|
|
UITimeZone: "",
|
|
|
|
},
|
|
|
|
UserDetails: &UserDetails{
|
|
|
|
NickName: "Lys",
|
|
|
|
UserGender: GenderFemale,
|
|
|
|
},
|
2022-09-02 21:30:50 +02:00
|
|
|
},
|
|
|
|
"bob": {
|
2023-03-09 15:12:10 +01:00
|
|
|
ID: 7,
|
|
|
|
UserUID: "uqxc08w3d0ej2283",
|
|
|
|
UserName: "bob",
|
|
|
|
DisplayName: "Robert Rich",
|
|
|
|
UserEmail: "bob@example.com",
|
|
|
|
UserRole: acl.RoleAdmin.String(),
|
|
|
|
AuthProvider: authn.ProviderLocal.String(),
|
|
|
|
SuperAdmin: false,
|
|
|
|
CanLogin: true,
|
|
|
|
WebDAV: true,
|
|
|
|
CanInvite: false,
|
2022-09-28 09:01:17 +02:00
|
|
|
UserSettings: &UserSettings{
|
|
|
|
UITheme: "grayscale",
|
|
|
|
MapsStyle: "topographique",
|
|
|
|
MapsAnimate: 6250,
|
|
|
|
UILanguage: "pt_BR",
|
|
|
|
UITimeZone: "",
|
|
|
|
},
|
|
|
|
UserDetails: &UserDetails{
|
|
|
|
NickName: "Bob",
|
|
|
|
UserGender: GenderMale,
|
|
|
|
BirthDay: 22,
|
|
|
|
BirthMonth: 1,
|
|
|
|
BirthYear: 1981,
|
|
|
|
},
|
2022-09-02 21:30:50 +02:00
|
|
|
},
|
|
|
|
"friend": {
|
2023-03-09 15:12:10 +01:00
|
|
|
ID: 8,
|
|
|
|
UserUID: "uqxqg7i1kperxvu7",
|
|
|
|
UserName: "friend",
|
|
|
|
UserEmail: "friend@example.com",
|
|
|
|
UserRole: acl.RoleAdmin.String(),
|
|
|
|
AuthProvider: authn.ProviderLocal.String(),
|
|
|
|
SuperAdmin: false,
|
|
|
|
DisplayName: "Guy Friend",
|
|
|
|
CanLogin: true,
|
|
|
|
WebDAV: false,
|
|
|
|
CanInvite: false,
|
2022-09-28 09:01:17 +02:00
|
|
|
UserSettings: &UserSettings{
|
|
|
|
UITheme: "gemstone",
|
|
|
|
MapsStyle: "hybrid",
|
|
|
|
MapsAnimate: 0,
|
|
|
|
UILanguage: "es_US",
|
|
|
|
UITimeZone: "America/Los_Angeles",
|
|
|
|
},
|
|
|
|
UserDetails: &UserDetails{
|
|
|
|
UserGender: GenderOther,
|
|
|
|
},
|
2022-09-02 21:30:50 +02:00
|
|
|
},
|
|
|
|
"deleted": {
|
2023-03-09 15:12:10 +01:00
|
|
|
ID: 10000008,
|
|
|
|
UserUID: "uqxqg7i1kperxvu8",
|
|
|
|
UserName: "deleted",
|
|
|
|
UserEmail: "",
|
|
|
|
DisplayName: "Deleted User",
|
|
|
|
SuperAdmin: false,
|
|
|
|
UserRole: acl.RoleVisitor.String(),
|
|
|
|
AuthProvider: authn.ProviderLocal.String(),
|
|
|
|
CanLogin: false,
|
|
|
|
WebDAV: true,
|
|
|
|
CanInvite: false,
|
|
|
|
DeletedAt: TimePointer(),
|
2022-09-28 09:01:17 +02:00
|
|
|
UserSettings: &UserSettings{
|
|
|
|
UITheme: "",
|
|
|
|
MapsStyle: "",
|
|
|
|
MapsAnimate: 0,
|
|
|
|
UILanguage: "de",
|
|
|
|
UITimeZone: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"unauthorized": {
|
2023-03-09 15:12:10 +01:00
|
|
|
ID: 10000009,
|
|
|
|
UserUID: "uriku0138hqql4bz",
|
|
|
|
UserName: "jens.mander",
|
|
|
|
UserEmail: "jens.mander@microsoft.com",
|
|
|
|
UserRole: acl.RoleUnknown.String(),
|
|
|
|
AuthProvider: authn.ProviderNone.String(),
|
|
|
|
SuperAdmin: false,
|
|
|
|
DisplayName: "Jens Mander",
|
|
|
|
CanLogin: true,
|
|
|
|
WebDAV: true,
|
|
|
|
CanInvite: false,
|
2022-09-28 09:01:17 +02:00
|
|
|
UserSettings: &UserSettings{
|
|
|
|
UITheme: "",
|
|
|
|
MapsStyle: "",
|
|
|
|
MapsAnimate: 0,
|
|
|
|
UILanguage: "de",
|
|
|
|
UITimeZone: "",
|
|
|
|
},
|
|
|
|
UserDetails: &UserDetails{
|
|
|
|
UserGender: GenderMale,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"fowler": {
|
2023-03-09 15:12:10 +01:00
|
|
|
ID: 10000023,
|
|
|
|
UserUID: "urinotv3d6jedvlm",
|
|
|
|
UserName: "fowler",
|
|
|
|
DisplayName: "Martin Fowler",
|
|
|
|
UserEmail: "martin@fowler.org",
|
|
|
|
UserRole: acl.RoleAdmin.String(),
|
|
|
|
AuthProvider: authn.ProviderLocal.String(),
|
|
|
|
SuperAdmin: false,
|
|
|
|
CanLogin: true,
|
|
|
|
WebDAV: true,
|
|
|
|
CanInvite: true,
|
|
|
|
InviteToken: GenerateToken(),
|
2022-09-28 09:01:17 +02:00
|
|
|
UserSettings: &UserSettings{
|
|
|
|
UITheme: "custom",
|
|
|
|
MapsStyle: "invalid",
|
|
|
|
MapsAnimate: -1,
|
|
|
|
UILanguage: "en",
|
|
|
|
UITimeZone: "UTC",
|
|
|
|
},
|
2022-09-02 21:30:50 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
// CreateUserFixtures creates the user fixtures specified above
|
2022-09-02 21:30:50 +02:00
|
|
|
func CreateUserFixtures() {
|
|
|
|
for _, entity := range UserFixtures {
|
|
|
|
Db().Create(&entity)
|
|
|
|
}
|
|
|
|
}
|