mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-07 07:16:54 +00:00
fix: review changes
This commit is contained in:
@@ -123,7 +123,9 @@ func (s *Server) ImportData(ctx context.Context, req *admin_pb.ImportDataRequest
|
||||
return nil, ctxTimeout.Err()
|
||||
case result := <-ch:
|
||||
logging.OnError(result.err).Errorf("error while importing: %v", result.err)
|
||||
logging.Infof("Import done: %s", result.count.getProgress())
|
||||
if result.count != nil {
|
||||
logging.Infof("Import done: %s", result.count.getProgress())
|
||||
}
|
||||
return result.ret, result.err
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -64,8 +64,9 @@ func HTTPConfigToPb(http *query.HTTP) *settings_pb.SMSProvider_Http {
|
||||
func TwilioConfigToPb(twilio *query.Twilio) *settings_pb.SMSProvider_Twilio {
|
||||
return &settings_pb.SMSProvider_Twilio{
|
||||
Twilio: &settings_pb.TwilioConfig{
|
||||
Sid: twilio.SID,
|
||||
SenderNumber: twilio.SenderNumber,
|
||||
Sid: twilio.SID,
|
||||
SenderNumber: twilio.SenderNumber,
|
||||
VerifyServiceSid: twilio.VerifyServiceSID,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -83,21 +84,23 @@ func smsStateToPb(state domain.SMSConfigState) settings_pb.SMSProviderConfigStat
|
||||
|
||||
func addSMSConfigTwilioToConfig(ctx context.Context, req *admin_pb.AddSMSProviderTwilioRequest) *command.AddTwilioConfig {
|
||||
return &command.AddTwilioConfig{
|
||||
ResourceOwner: authz.GetInstance(ctx).InstanceID(),
|
||||
Description: req.Description,
|
||||
SID: req.Sid,
|
||||
SenderNumber: req.SenderNumber,
|
||||
Token: req.Token,
|
||||
ResourceOwner: authz.GetInstance(ctx).InstanceID(),
|
||||
Description: req.Description,
|
||||
SID: req.Sid,
|
||||
SenderNumber: req.SenderNumber,
|
||||
Token: req.Token,
|
||||
VerifyServiceSID: req.VerifyServiceSid,
|
||||
}
|
||||
}
|
||||
|
||||
func updateSMSConfigTwilioToConfig(ctx context.Context, req *admin_pb.UpdateSMSProviderTwilioRequest) *command.ChangeTwilioConfig {
|
||||
return &command.ChangeTwilioConfig{
|
||||
ResourceOwner: authz.GetInstance(ctx).InstanceID(),
|
||||
ID: req.Id,
|
||||
Description: gu.Ptr(req.Description),
|
||||
SID: gu.Ptr(req.Sid),
|
||||
SenderNumber: gu.Ptr(req.SenderNumber),
|
||||
ResourceOwner: authz.GetInstance(ctx).InstanceID(),
|
||||
ID: req.Id,
|
||||
Description: gu.Ptr(req.Description),
|
||||
SID: gu.Ptr(req.Sid),
|
||||
SenderNumber: gu.Ptr(req.SenderNumber),
|
||||
VerifyServiceSID: gu.Ptr(req.VerifyServiceSid),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ func systemFeaturesToCommand(req *feature_pb.SetSystemFeaturesRequest) *command.
|
||||
TokenExchange: req.OidcTokenExchange,
|
||||
ImprovedPerformance: improvedPerformanceListToDomain(req.ImprovedPerformance),
|
||||
OIDCSingleV1SessionTermination: req.OidcSingleV1SessionTermination,
|
||||
DisableUserTokenEvent: req.DisableUserTokenEvent,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +33,7 @@ func systemFeaturesToPb(f *query.SystemFeatures) *feature_pb.GetSystemFeaturesRe
|
||||
Actions: featureSourceToFlagPb(&f.Actions),
|
||||
ImprovedPerformance: featureSourceToImprovedPerformanceFlagPb(&f.ImprovedPerformance),
|
||||
OidcSingleV1SessionTermination: featureSourceToFlagPb(&f.OIDCSingleV1SessionTermination),
|
||||
DisableUserTokenEvent: featureSourceToFlagPb(&f.DisableUserTokenEvent),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +49,7 @@ func instanceFeaturesToCommand(req *feature_pb.SetInstanceFeaturesRequest) *comm
|
||||
WebKey: req.WebKey,
|
||||
DebugOIDCParentError: req.DebugOidcParentError,
|
||||
OIDCSingleV1SessionTermination: req.OidcSingleV1SessionTermination,
|
||||
DisableUserTokenEvent: req.DisableUserTokenEvent,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +66,7 @@ func instanceFeaturesToPb(f *query.InstanceFeatures) *feature_pb.GetInstanceFeat
|
||||
WebKey: featureSourceToFlagPb(&f.WebKey),
|
||||
DebugOidcParentError: featureSourceToFlagPb(&f.DebugOIDCParentError),
|
||||
OidcSingleV1SessionTermination: featureSourceToFlagPb(&f.OIDCSingleV1SessionTermination),
|
||||
DisableUserTokenEvent: featureSourceToFlagPb(&f.DisableUserTokenEvent),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,10 @@ func Test_systemFeaturesToPb(t *testing.T) {
|
||||
Enabled: true,
|
||||
Source: feature_pb.Source_SOURCE_SYSTEM,
|
||||
},
|
||||
DisableUserTokenEvent: &feature_pb.FeatureFlag{
|
||||
Enabled: false,
|
||||
Source: feature_pb.Source_SOURCE_UNSPECIFIED,
|
||||
},
|
||||
}
|
||||
got := systemFeaturesToPb(arg)
|
||||
assert.Equal(t, want, got)
|
||||
@@ -243,6 +247,10 @@ func Test_instanceFeaturesToPb(t *testing.T) {
|
||||
Enabled: true,
|
||||
Source: feature_pb.Source_SOURCE_INSTANCE,
|
||||
},
|
||||
DisableUserTokenEvent: &feature_pb.FeatureFlag{
|
||||
Enabled: false,
|
||||
Source: feature_pb.Source_SOURCE_UNSPECIFIED,
|
||||
},
|
||||
}
|
||||
got := instanceFeaturesToPb(arg)
|
||||
assert.Equal(t, want, got)
|
||||
|
||||
@@ -31,11 +31,11 @@ func TestServer_Limits_AuditLogRetention(t *testing.T) {
|
||||
farPast := timestamppb.New(beforeTime.Add(-10 * time.Hour).UTC())
|
||||
zeroCounts := &eventCounts{}
|
||||
seededCount := requireEventually(t, iamOwnerCtx, isoInstance.Client, userID, projectID, appID, projectGrantID, func(c assert.TestingT, counts *eventCounts) {
|
||||
counts.assertAll(t, c, "seeded events are > 0", assert.Greater, zeroCounts)
|
||||
counts.assertAll(c, "seeded events are > 0", assert.Greater, zeroCounts)
|
||||
}, "wait for seeded event assertions to pass")
|
||||
produceEvents(iamOwnerCtx, t, isoInstance.Client, userID, appID, projectID, projectGrantID)
|
||||
addedCount := requireEventually(t, iamOwnerCtx, isoInstance.Client, userID, projectID, appID, projectGrantID, func(c assert.TestingT, counts *eventCounts) {
|
||||
counts.assertAll(t, c, "added events are > seeded events", assert.Greater, seededCount)
|
||||
counts.assertAll(c, "added events are > seeded events", assert.Greater, seededCount)
|
||||
}, "wait for added event assertions to pass")
|
||||
_, err := integration.SystemClient().SetLimits(CTX, &system.SetLimitsRequest{
|
||||
InstanceId: isoInstance.ID(),
|
||||
@@ -44,8 +44,8 @@ func TestServer_Limits_AuditLogRetention(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
var limitedCounts *eventCounts
|
||||
requireEventually(t, iamOwnerCtx, isoInstance.Client, userID, projectID, appID, projectGrantID, func(c assert.TestingT, counts *eventCounts) {
|
||||
counts.assertAll(t, c, "limited events < added events", assert.Less, addedCount)
|
||||
counts.assertAll(t, c, "limited events > 0", assert.Greater, zeroCounts)
|
||||
counts.assertAll(c, "limited events < added events", assert.Less, addedCount)
|
||||
counts.assertAll(c, "limited events > 0", assert.Greater, zeroCounts)
|
||||
limitedCounts = counts
|
||||
}, "wait for limited event assertions to pass")
|
||||
listedEvents, err := isoInstance.Client.Admin.ListEvents(iamOwnerCtx, &admin.ListEventsRequest{CreationDateFilter: &admin.ListEventsRequest_From{
|
||||
@@ -63,7 +63,7 @@ func TestServer_Limits_AuditLogRetention(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
requireEventually(t, iamOwnerCtx, isoInstance.Client, userID, projectID, appID, projectGrantID, func(c assert.TestingT, counts *eventCounts) {
|
||||
counts.assertAll(t, c, "with reset limit, added events are > seeded events", assert.Greater, seededCount)
|
||||
counts.assertAll(c, "with reset limit, added events are > seeded events", assert.Greater, seededCount)
|
||||
}, "wait for reset event assertions to pass")
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ func requireEventually(
|
||||
) (counts *eventCounts) {
|
||||
countTimeout := 30 * time.Second
|
||||
assertTimeout := countTimeout + time.Second
|
||||
countCtx, cancel := context.WithTimeout(ctx, countTimeout)
|
||||
countCtx, cancel := context.WithTimeout(ctx, time.Minute)
|
||||
defer cancel()
|
||||
require.EventuallyWithT(t, func(c *assert.CollectT) {
|
||||
counts = countEvents(countCtx, c, cc, userID, projectID, appID, projectGrantID)
|
||||
@@ -168,63 +168,77 @@ type eventCounts struct {
|
||||
all, myUser, aUser, grant, project, app, org int
|
||||
}
|
||||
|
||||
func (e *eventCounts) assertAll(t *testing.T, c assert.TestingT, name string, compare assert.ComparisonAssertionFunc, than *eventCounts) {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
compare(c, e.all, than.all, "ListEvents")
|
||||
compare(c, e.myUser, than.myUser, "ListMyUserChanges")
|
||||
compare(c, e.aUser, than.aUser, "ListUserChanges")
|
||||
compare(c, e.grant, than.grant, "ListProjectGrantChanges")
|
||||
compare(c, e.project, than.project, "ListProjectChanges")
|
||||
compare(c, e.app, than.app, "ListAppChanges")
|
||||
compare(c, e.org, than.org, "ListOrgChanges")
|
||||
})
|
||||
func (e *eventCounts) assertAll(c assert.TestingT, name string, compare assert.ComparisonAssertionFunc, than *eventCounts) {
|
||||
compare(c, e.all, than.all, name+"ListEvents")
|
||||
compare(c, e.myUser, than.myUser, name+"ListMyUserChanges")
|
||||
compare(c, e.aUser, than.aUser, name+"ListUserChanges")
|
||||
compare(c, e.grant, than.grant, name+"ListProjectGrantChanges")
|
||||
compare(c, e.project, than.project, name+"ListProjectChanges")
|
||||
compare(c, e.app, than.app, name+"ListAppChanges")
|
||||
compare(c, e.org, than.org, name+"ListOrgChanges")
|
||||
}
|
||||
|
||||
func countEvents(ctx context.Context, t assert.TestingT, cc *integration.Client, userID, projectID, appID, grantID string) *eventCounts {
|
||||
counts := new(eventCounts)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(7)
|
||||
|
||||
var mutex sync.Mutex
|
||||
assertResultLocked := func(err error, f func(counts *eventCounts)) {
|
||||
mutex.Lock()
|
||||
assert.NoError(t, err)
|
||||
f(counts)
|
||||
mutex.Unlock()
|
||||
}
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
result, err := cc.Admin.ListEvents(ctx, &admin.ListEventsRequest{})
|
||||
assert.NoError(t, err)
|
||||
counts.all = len(result.GetEvents())
|
||||
assertResultLocked(err, func(counts *eventCounts) {
|
||||
counts.all = len(result.GetEvents())
|
||||
})
|
||||
}()
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
result, err := cc.Auth.ListMyUserChanges(ctx, &auth.ListMyUserChangesRequest{})
|
||||
assert.NoError(t, err)
|
||||
counts.myUser = len(result.GetResult())
|
||||
assertResultLocked(err, func(counts *eventCounts) {
|
||||
counts.myUser = len(result.GetResult())
|
||||
})
|
||||
}()
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
result, err := cc.Mgmt.ListUserChanges(ctx, &management.ListUserChangesRequest{UserId: userID})
|
||||
assert.NoError(t, err)
|
||||
counts.aUser = len(result.GetResult())
|
||||
assertResultLocked(err, func(counts *eventCounts) {
|
||||
counts.aUser = len(result.GetResult())
|
||||
})
|
||||
}()
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
result, err := cc.Mgmt.ListAppChanges(ctx, &management.ListAppChangesRequest{ProjectId: projectID, AppId: appID})
|
||||
assert.NoError(t, err)
|
||||
counts.app = len(result.GetResult())
|
||||
assertResultLocked(err, func(counts *eventCounts) {
|
||||
counts.app = len(result.GetResult())
|
||||
})
|
||||
}()
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
result, err := cc.Mgmt.ListOrgChanges(ctx, &management.ListOrgChangesRequest{})
|
||||
assert.NoError(t, err)
|
||||
counts.org = len(result.GetResult())
|
||||
assertResultLocked(err, func(counts *eventCounts) {
|
||||
counts.org = len(result.GetResult())
|
||||
})
|
||||
}()
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
result, err := cc.Mgmt.ListProjectChanges(ctx, &management.ListProjectChangesRequest{ProjectId: projectID})
|
||||
assert.NoError(t, err)
|
||||
counts.project = len(result.GetResult())
|
||||
assertResultLocked(err, func(counts *eventCounts) {
|
||||
counts.project = len(result.GetResult())
|
||||
})
|
||||
}()
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
result, err := cc.Mgmt.ListProjectGrantChanges(ctx, &management.ListProjectGrantChangesRequest{ProjectId: projectID, GrantId: grantID})
|
||||
assert.NoError(t, err)
|
||||
counts.grant = len(result.GetResult())
|
||||
assertResultLocked(err, func(counts *eventCounts) {
|
||||
counts.grant = len(result.GetResult())
|
||||
})
|
||||
}()
|
||||
wg.Wait()
|
||||
return counts
|
||||
|
||||
Reference in New Issue
Block a user