2024-05-25 10:20:58 +00: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 19:42:06 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2024-05-25 10:20:58 +00: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
|
|
|
|
`
|
|
|
|
cfg, err := NewConfigProviderFromData(iniStr)
|
2024-07-30 19:42:06 +00:00
|
|
|
require.NoError(t, err)
|
2024-05-25 10:20:58 +00:00
|
|
|
loadAdminFrom(cfg)
|
|
|
|
|
2024-07-30 19:42:06 +00:00
|
|
|
assert.True(t, Admin.DisableRegularOrgCreation)
|
2024-05-25 10:20:58 +00:00
|
|
|
assert.EqualValues(t, "z", Admin.DefaultEmailNotification)
|
2024-07-30 19:42:06 +00:00
|
|
|
assert.True(t, Admin.SendNotificationEmailOnNewUser)
|
2024-05-25 10:20:58 +00:00
|
|
|
assert.EqualValues(t, container.SetOf("a", "b"), Admin.UserDisabledFeatures)
|
|
|
|
}
|