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:
Fabi
2022-04-05 07:58:09 +02:00
committed by GitHub
parent 7d6a10015a
commit c740ee5d81
156 changed files with 6360 additions and 3951 deletions

View File

@@ -24,8 +24,9 @@ func TestCommandSide_ChangeDefaultIDPJWTConfig(t *testing.T) {
}
type (
args struct {
ctx context.Context
config *domain.JWTIDPConfig
ctx context.Context
instanceID string
config *domain.JWTIDPConfig
}
)
type res struct {
@@ -46,8 +47,9 @@ func TestCommandSide_ChangeDefaultIDPJWTConfig(t *testing.T) {
),
},
args: args{
ctx: context.Background(),
config: &domain.JWTIDPConfig{},
ctx: context.Background(),
instanceID: "INSTANCE",
config: &domain.JWTIDPConfig{},
},
res: res{
err: caos_errs.IsErrorInvalidArgument,
@@ -62,7 +64,8 @@ func TestCommandSide_ChangeDefaultIDPJWTConfig(t *testing.T) {
),
},
args: args{
ctx: context.Background(),
ctx: context.Background(),
instanceID: "INSTANCE",
config: &domain.JWTIDPConfig{
IDPConfigID: "config1",
},
@@ -79,7 +82,7 @@ func TestCommandSide_ChangeDefaultIDPJWTConfig(t *testing.T) {
expectFilter(
eventFromEventPusher(
instance.NewIDPConfigAddedEvent(context.Background(),
&instance.NewAggregate().Aggregate,
&instance.NewAggregate("INSTANCE").Aggregate,
"config1",
"name1",
domain.IDPConfigTypeJWT,
@@ -89,7 +92,7 @@ func TestCommandSide_ChangeDefaultIDPJWTConfig(t *testing.T) {
),
eventFromEventPusher(
instance.NewIDPJWTConfigAddedEvent(context.Background(),
&instance.NewAggregate().Aggregate,
&instance.NewAggregate("INSTANCE").Aggregate,
"config1",
"jwt-endpoint",
"issuer",
@@ -99,7 +102,7 @@ func TestCommandSide_ChangeDefaultIDPJWTConfig(t *testing.T) {
),
eventFromEventPusher(
instance.NewIDPConfigRemovedEvent(context.Background(),
&instance.NewAggregate().Aggregate,
&instance.NewAggregate("INSTANCE").Aggregate,
"config1",
"name",
),
@@ -108,7 +111,8 @@ func TestCommandSide_ChangeDefaultIDPJWTConfig(t *testing.T) {
),
},
args: args{
ctx: context.Background(),
ctx: context.Background(),
instanceID: "INSTANCE",
config: &domain.JWTIDPConfig{
IDPConfigID: "config1",
},
@@ -125,7 +129,7 @@ func TestCommandSide_ChangeDefaultIDPJWTConfig(t *testing.T) {
expectFilter(
eventFromEventPusher(
instance.NewIDPConfigAddedEvent(context.Background(),
&instance.NewAggregate().Aggregate,
&instance.NewAggregate("INSTANCE").Aggregate,
"config1",
"name1",
domain.IDPConfigTypeJWT,
@@ -135,7 +139,7 @@ func TestCommandSide_ChangeDefaultIDPJWTConfig(t *testing.T) {
),
eventFromEventPusher(
instance.NewIDPJWTConfigAddedEvent(context.Background(),
&instance.NewAggregate().Aggregate,
&instance.NewAggregate("INSTANCE").Aggregate,
"config1",
"jwt-endpoint",
"issuer",
@@ -148,7 +152,8 @@ func TestCommandSide_ChangeDefaultIDPJWTConfig(t *testing.T) {
secretCrypto: crypto.CreateMockEncryptionAlg(gomock.NewController(t)),
},
args: args{
ctx: context.Background(),
ctx: context.Background(),
instanceID: "INSTANCE",
config: &domain.JWTIDPConfig{
IDPConfigID: "config1",
JWTEndpoint: "jwt-endpoint",
@@ -169,7 +174,7 @@ func TestCommandSide_ChangeDefaultIDPJWTConfig(t *testing.T) {
expectFilter(
eventFromEventPusher(
instance.NewIDPConfigAddedEvent(context.Background(),
&instance.NewAggregate().Aggregate,
&instance.NewAggregate("INSTANCE").Aggregate,
"config1",
"name1",
domain.IDPConfigTypeJWT,
@@ -179,7 +184,7 @@ func TestCommandSide_ChangeDefaultIDPJWTConfig(t *testing.T) {
),
eventFromEventPusher(
instance.NewIDPJWTConfigAddedEvent(context.Background(),
&instance.NewAggregate().Aggregate,
&instance.NewAggregate("INSTANCE").Aggregate,
"config1",
"jwt-endpoint",
"issuer",
@@ -205,7 +210,8 @@ func TestCommandSide_ChangeDefaultIDPJWTConfig(t *testing.T) {
secretCrypto: crypto.CreateMockEncryptionAlg(gomock.NewController(t)),
},
args: args{
ctx: context.Background(),
ctx: context.Background(),
instanceID: "INSTANCE",
config: &domain.JWTIDPConfig{
IDPConfigID: "config1",
JWTEndpoint: "jwt-endpoint-changed",
@@ -217,8 +223,8 @@ func TestCommandSide_ChangeDefaultIDPJWTConfig(t *testing.T) {
res: res{
want: &domain.JWTIDPConfig{
ObjectRoot: models.ObjectRoot{
AggregateID: "IAM",
ResourceOwner: "IAM",
AggregateID: "INSTANCE",
ResourceOwner: "INSTANCE",
},
IDPConfigID: "config1",
JWTEndpoint: "jwt-endpoint-changed",
@@ -251,7 +257,7 @@ func TestCommandSide_ChangeDefaultIDPJWTConfig(t *testing.T) {
func newDefaultIDPJWTConfigChangedEvent(ctx context.Context, configID, jwtEndpoint, issuer, keysEndpoint, headerName string) *instance.IDPJWTConfigChangedEvent {
event, _ := instance.NewIDPJWTConfigChangedEvent(ctx,
&instance.NewAggregate().Aggregate,
&instance.NewAggregate("INSTANCE").Aggregate,
configID,
[]idpconfig.JWTConfigChanges{
idpconfig.ChangeJWTEndpoint(jwtEndpoint),