mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-24 03:26:45 +00:00
feat: Feature flag for relational tables (#10599)
# Which Problems Are Solved This PR introduces a new feature flag `EnableRelationalTables` that will be used in following implementations to decide whether Zitadel should use the relational model or the event sourcing one. # TODO - [x] Implement flag at system level - [x] Display the flag on console: https://github.com/zitadel/zitadel/pull/10615 # How the Problems Are Solved - Implement loading the flag from config - Add persistence of the flag through gRPC endpoint (SetInstanceFeatures) - Implement reading of the flag through gRPC endpoint (GetInstanceFeatures) # Additional Changes Some minor refactoring to remove un-needed generics annotations # Additional Context - Closes #10574 --------- Co-authored-by: Silvan <27845747+adlerhurst@users.noreply.github.com>
This commit is contained in:
144
internal/command/instance_features_model_test.go
Normal file
144
internal/command/instance_features_model_test.go
Normal file
@@ -0,0 +1,144 @@
|
||||
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: "token exchange",
|
||||
args: args{
|
||||
features: &InstanceFeatures{},
|
||||
key: feature.KeyTokenExchange,
|
||||
value: true,
|
||||
},
|
||||
expected: &InstanceFeatures{TokenExchange: 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: "enable back channel logout",
|
||||
args: args{
|
||||
features: &InstanceFeatures{},
|
||||
key: feature.KeyEnableBackChannelLogout,
|
||||
value: true,
|
||||
},
|
||||
expected: &InstanceFeatures{EnableBackChannelLogout: 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: "console use v2 user api",
|
||||
args: args{
|
||||
features: &InstanceFeatures{},
|
||||
key: feature.KeyConsoleUseV2UserApi,
|
||||
value: true,
|
||||
},
|
||||
expected: &InstanceFeatures{ConsoleUseV2UserApi: 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)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user