Files
zitadel/internal/integration/feature.go
T
Livio SpringandGitHub 621fd9bdec test: fix matrix for relation table tests (#11757)
# Which Problems Are Solved

In #11239 , the helper function for matrix tests (without the relational
tables enabled) was changed, but the feature was never enabled in the
matrix. Some integration tests currently can't even succeed because of
missing implementations.

# How the Problems Are Solved

This PR correctly enables the feature where intended and returns the
state into the matrix.
This allows returning early for some tests which cannot succeed yet.
Corresponding todos have been re-added as well.

# Additional Changes

None

# Additional Context

 - relates to #11239
 - requires backport to v4.x
2026-03-12 06:24:40 +00:00

69 lines
2.2 KiB
Go

package integration
import (
"context"
"testing"
"time"
"github.com/muhlemmer/gu"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/zitadel/zitadel/pkg/grpc/feature/v2"
)
func EnsureInstanceFeature(t *testing.T, ctx context.Context, instance *Instance, features *feature.SetInstanceFeaturesRequest, assertFeatures func(t *assert.CollectT, got *feature.GetInstanceFeaturesResponse)) {
ctx = instance.WithAuthorizationToken(ctx, UserTypeIAMOwner)
_, err := instance.Client.FeatureV2.SetInstanceFeatures(ctx, features)
require.NoError(t, err)
retryDuration, tick := WaitForAndTickWithMaxDuration(ctx, 5*time.Minute)
require.EventuallyWithT(t,
func(tt *assert.CollectT) {
got, err := instance.Client.FeatureV2.GetInstanceFeatures(ctx, &feature.GetInstanceFeaturesRequest{
Inheritance: true,
})
require.NoError(tt, err)
assertFeatures(tt, got)
},
retryDuration,
tick,
"timed out waiting for ensuring instance feature")
}
type RelationalTableFeatureMatrix struct {
Name string
Inst *Instance
InstOwner context.Context
Enabled bool
}
// TODO(IAM-Marco): Once we have gotten rid of eventstore, this can be removed
func RelationalTablesEnableMatrix(t *testing.T, ctx context.Context, sysAuthZ context.Context) []RelationalTableFeatureMatrix {
return []RelationalTableFeatureMatrix{
func() RelationalTableFeatureMatrix {
inst := NewInstance(sysAuthZ)
instOwner := inst.WithAuthorizationToken(ctx, UserTypeIAMOwner)
return RelationalTableFeatureMatrix{
Name: "when relational tables are disabled",
Inst: inst,
InstOwner: instOwner,
}
}(),
func() RelationalTableFeatureMatrix {
inst := NewInstance(sysAuthZ)
instOwner := inst.WithAuthorizationToken(ctx, UserTypeIAMOwner)
EnsureInstanceFeature(t, ctx, inst, &feature.SetInstanceFeaturesRequest{
EnableRelationalTables: gu.Ptr(true),
}, func(tt *assert.CollectT, got *feature.GetInstanceFeaturesResponse) {
assert.True(tt, got.GetEnableRelationalTables().GetEnabled(), "expected relational tables to be enabled")
})
return RelationalTableFeatureMatrix{
Name: "when relational tables are enabled",
Inst: inst,
InstOwner: instOwner,
Enabled: true,
}
}(),
}
}