2024-05-25 05:20:58 -05:00
|
|
|
// Copyright The Forgejo Authors.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
package setting
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/container"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2024-07-30 14:41:10 -05:00
|
|
|
"github.com/stretchr/testify/require"
|
2024-05-25 05:20:58 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func Test_loadAdminFrom(t *testing.T) {
|
|
|
|
iniStr := `
|
|
|
|
[admin]
|
|
|
|
DISABLE_REGULAR_ORG_CREATION = true
|
|
|
|
DEFAULT_EMAIL_NOTIFICATIONS = z
|
|
|
|
SEND_NOTIFICATION_EMAIL_ON_NEW_USER = true
|
|
|
|
USER_DISABLED_FEATURES = a,b
|
|
|
|
EXTERNAL_USER_DISABLE_FEATURES = x,y
|
|
|
|
`
|
|
|
|
cfg, err := NewConfigProviderFromData(iniStr)
|
2024-07-30 14:41:10 -05:00
|
|
|
require.NoError(t, err)
|
2024-05-25 05:20:58 -05:00
|
|
|
loadAdminFrom(cfg)
|
|
|
|
|
2024-07-30 14:41:10 -05:00
|
|
|
assert.True(t, Admin.DisableRegularOrgCreation)
|
2024-05-25 05:20:58 -05:00
|
|
|
assert.EqualValues(t, "z", Admin.DefaultEmailNotification)
|
2024-07-30 14:41:10 -05:00
|
|
|
assert.True(t, Admin.SendNotificationEmailOnNewUser)
|
2024-05-25 05:20:58 -05:00
|
|
|
assert.EqualValues(t, container.SetOf("a", "b"), Admin.UserDisabledFeatures)
|
|
|
|
assert.EqualValues(t, container.SetOf("x", "y"), Admin.ExternalUserDisableFeatures)
|
|
|
|
}
|