mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 22:47:35 +00:00
feat: Instance commands (#3385)
* fix: add events for domain * fix: add/remove domain command side * fix: add/remove domain command side * fix: add/remove domain query side * fix: create instance * fix: merge v2 * fix: instance domain * fix: instance domain * fix: instance domain * fix: instance domain * fix: remove domain.IAMID from writemodels * fix: remove domain.IAMID from writemodels * fix: remove domain.IAMID from writemodels * fix: remove domain.IAMID from writemodels * fix: remove domain.IAMID from writemodels * fix: remove domain.IAMID from writemodels * fix: remove domain.IAMID from writemodels * fix: remove domain.IAMID from writemodels * fix: remove domain.IAMID from writemodels * fix: remove domain.IAMID from api * fix: remove domain.IAMID * fix: remove domain.IAMID * fix: add instance domain queries * fix: fix after merge * Update auth_request.go * fix keypair * remove unused code * feat: read instance id from context * feat: remove unused code * feat: use instance id from context * some fixes Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
@@ -24,8 +24,9 @@ func TestCommandSide_AddSMSConfigTwilio(t *testing.T) {
|
||||
alg crypto.EncryptionAlgorithm
|
||||
}
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
sms *twilio.TwilioConfig
|
||||
ctx context.Context
|
||||
instanceID string
|
||||
sms *twilio.TwilioConfig
|
||||
}
|
||||
type res struct {
|
||||
want *domain.ObjectDetails
|
||||
@@ -47,7 +48,7 @@ func TestCommandSide_AddSMSConfigTwilio(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(instance.NewSMSConfigTwilioAddedEvent(
|
||||
context.Background(),
|
||||
&instance.NewAggregate().Aggregate,
|
||||
&instance.NewAggregate("INSTANCE").Aggregate,
|
||||
"providerid",
|
||||
"sid",
|
||||
"senderName",
|
||||
@@ -66,7 +67,8 @@ func TestCommandSide_AddSMSConfigTwilio(t *testing.T) {
|
||||
alg: crypto.CreateMockEncryptionAlg(gomock.NewController(t)),
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
ctx: context.Background(),
|
||||
instanceID: "INSTANCE",
|
||||
sms: &twilio.TwilioConfig{
|
||||
SID: "sid",
|
||||
Token: "token",
|
||||
@@ -75,7 +77,7 @@ func TestCommandSide_AddSMSConfigTwilio(t *testing.T) {
|
||||
},
|
||||
res: res{
|
||||
want: &domain.ObjectDetails{
|
||||
ResourceOwner: "IAM",
|
||||
ResourceOwner: "INSTANCE",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -87,7 +89,7 @@ func TestCommandSide_AddSMSConfigTwilio(t *testing.T) {
|
||||
idGenerator: tt.fields.idGenerator,
|
||||
smsCrypto: tt.fields.alg,
|
||||
}
|
||||
_, got, err := r.AddSMSConfigTwilio(tt.args.ctx, tt.args.sms)
|
||||
_, got, err := r.AddSMSConfigTwilio(tt.args.ctx, tt.args.instanceID, tt.args.sms)
|
||||
if tt.res.err == nil {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
@@ -106,9 +108,10 @@ func TestCommandSide_ChangeSMSConfigTwilio(t *testing.T) {
|
||||
eventstore *eventstore.Eventstore
|
||||
}
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
id string
|
||||
sms *twilio.TwilioConfig
|
||||
ctx context.Context
|
||||
instanceID string
|
||||
id string
|
||||
sms *twilio.TwilioConfig
|
||||
}
|
||||
type res struct {
|
||||
want *domain.ObjectDetails
|
||||
@@ -144,9 +147,10 @@ func TestCommandSide_ChangeSMSConfigTwilio(t *testing.T) {
|
||||
),
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
sms: &twilio.TwilioConfig{},
|
||||
id: "id",
|
||||
ctx: context.Background(),
|
||||
sms: &twilio.TwilioConfig{},
|
||||
instanceID: "INSTANCE",
|
||||
id: "id",
|
||||
},
|
||||
res: res{
|
||||
err: caos_errs.IsNotFound,
|
||||
@@ -161,7 +165,7 @@ func TestCommandSide_ChangeSMSConfigTwilio(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
instance.NewSMSConfigTwilioAddedEvent(
|
||||
context.Background(),
|
||||
&instance.NewAggregate().Aggregate,
|
||||
&instance.NewAggregate("INSTANCE").Aggregate,
|
||||
"providerid",
|
||||
"sid",
|
||||
"senderName",
|
||||
@@ -183,7 +187,8 @@ func TestCommandSide_ChangeSMSConfigTwilio(t *testing.T) {
|
||||
Token: "token",
|
||||
SenderNumber: "senderName",
|
||||
},
|
||||
id: "providerid",
|
||||
instanceID: "INSTANCE",
|
||||
id: "providerid",
|
||||
},
|
||||
res: res{
|
||||
err: caos_errs.IsPreconditionFailed,
|
||||
@@ -198,7 +203,7 @@ func TestCommandSide_ChangeSMSConfigTwilio(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
instance.NewSMSConfigTwilioAddedEvent(
|
||||
context.Background(),
|
||||
&instance.NewAggregate().Aggregate,
|
||||
&instance.NewAggregate("INSTANCE").Aggregate,
|
||||
"providerid",
|
||||
"sid",
|
||||
"token",
|
||||
@@ -232,11 +237,12 @@ func TestCommandSide_ChangeSMSConfigTwilio(t *testing.T) {
|
||||
Token: "token2",
|
||||
SenderNumber: "senderName2",
|
||||
},
|
||||
id: "providerid",
|
||||
instanceID: "INSTANCE",
|
||||
id: "providerid",
|
||||
},
|
||||
res: res{
|
||||
want: &domain.ObjectDetails{
|
||||
ResourceOwner: "IAM",
|
||||
ResourceOwner: "INSTANCE",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -246,7 +252,7 @@ func TestCommandSide_ChangeSMSConfigTwilio(t *testing.T) {
|
||||
r := &Commands{
|
||||
eventstore: tt.fields.eventstore,
|
||||
}
|
||||
got, err := r.ChangeSMSConfigTwilio(tt.args.ctx, tt.args.id, tt.args.sms)
|
||||
got, err := r.ChangeSMSConfigTwilio(tt.args.ctx, tt.args.instanceID, tt.args.id, tt.args.sms)
|
||||
if tt.res.err == nil {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
@@ -265,8 +271,9 @@ func TestCommandSide_ActivateSMSConfigTwilio(t *testing.T) {
|
||||
eventstore *eventstore.Eventstore
|
||||
}
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
id string
|
||||
ctx context.Context
|
||||
instanceID string
|
||||
id string
|
||||
}
|
||||
type res struct {
|
||||
want *domain.ObjectDetails
|
||||
@@ -301,8 +308,9 @@ func TestCommandSide_ActivateSMSConfigTwilio(t *testing.T) {
|
||||
),
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
id: "id",
|
||||
ctx: context.Background(),
|
||||
instanceID: "INSTANCE",
|
||||
id: "id",
|
||||
},
|
||||
res: res{
|
||||
err: caos_errs.IsNotFound,
|
||||
@@ -317,7 +325,7 @@ func TestCommandSide_ActivateSMSConfigTwilio(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
instance.NewSMSConfigTwilioAddedEvent(
|
||||
context.Background(),
|
||||
&instance.NewAggregate().Aggregate,
|
||||
&instance.NewAggregate("INSTANCE").Aggregate,
|
||||
"providerid",
|
||||
"sid",
|
||||
"sender-name",
|
||||
@@ -330,7 +338,7 @@ func TestCommandSide_ActivateSMSConfigTwilio(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
instance.NewSMSConfigTwilioActivatedEvent(
|
||||
context.Background(),
|
||||
&instance.NewAggregate().Aggregate,
|
||||
&instance.NewAggregate("INSTANCE").Aggregate,
|
||||
"providerid",
|
||||
),
|
||||
),
|
||||
@@ -339,12 +347,13 @@ func TestCommandSide_ActivateSMSConfigTwilio(t *testing.T) {
|
||||
),
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
id: "providerid",
|
||||
ctx: context.Background(),
|
||||
instanceID: "INSTANCE",
|
||||
id: "providerid",
|
||||
},
|
||||
res: res{
|
||||
want: &domain.ObjectDetails{
|
||||
ResourceOwner: "IAM",
|
||||
ResourceOwner: "INSTANCE",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -354,7 +363,7 @@ func TestCommandSide_ActivateSMSConfigTwilio(t *testing.T) {
|
||||
r := &Commands{
|
||||
eventstore: tt.fields.eventstore,
|
||||
}
|
||||
got, err := r.ActivateSMSConfigTwilio(tt.args.ctx, tt.args.id)
|
||||
got, err := r.ActivateSMSConfigTwilio(tt.args.ctx, tt.args.instanceID, tt.args.id)
|
||||
if tt.res.err == nil {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
@@ -373,8 +382,9 @@ func TestCommandSide_DeactivateSMSConfigTwilio(t *testing.T) {
|
||||
eventstore *eventstore.Eventstore
|
||||
}
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
id string
|
||||
ctx context.Context
|
||||
instanceID string
|
||||
id string
|
||||
}
|
||||
type res struct {
|
||||
want *domain.ObjectDetails
|
||||
@@ -409,8 +419,9 @@ func TestCommandSide_DeactivateSMSConfigTwilio(t *testing.T) {
|
||||
),
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
id: "id",
|
||||
ctx: context.Background(),
|
||||
instanceID: "INSTANCE",
|
||||
id: "id",
|
||||
},
|
||||
res: res{
|
||||
err: caos_errs.IsNotFound,
|
||||
@@ -425,7 +436,7 @@ func TestCommandSide_DeactivateSMSConfigTwilio(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
instance.NewSMSConfigTwilioAddedEvent(
|
||||
context.Background(),
|
||||
&instance.NewAggregate().Aggregate,
|
||||
&instance.NewAggregate("INSTANCE").Aggregate,
|
||||
"providerid",
|
||||
"sid",
|
||||
"sender-name",
|
||||
@@ -435,7 +446,7 @@ func TestCommandSide_DeactivateSMSConfigTwilio(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
instance.NewSMSConfigTwilioActivatedEvent(
|
||||
context.Background(),
|
||||
&instance.NewAggregate().Aggregate,
|
||||
&instance.NewAggregate("INSTANCE").Aggregate,
|
||||
"providerid",
|
||||
),
|
||||
),
|
||||
@@ -445,7 +456,7 @@ func TestCommandSide_DeactivateSMSConfigTwilio(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
instance.NewSMSConfigDeactivatedEvent(
|
||||
context.Background(),
|
||||
&instance.NewAggregate().Aggregate,
|
||||
&instance.NewAggregate("INSTANCE").Aggregate,
|
||||
"providerid",
|
||||
),
|
||||
),
|
||||
@@ -454,12 +465,13 @@ func TestCommandSide_DeactivateSMSConfigTwilio(t *testing.T) {
|
||||
),
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
id: "providerid",
|
||||
ctx: context.Background(),
|
||||
instanceID: "INSTANCE",
|
||||
id: "providerid",
|
||||
},
|
||||
res: res{
|
||||
want: &domain.ObjectDetails{
|
||||
ResourceOwner: "IAM",
|
||||
ResourceOwner: "INSTANCE",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -469,7 +481,7 @@ func TestCommandSide_DeactivateSMSConfigTwilio(t *testing.T) {
|
||||
r := &Commands{
|
||||
eventstore: tt.fields.eventstore,
|
||||
}
|
||||
got, err := r.DeactivateSMSConfigTwilio(tt.args.ctx, tt.args.id)
|
||||
got, err := r.DeactivateSMSConfigTwilio(tt.args.ctx, tt.args.instanceID, tt.args.id)
|
||||
if tt.res.err == nil {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
@@ -488,8 +500,9 @@ func TestCommandSide_RemoveSMSConfigTwilio(t *testing.T) {
|
||||
eventstore *eventstore.Eventstore
|
||||
}
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
id string
|
||||
ctx context.Context
|
||||
instanceID string
|
||||
id string
|
||||
}
|
||||
type res struct {
|
||||
want *domain.ObjectDetails
|
||||
@@ -524,8 +537,9 @@ func TestCommandSide_RemoveSMSConfigTwilio(t *testing.T) {
|
||||
),
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
id: "id",
|
||||
ctx: context.Background(),
|
||||
instanceID: "INSTANCE",
|
||||
id: "id",
|
||||
},
|
||||
res: res{
|
||||
err: caos_errs.IsNotFound,
|
||||
@@ -540,7 +554,7 @@ func TestCommandSide_RemoveSMSConfigTwilio(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
instance.NewSMSConfigTwilioAddedEvent(
|
||||
context.Background(),
|
||||
&instance.NewAggregate().Aggregate,
|
||||
&instance.NewAggregate("INSTANCE").Aggregate,
|
||||
"providerid",
|
||||
"sid",
|
||||
"sender-name",
|
||||
@@ -553,7 +567,7 @@ func TestCommandSide_RemoveSMSConfigTwilio(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
instance.NewSMSConfigRemovedEvent(
|
||||
context.Background(),
|
||||
&instance.NewAggregate().Aggregate,
|
||||
&instance.NewAggregate("INSTANCE").Aggregate,
|
||||
"providerid",
|
||||
),
|
||||
),
|
||||
@@ -562,12 +576,13 @@ func TestCommandSide_RemoveSMSConfigTwilio(t *testing.T) {
|
||||
),
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
id: "providerid",
|
||||
ctx: context.Background(),
|
||||
instanceID: "INSTANCE",
|
||||
id: "providerid",
|
||||
},
|
||||
res: res{
|
||||
want: &domain.ObjectDetails{
|
||||
ResourceOwner: "IAM",
|
||||
ResourceOwner: "INSTANCE",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -577,7 +592,7 @@ func TestCommandSide_RemoveSMSConfigTwilio(t *testing.T) {
|
||||
r := &Commands{
|
||||
eventstore: tt.fields.eventstore,
|
||||
}
|
||||
got, err := r.RemoveSMSConfigTwilio(tt.args.ctx, tt.args.id)
|
||||
got, err := r.RemoveSMSConfigTwilio(tt.args.ctx, tt.args.instanceID, tt.args.id)
|
||||
if tt.res.err == nil {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
@@ -597,7 +612,7 @@ func newSMSConfigTwilioChangedEvent(ctx context.Context, id, sid, senderName str
|
||||
instance.ChangeSMSConfigTwilioSenderNumber(senderName),
|
||||
}
|
||||
event, _ := instance.NewSMSConfigTwilioChangedEvent(ctx,
|
||||
&instance.NewAggregate().Aggregate,
|
||||
&instance.NewAggregate("INSTANCE").Aggregate,
|
||||
id,
|
||||
changes,
|
||||
)
|
||||
|
Reference in New Issue
Block a user