mirror of
https://github.com/zitadel/zitadel.git
synced 2026-07-25 18:28:00 +00:00
# Which Problems Are Solved #11390 renamed "Console" to "Management Console". This included a rename of the feature key to enable the management console to use the V2 API for user creation. Due to the rename generated events would also be changed, resp. existing events would be ignored, which leads to inconsistency in the data model. # How the Problems Are Solved Renamed the key back to `KeyConsoleUseV2UserApi`. And added a comment to prevent future issues. # Additional Changes None # Additional Context - relates to #11390 - backport to v4
127 lines
3.0 KiB
Go
127 lines
3.0 KiB
Go
package command
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/muhlemmer/gu"
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/zitadel/zitadel/internal/feature"
|
|
)
|
|
|
|
func Test_reduceInstanceFeature(t *testing.T) {
|
|
type args struct {
|
|
features *InstanceFeatures
|
|
key feature.Key
|
|
value any
|
|
}
|
|
tt := []struct {
|
|
name string
|
|
args args
|
|
expected *InstanceFeatures
|
|
}{
|
|
{
|
|
name: "key unspecified",
|
|
args: args{
|
|
features: &InstanceFeatures{},
|
|
key: feature.KeyUnspecified,
|
|
value: true,
|
|
},
|
|
expected: &InstanceFeatures{},
|
|
},
|
|
{
|
|
name: "login default org",
|
|
args: args{
|
|
features: &InstanceFeatures{},
|
|
key: feature.KeyLoginDefaultOrg,
|
|
value: true,
|
|
},
|
|
expected: &InstanceFeatures{LoginDefaultOrg: gu.Ptr(true)},
|
|
},
|
|
{
|
|
name: "user schema",
|
|
args: args{
|
|
features: &InstanceFeatures{},
|
|
key: feature.KeyUserSchema,
|
|
value: true,
|
|
},
|
|
expected: &InstanceFeatures{UserSchema: gu.Ptr(true)},
|
|
},
|
|
{
|
|
name: "improved performance",
|
|
args: args{
|
|
features: &InstanceFeatures{},
|
|
key: feature.KeyImprovedPerformance,
|
|
value: []feature.ImprovedPerformanceType{feature.ImprovedPerformanceTypeProject},
|
|
},
|
|
expected: &InstanceFeatures{ImprovedPerformance: []feature.ImprovedPerformanceType{feature.ImprovedPerformanceTypeProject}},
|
|
},
|
|
{
|
|
name: "debug OIDC parent error",
|
|
args: args{
|
|
features: &InstanceFeatures{},
|
|
key: feature.KeyDebugOIDCParentError,
|
|
value: true,
|
|
},
|
|
expected: &InstanceFeatures{DebugOIDCParentError: gu.Ptr(true)},
|
|
},
|
|
{
|
|
name: "OIDC single v1 session termination",
|
|
args: args{
|
|
features: &InstanceFeatures{},
|
|
key: feature.KeyOIDCSingleV1SessionTermination,
|
|
value: true,
|
|
},
|
|
expected: &InstanceFeatures{OIDCSingleV1SessionTermination: gu.Ptr(true)},
|
|
},
|
|
{
|
|
name: "login v2",
|
|
args: args{
|
|
features: &InstanceFeatures{},
|
|
key: feature.KeyLoginV2,
|
|
value: &feature.LoginV2{},
|
|
},
|
|
expected: &InstanceFeatures{LoginV2: &feature.LoginV2{}},
|
|
},
|
|
{
|
|
name: "permission check v2",
|
|
args: args{
|
|
features: &InstanceFeatures{},
|
|
key: feature.KeyPermissionCheckV2,
|
|
value: true,
|
|
},
|
|
expected: &InstanceFeatures{PermissionCheckV2: gu.Ptr(true)},
|
|
},
|
|
{
|
|
name: "management console uses v2 user api",
|
|
args: args{
|
|
features: &InstanceFeatures{},
|
|
key: feature.KeyConsoleUseV2UserApi,
|
|
value: true,
|
|
},
|
|
expected: &InstanceFeatures{ManagementConsoleUseV2UserApi: gu.Ptr(true)},
|
|
},
|
|
{
|
|
name: "enable relational tables",
|
|
args: args{
|
|
features: &InstanceFeatures{},
|
|
key: feature.KeyEnableRelationalTables,
|
|
value: true,
|
|
},
|
|
expected: &InstanceFeatures{EnableRelationalTables: gu.Ptr(true)},
|
|
},
|
|
}
|
|
|
|
for _, tc := range tt {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
// Test
|
|
reduceInstanceFeature(tc.args.features, tc.args.key, tc.args.value)
|
|
|
|
// Verify
|
|
assert.Equal(t, tc.expected, tc.args.features)
|
|
})
|
|
}
|
|
}
|