2020-07-13 17:37:43 +02:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2020-11-21 18:08:41 +01:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2022-09-28 09:01:17 +02:00
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/internal/acl"
|
2022-11-23 19:48:39 +01:00
|
|
|
"github.com/photoprism/photoprism/internal/customize"
|
2022-09-28 09:01:17 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/entity"
|
2020-07-13 17:37:43 +02:00
|
|
|
)
|
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
func TestConfig_ClientConfig(t *testing.T) {
|
|
|
|
t.Run("TestConfig", func(t *testing.T) {
|
|
|
|
c := TestConfig()
|
|
|
|
result := c.ClientPublic()
|
|
|
|
assert.IsType(t, ClientConfig{}, result)
|
2022-10-12 18:11:20 +02:00
|
|
|
assert.Equal(t, AuthModePublic, result.AuthMode)
|
2022-11-23 19:48:39 +01:00
|
|
|
assert.Equal(t, "/library/browse", result.LoginUri)
|
2022-11-22 22:14:34 +01:00
|
|
|
assert.Equal(t, "", result.RegisterUri)
|
|
|
|
assert.Equal(t, 0, result.PasswordLength)
|
|
|
|
assert.Equal(t, "", result.PasswordResetUri)
|
2022-09-28 09:01:17 +02:00
|
|
|
assert.Equal(t, true, result.Public)
|
|
|
|
})
|
|
|
|
t.Run("TestErrorConfig", func(t *testing.T) {
|
|
|
|
c := NewTestErrorConfig()
|
|
|
|
result2 := c.ClientPublic()
|
|
|
|
assert.IsType(t, ClientConfig{}, result2)
|
2022-10-12 18:11:20 +02:00
|
|
|
assert.Equal(t, AuthModePasswd, result2.AuthMode)
|
2022-09-28 09:01:17 +02:00
|
|
|
assert.Equal(t, false, result2.Public)
|
|
|
|
})
|
|
|
|
t.Run("Values", func(t *testing.T) {
|
|
|
|
c := TestConfig()
|
|
|
|
|
|
|
|
cfg := c.ClientRole(acl.RoleAdmin)
|
|
|
|
|
|
|
|
assert.IsType(t, ClientConfig{}, cfg)
|
|
|
|
|
|
|
|
if cfg.JsUri == "" {
|
|
|
|
t.Error("the JavaScript asset URI must not be empty, make sure that the frontend has been built")
|
|
|
|
}
|
|
|
|
|
|
|
|
if cfg.CssUri == "" {
|
|
|
|
t.Error("the CSS asset URI must not be empty, make sure that the frontend has been built")
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.NotEmpty(t, cfg.Name)
|
|
|
|
assert.NotEmpty(t, cfg.Version)
|
|
|
|
assert.NotEmpty(t, cfg.Copyright)
|
|
|
|
assert.NotEmpty(t, cfg.Thumbs)
|
|
|
|
assert.NotEmpty(t, cfg.ManifestUri)
|
|
|
|
assert.Equal(t, true, cfg.Debug)
|
2022-10-12 18:11:20 +02:00
|
|
|
assert.Equal(t, AuthModePublic, cfg.AuthMode)
|
2022-09-28 09:01:17 +02:00
|
|
|
assert.Equal(t, false, cfg.Demo)
|
|
|
|
assert.Equal(t, true, cfg.Sponsor)
|
|
|
|
assert.Equal(t, false, cfg.ReadOnly)
|
|
|
|
|
|
|
|
// Counts.
|
|
|
|
assert.NotEmpty(t, cfg.Count.All)
|
|
|
|
assert.NotEmpty(t, cfg.Count.Photos)
|
|
|
|
assert.LessOrEqual(t, 20, cfg.Count.Photos)
|
|
|
|
assert.LessOrEqual(t, 1, cfg.Count.Live)
|
|
|
|
assert.LessOrEqual(t, 4, cfg.Count.Videos)
|
2023-02-03 13:18:30 +01:00
|
|
|
assert.LessOrEqual(t, cfg.Count.Photos+cfg.Count.Live+cfg.Count.Videos-cfg.Count.Review, cfg.Count.All)
|
2022-09-28 09:01:17 +02:00
|
|
|
assert.LessOrEqual(t, 6, cfg.Count.Cameras)
|
|
|
|
assert.LessOrEqual(t, 1, cfg.Count.Lenses)
|
|
|
|
assert.LessOrEqual(t, 13, cfg.Count.Review)
|
|
|
|
assert.LessOrEqual(t, 1, cfg.Count.Private)
|
|
|
|
assert.LessOrEqual(t, 4, cfg.Count.Albums)
|
|
|
|
})
|
2020-07-13 17:37:43 +02:00
|
|
|
}
|
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
func TestConfig_ClientShareConfig(t *testing.T) {
|
2020-07-13 20:25:47 +02:00
|
|
|
config := TestConfig()
|
2022-09-28 09:01:17 +02:00
|
|
|
result := config.ClientShare()
|
2020-07-13 17:37:43 +02:00
|
|
|
assert.IsType(t, ClientConfig{}, result)
|
|
|
|
assert.Equal(t, true, result.Public)
|
2022-10-12 18:11:20 +02:00
|
|
|
assert.Equal(t, AuthModePublic, result.AuthMode)
|
2022-10-02 11:38:30 +02:00
|
|
|
assert.Equal(t, true, result.Experimental)
|
|
|
|
assert.Equal(t, false, result.ReadOnly)
|
2020-07-13 17:37:43 +02:00
|
|
|
}
|
2020-07-13 19:25:27 +02:00
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
func TestConfig_ClientRoleConfig(t *testing.T) {
|
|
|
|
c := NewTestConfig("config")
|
2022-10-12 18:11:20 +02:00
|
|
|
c.SetAuthMode(AuthModePasswd)
|
2022-09-28 09:01:17 +02:00
|
|
|
|
|
|
|
assert.Equal(t, AuthModePasswd, c.AuthMode())
|
|
|
|
|
|
|
|
adminFeatures := c.ClientRole(acl.RoleAdmin).Settings.Features
|
|
|
|
|
|
|
|
t.Run("RoleAdmin", func(t *testing.T) {
|
|
|
|
cfg := c.ClientRole(acl.RoleAdmin)
|
|
|
|
assert.IsType(t, ClientConfig{}, cfg)
|
2022-10-12 18:11:20 +02:00
|
|
|
assert.Equal(t, AuthModePasswd, cfg.AuthMode)
|
2022-09-28 09:01:17 +02:00
|
|
|
assert.Equal(t, false, cfg.Public)
|
|
|
|
|
|
|
|
f := cfg.Settings.Features
|
|
|
|
assert.Equal(t, adminFeatures, f)
|
|
|
|
|
|
|
|
expected := customize.FeatureSettings{
|
2022-10-15 21:54:11 +02:00
|
|
|
Account: true,
|
2022-09-28 09:01:17 +02:00
|
|
|
Albums: true,
|
|
|
|
Archive: true,
|
2023-10-08 15:42:23 +02:00
|
|
|
Delete: true,
|
2022-09-28 09:01:17 +02:00
|
|
|
Download: true,
|
|
|
|
Edit: true,
|
|
|
|
Estimates: true,
|
|
|
|
Favorites: true,
|
|
|
|
Files: true,
|
|
|
|
Folders: true,
|
|
|
|
Import: true,
|
|
|
|
Labels: true,
|
|
|
|
Library: true,
|
|
|
|
Logs: true,
|
|
|
|
Moments: true,
|
|
|
|
People: true,
|
|
|
|
Places: true,
|
|
|
|
Private: true,
|
|
|
|
Ratings: true,
|
|
|
|
Reactions: true,
|
|
|
|
Review: true,
|
|
|
|
Search: true,
|
|
|
|
Settings: true,
|
|
|
|
Share: true,
|
2022-10-15 21:54:11 +02:00
|
|
|
Services: true,
|
2022-09-28 09:01:17 +02:00
|
|
|
Upload: true,
|
|
|
|
Videos: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, expected, f)
|
|
|
|
})
|
|
|
|
t.Run("RoleVisitor", func(t *testing.T) {
|
|
|
|
cfg := c.ClientRole(acl.RoleVisitor)
|
|
|
|
f := cfg.Settings.Features
|
|
|
|
|
|
|
|
assert.NotEqual(t, adminFeatures, f)
|
|
|
|
|
|
|
|
expected := customize.FeatureSettings{
|
|
|
|
Account: false,
|
|
|
|
Albums: true,
|
|
|
|
Archive: false,
|
|
|
|
Delete: false,
|
|
|
|
Download: true,
|
|
|
|
Edit: false,
|
|
|
|
Estimates: true,
|
|
|
|
Favorites: false,
|
|
|
|
Files: false,
|
2022-10-02 11:38:30 +02:00
|
|
|
Folders: true,
|
2022-09-28 09:01:17 +02:00
|
|
|
Import: false,
|
|
|
|
Labels: false,
|
|
|
|
Library: false,
|
|
|
|
Logs: false,
|
2022-10-02 11:38:30 +02:00
|
|
|
Moments: true,
|
2022-09-28 09:01:17 +02:00
|
|
|
People: false,
|
2022-09-30 00:42:19 +02:00
|
|
|
Places: true,
|
2022-09-28 09:01:17 +02:00
|
|
|
Private: false,
|
|
|
|
Ratings: false,
|
|
|
|
Reactions: false,
|
2022-10-04 02:57:15 +02:00
|
|
|
Review: true,
|
2022-09-28 09:01:17 +02:00
|
|
|
Search: false,
|
|
|
|
Settings: false,
|
|
|
|
Share: false,
|
2022-10-15 21:54:11 +02:00
|
|
|
Services: false,
|
2022-09-28 09:01:17 +02:00
|
|
|
Upload: false,
|
|
|
|
Videos: false,
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, expected, f)
|
|
|
|
})
|
2024-01-18 16:53:05 +01:00
|
|
|
t.Run("RoleNone", func(t *testing.T) {
|
|
|
|
cfg := c.ClientRole(acl.RoleNone)
|
2022-09-28 09:01:17 +02:00
|
|
|
f := cfg.Settings.Features
|
|
|
|
|
|
|
|
assert.NotEqual(t, adminFeatures, f)
|
|
|
|
assert.False(t, f.Search)
|
|
|
|
assert.False(t, f.Videos)
|
|
|
|
assert.False(t, f.Albums)
|
|
|
|
assert.False(t, f.Moments)
|
|
|
|
assert.False(t, f.Labels)
|
|
|
|
assert.False(t, f.People)
|
|
|
|
assert.False(t, f.Settings)
|
|
|
|
assert.False(t, f.Edit)
|
|
|
|
assert.False(t, f.Private)
|
|
|
|
assert.False(t, f.Upload)
|
|
|
|
assert.False(t, f.Download)
|
2022-10-15 21:54:11 +02:00
|
|
|
assert.False(t, f.Services)
|
2022-09-28 09:01:17 +02:00
|
|
|
assert.False(t, f.Delete)
|
|
|
|
assert.False(t, f.Import)
|
|
|
|
assert.False(t, f.Library)
|
|
|
|
assert.False(t, f.Logs)
|
2022-10-04 02:57:15 +02:00
|
|
|
assert.True(t, f.Review)
|
2022-09-28 09:01:17 +02:00
|
|
|
assert.False(t, f.Share)
|
|
|
|
assert.False(t, f.Favorites)
|
|
|
|
assert.False(t, f.Reactions)
|
|
|
|
assert.False(t, f.Ratings)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestConfig_ClientSessionConfig(t *testing.T) {
|
|
|
|
c := NewTestConfig("config")
|
2022-10-13 22:11:02 +02:00
|
|
|
c.SetAuthMode(AuthModePasswd)
|
2022-09-28 09:01:17 +02:00
|
|
|
|
|
|
|
assert.Equal(t, AuthModePasswd, c.AuthMode())
|
|
|
|
|
|
|
|
adminFeatures := c.ClientRole(acl.RoleAdmin).Settings.Features
|
|
|
|
|
|
|
|
t.Run("RoleAdmin", func(t *testing.T) {
|
|
|
|
cfg := c.ClientSession(entity.SessionFixtures.Pointer("alice"))
|
|
|
|
assert.IsType(t, ClientConfig{}, cfg)
|
|
|
|
assert.Equal(t, false, cfg.Public)
|
2022-10-13 22:11:02 +02:00
|
|
|
assert.NotEmpty(t, cfg.PreviewToken)
|
|
|
|
assert.NotEmpty(t, cfg.DownloadToken)
|
2022-09-28 09:01:17 +02:00
|
|
|
|
|
|
|
f := cfg.Settings.Features
|
|
|
|
assert.Equal(t, adminFeatures, f)
|
|
|
|
|
|
|
|
assert.True(t, f.Search)
|
|
|
|
assert.True(t, f.Videos)
|
|
|
|
assert.True(t, f.Albums)
|
|
|
|
assert.True(t, f.Moments)
|
|
|
|
assert.True(t, f.Labels)
|
|
|
|
assert.True(t, f.People)
|
|
|
|
assert.True(t, f.Settings)
|
|
|
|
assert.True(t, f.Edit)
|
|
|
|
assert.True(t, f.Private)
|
|
|
|
assert.True(t, f.Upload)
|
|
|
|
assert.True(t, f.Download)
|
2022-10-15 21:54:11 +02:00
|
|
|
assert.True(t, f.Services)
|
2023-10-08 15:42:23 +02:00
|
|
|
assert.True(t, f.Delete)
|
2022-09-28 09:01:17 +02:00
|
|
|
assert.True(t, f.Import)
|
|
|
|
assert.True(t, f.Library)
|
|
|
|
assert.True(t, f.Logs)
|
|
|
|
assert.True(t, f.Review)
|
|
|
|
assert.True(t, f.Share)
|
|
|
|
})
|
2024-01-05 16:31:07 +01:00
|
|
|
t.Run("RoleAdminToken", func(t *testing.T) {
|
|
|
|
cfg := c.ClientSession(entity.SessionFixtures.Pointer("alice_token"))
|
|
|
|
|
|
|
|
assert.IsType(t, ClientConfig{}, cfg)
|
|
|
|
assert.Equal(t, false, cfg.Public)
|
|
|
|
assert.NotEmpty(t, cfg.PreviewToken)
|
|
|
|
assert.NotEmpty(t, cfg.DownloadToken)
|
|
|
|
|
|
|
|
f := cfg.Settings.Features
|
|
|
|
assert.Equal(t, adminFeatures, f)
|
|
|
|
|
|
|
|
assert.True(t, f.Search)
|
|
|
|
assert.True(t, f.Videos)
|
|
|
|
assert.True(t, f.Albums)
|
|
|
|
assert.True(t, f.Moments)
|
|
|
|
assert.True(t, f.Labels)
|
|
|
|
assert.True(t, f.People)
|
|
|
|
assert.True(t, f.Settings)
|
|
|
|
assert.True(t, f.Edit)
|
|
|
|
assert.True(t, f.Private)
|
|
|
|
assert.True(t, f.Upload)
|
|
|
|
assert.True(t, f.Download)
|
|
|
|
assert.True(t, f.Services)
|
|
|
|
assert.True(t, f.Delete)
|
|
|
|
assert.True(t, f.Import)
|
|
|
|
assert.True(t, f.Library)
|
|
|
|
assert.True(t, f.Logs)
|
|
|
|
assert.True(t, f.Review)
|
|
|
|
assert.True(t, f.Share)
|
|
|
|
})
|
|
|
|
t.Run("RoleAdminTokenScope", func(t *testing.T) {
|
|
|
|
cfg := c.ClientSession(entity.SessionFixtures.Pointer("alice_token_scope"))
|
|
|
|
|
|
|
|
assert.IsType(t, ClientConfig{}, cfg)
|
|
|
|
assert.Equal(t, false, cfg.Public)
|
|
|
|
assert.NotEmpty(t, cfg.PreviewToken)
|
|
|
|
assert.NotEmpty(t, cfg.DownloadToken)
|
|
|
|
|
|
|
|
f := cfg.Settings.Features
|
|
|
|
assert.NotEqual(t, adminFeatures, f)
|
|
|
|
|
|
|
|
assert.True(t, f.Search)
|
|
|
|
assert.True(t, f.Videos)
|
|
|
|
assert.True(t, f.Albums)
|
|
|
|
assert.False(t, f.Moments)
|
|
|
|
assert.False(t, f.Labels)
|
|
|
|
assert.False(t, f.People)
|
|
|
|
assert.False(t, f.Settings)
|
|
|
|
assert.True(t, f.Edit)
|
|
|
|
assert.True(t, f.Private)
|
|
|
|
assert.True(t, f.Upload)
|
|
|
|
assert.True(t, f.Download)
|
|
|
|
assert.False(t, f.Services)
|
|
|
|
assert.True(t, f.Delete)
|
|
|
|
assert.False(t, f.Import)
|
|
|
|
assert.False(t, f.Library)
|
|
|
|
assert.False(t, f.Logs)
|
|
|
|
assert.True(t, f.Review)
|
|
|
|
assert.False(t, f.Share)
|
|
|
|
})
|
2022-09-28 09:01:17 +02:00
|
|
|
t.Run("RoleVisitor", func(t *testing.T) {
|
|
|
|
cfg := c.ClientSession(entity.SessionFixtures.Pointer("visitor"))
|
|
|
|
|
|
|
|
assert.IsType(t, ClientConfig{}, cfg)
|
|
|
|
assert.Equal(t, false, cfg.Public)
|
2022-10-13 22:11:02 +02:00
|
|
|
assert.NotEmpty(t, cfg.PreviewToken)
|
|
|
|
assert.NotEmpty(t, cfg.DownloadToken)
|
2022-09-28 09:01:17 +02:00
|
|
|
|
|
|
|
f := cfg.Settings.Features
|
|
|
|
assert.NotEqual(t, adminFeatures, f)
|
|
|
|
|
|
|
|
assert.False(t, f.Search)
|
|
|
|
assert.False(t, f.Videos)
|
|
|
|
assert.True(t, f.Albums)
|
2022-10-02 11:38:30 +02:00
|
|
|
assert.True(t, f.Moments)
|
|
|
|
assert.True(t, f.Folders)
|
2022-09-28 09:01:17 +02:00
|
|
|
assert.False(t, f.Labels)
|
|
|
|
assert.False(t, f.People)
|
|
|
|
assert.False(t, f.Settings)
|
|
|
|
assert.False(t, f.Edit)
|
|
|
|
assert.False(t, f.Private)
|
|
|
|
assert.False(t, f.Upload)
|
|
|
|
assert.True(t, f.Download)
|
2022-10-15 21:54:11 +02:00
|
|
|
assert.False(t, f.Services)
|
2022-09-28 09:01:17 +02:00
|
|
|
assert.False(t, f.Delete)
|
|
|
|
assert.False(t, f.Import)
|
|
|
|
assert.False(t, f.Library)
|
|
|
|
assert.False(t, f.Logs)
|
2022-10-04 02:57:15 +02:00
|
|
|
assert.True(t, f.Review)
|
2022-09-28 09:01:17 +02:00
|
|
|
assert.False(t, f.Share)
|
|
|
|
})
|
2024-01-05 16:31:07 +01:00
|
|
|
t.Run("RoleVisitorTokenMetrics", func(t *testing.T) {
|
|
|
|
cfg := c.ClientSession(entity.SessionFixtures.Pointer("visitor_token_metrics"))
|
|
|
|
|
|
|
|
assert.IsType(t, ClientConfig{}, cfg)
|
|
|
|
assert.Equal(t, false, cfg.Public)
|
|
|
|
assert.NotEmpty(t, cfg.PreviewToken)
|
|
|
|
assert.NotEmpty(t, cfg.DownloadToken)
|
|
|
|
|
|
|
|
f := cfg.Settings.Features
|
|
|
|
assert.NotEqual(t, adminFeatures, f)
|
|
|
|
|
|
|
|
assert.False(t, f.Search)
|
|
|
|
assert.False(t, f.Videos)
|
|
|
|
assert.True(t, f.Albums)
|
|
|
|
assert.True(t, f.Moments)
|
|
|
|
assert.True(t, f.Folders)
|
|
|
|
assert.False(t, f.Labels)
|
|
|
|
assert.False(t, f.People)
|
|
|
|
assert.False(t, f.Settings)
|
|
|
|
assert.False(t, f.Edit)
|
|
|
|
assert.False(t, f.Private)
|
|
|
|
assert.False(t, f.Upload)
|
|
|
|
assert.True(t, f.Download)
|
|
|
|
assert.False(t, f.Services)
|
|
|
|
assert.False(t, f.Delete)
|
|
|
|
assert.False(t, f.Import)
|
|
|
|
assert.False(t, f.Library)
|
|
|
|
assert.False(t, f.Logs)
|
|
|
|
assert.True(t, f.Review)
|
|
|
|
assert.False(t, f.Share)
|
|
|
|
})
|
2024-01-18 16:53:05 +01:00
|
|
|
t.Run("RoleNone", func(t *testing.T) {
|
2022-09-28 09:01:17 +02:00
|
|
|
sess := entity.SessionFixtures.Pointer("unauthorized")
|
|
|
|
|
|
|
|
cfg := c.ClientSession(sess)
|
|
|
|
|
|
|
|
assert.IsType(t, ClientConfig{}, cfg)
|
|
|
|
assert.Equal(t, false, cfg.Public)
|
2022-10-13 22:11:02 +02:00
|
|
|
assert.NotEmpty(t, cfg.PreviewToken)
|
|
|
|
assert.NotEmpty(t, cfg.DownloadToken)
|
2022-09-28 09:01:17 +02:00
|
|
|
|
|
|
|
f := cfg.Settings.Features
|
|
|
|
assert.NotEqual(t, adminFeatures, f)
|
|
|
|
|
|
|
|
assert.False(t, f.Search)
|
|
|
|
assert.False(t, f.Videos)
|
|
|
|
assert.False(t, f.Albums)
|
|
|
|
assert.False(t, f.Moments)
|
|
|
|
assert.False(t, f.Labels)
|
|
|
|
assert.False(t, f.People)
|
|
|
|
assert.False(t, f.Settings)
|
|
|
|
assert.False(t, f.Edit)
|
|
|
|
assert.False(t, f.Private)
|
|
|
|
assert.False(t, f.Upload)
|
|
|
|
assert.False(t, f.Download)
|
2022-10-15 21:54:11 +02:00
|
|
|
assert.False(t, f.Services)
|
2022-09-28 09:01:17 +02:00
|
|
|
assert.False(t, f.Delete)
|
|
|
|
assert.False(t, f.Import)
|
|
|
|
assert.False(t, f.Library)
|
|
|
|
assert.False(t, f.Logs)
|
2022-10-04 02:57:15 +02:00
|
|
|
assert.True(t, f.Review)
|
2022-09-28 09:01:17 +02:00
|
|
|
assert.False(t, f.Share)
|
|
|
|
})
|
|
|
|
t.Run("Bob", func(t *testing.T) {
|
|
|
|
cfg := c.ClientSession(entity.SessionFixtures.Pointer("bob"))
|
|
|
|
|
|
|
|
assert.IsType(t, ClientConfig{}, cfg)
|
|
|
|
assert.Equal(t, false, cfg.Public)
|
2022-10-13 22:11:02 +02:00
|
|
|
assert.NotEmpty(t, cfg.PreviewToken)
|
|
|
|
assert.NotEmpty(t, cfg.DownloadToken)
|
2022-09-28 09:01:17 +02:00
|
|
|
f := cfg.Settings.Features
|
|
|
|
|
|
|
|
assert.True(t, f.Search)
|
|
|
|
assert.True(t, f.Videos)
|
|
|
|
assert.True(t, f.Albums)
|
|
|
|
assert.True(t, f.Moments)
|
|
|
|
assert.True(t, f.Labels)
|
|
|
|
assert.True(t, f.People)
|
|
|
|
assert.True(t, f.Settings)
|
|
|
|
assert.True(t, f.Edit)
|
|
|
|
assert.True(t, f.Private)
|
|
|
|
assert.True(t, f.Upload)
|
|
|
|
assert.True(t, f.Download)
|
2022-10-15 21:54:11 +02:00
|
|
|
assert.True(t, f.Services)
|
2023-10-08 15:42:23 +02:00
|
|
|
assert.True(t, f.Delete)
|
2022-09-28 09:01:17 +02:00
|
|
|
assert.True(t, f.Import)
|
|
|
|
assert.True(t, f.Library)
|
|
|
|
assert.True(t, f.Logs)
|
|
|
|
assert.True(t, f.Review)
|
|
|
|
assert.True(t, f.Share)
|
|
|
|
})
|
2024-01-05 16:31:07 +01:00
|
|
|
t.Run("TokenMetrics", func(t *testing.T) {
|
|
|
|
cfg := c.ClientSession(entity.SessionFixtures.Pointer("token_metrics"))
|
|
|
|
|
|
|
|
assert.IsType(t, ClientConfig{}, cfg)
|
|
|
|
assert.Equal(t, false, cfg.Public)
|
|
|
|
assert.NotEmpty(t, cfg.PreviewToken)
|
|
|
|
assert.NotEmpty(t, cfg.DownloadToken)
|
|
|
|
|
|
|
|
f := cfg.Settings.Features
|
|
|
|
assert.NotEqual(t, adminFeatures, f)
|
|
|
|
|
|
|
|
assert.False(t, f.Search)
|
|
|
|
assert.False(t, f.Videos)
|
|
|
|
assert.False(t, f.Albums)
|
|
|
|
assert.False(t, f.Moments)
|
|
|
|
assert.False(t, f.Folders)
|
|
|
|
assert.False(t, f.Labels)
|
|
|
|
assert.False(t, f.People)
|
|
|
|
assert.False(t, f.Settings)
|
|
|
|
assert.False(t, f.Edit)
|
|
|
|
assert.False(t, f.Private)
|
|
|
|
assert.False(t, f.Upload)
|
|
|
|
assert.False(t, f.Download)
|
|
|
|
assert.False(t, f.Services)
|
|
|
|
assert.False(t, f.Delete)
|
|
|
|
assert.False(t, f.Import)
|
|
|
|
assert.False(t, f.Library)
|
|
|
|
assert.False(t, f.Logs)
|
|
|
|
assert.True(t, f.Review)
|
|
|
|
assert.False(t, f.Share)
|
|
|
|
})
|
|
|
|
t.Run("TokenSettings", func(t *testing.T) {
|
|
|
|
cfg := c.ClientSession(entity.SessionFixtures.Pointer("token_settings"))
|
|
|
|
|
|
|
|
assert.IsType(t, ClientConfig{}, cfg)
|
|
|
|
assert.Equal(t, false, cfg.Public)
|
|
|
|
assert.NotEmpty(t, cfg.PreviewToken)
|
|
|
|
assert.NotEmpty(t, cfg.DownloadToken)
|
|
|
|
|
|
|
|
f := cfg.Settings.Features
|
|
|
|
assert.NotEqual(t, adminFeatures, f)
|
|
|
|
|
|
|
|
assert.True(t, f.Search)
|
|
|
|
assert.True(t, f.Videos)
|
|
|
|
assert.True(t, f.Albums)
|
|
|
|
assert.True(t, f.Moments)
|
|
|
|
assert.True(t, f.Labels)
|
|
|
|
assert.True(t, f.People)
|
|
|
|
assert.True(t, f.Settings)
|
|
|
|
assert.True(t, f.Edit)
|
|
|
|
assert.True(t, f.Private)
|
|
|
|
assert.True(t, f.Upload)
|
|
|
|
assert.True(t, f.Download)
|
|
|
|
assert.False(t, f.Services)
|
|
|
|
assert.True(t, f.Delete)
|
|
|
|
assert.True(t, f.Import)
|
|
|
|
assert.True(t, f.Library)
|
|
|
|
assert.True(t, f.Logs)
|
|
|
|
assert.True(t, f.Review)
|
|
|
|
assert.False(t, f.Share)
|
|
|
|
})
|
2022-09-28 09:01:17 +02:00
|
|
|
}
|
|
|
|
|
2020-07-13 19:25:27 +02:00
|
|
|
func TestConfig_Flags(t *testing.T) {
|
2020-07-13 20:25:47 +02:00
|
|
|
config := TestConfig()
|
2020-12-18 20:42:12 +01:00
|
|
|
config.options.Experimental = true
|
|
|
|
config.options.ReadOnly = true
|
2021-02-18 11:41:51 +01:00
|
|
|
config.settings.UI.Scrollbar = false
|
2020-07-13 19:25:27 +02:00
|
|
|
|
|
|
|
result := config.Flags()
|
2022-03-16 17:41:50 +01:00
|
|
|
assert.Equal(t, []string{"public", "debug", "test", "sponsor", "experimental", "readonly", "settings", "hide-scrollbar"}, result)
|
2020-07-13 20:25:47 +02:00
|
|
|
|
2020-12-18 20:42:12 +01:00
|
|
|
config.options.Experimental = false
|
|
|
|
config.options.ReadOnly = false
|
2020-07-13 19:25:27 +02:00
|
|
|
}
|