mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 15:37:33 +00:00
fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event
This commit is contained in:
@@ -937,4 +937,55 @@ func TestServer_TestIDProviderReduces(t *testing.T) {
|
|||||||
assert.WithinRange(t, google.UpdatedAt, beforeCreate, afterCreate)
|
assert.WithinRange(t, google.UpdatedAt, beforeCreate, afterCreate)
|
||||||
}, retryDuration, tick)
|
}, retryDuration, tick)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("test instance idp jwt added reduces", func(t *testing.T) {
|
||||||
|
name := gofakeit.Name()
|
||||||
|
|
||||||
|
// add jwt
|
||||||
|
beforeCreate := time.Now().Add(-1 * time.Second)
|
||||||
|
addJWT, err := AdminClient.AddJWTProvider(CTX, &admin.AddJWTProviderRequest{
|
||||||
|
Name: name,
|
||||||
|
Issuer: "issuer",
|
||||||
|
JwtEndpoint: "jwtEndpoint",
|
||||||
|
KeysEndpoint: "keyEndpoint",
|
||||||
|
HeaderName: "headerName",
|
||||||
|
ProviderOptions: &idp_grpc.Options{
|
||||||
|
IsLinkingAllowed: false,
|
||||||
|
IsCreationAllowed: false,
|
||||||
|
IsAutoCreation: false,
|
||||||
|
IsAutoUpdate: false,
|
||||||
|
AutoLinking: idp.AutoLinkingOption_AUTO_LINKING_OPTION_EMAIL,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
afterCreate := time.Now()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
idpRepo := repository.IDProviderRepository(pool)
|
||||||
|
|
||||||
|
// check values for jwt
|
||||||
|
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(CTX, time.Second*5)
|
||||||
|
assert.EventuallyWithT(t, func(t *assert.CollectT) {
|
||||||
|
jwt, err := idpRepo.GetJWT(CTX, idpRepo.IDCondition(addJWT.Id), instanceID, nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// event instance.idp.jwt.added
|
||||||
|
// idp
|
||||||
|
assert.Equal(t, addJWT.Id, jwt.ID)
|
||||||
|
assert.Equal(t, domain.IDPTypeJWT.String(), jwt.Type)
|
||||||
|
|
||||||
|
// jwt
|
||||||
|
assert.Equal(t, addJWT.Id, jwt.ID)
|
||||||
|
assert.Equal(t, "jwtEndpoint", jwt.JWTEndpoint)
|
||||||
|
assert.Equal(t, "issuer", jwt.Issuer)
|
||||||
|
assert.Equal(t, "keyEndpoint", jwt.KeysEndpoint)
|
||||||
|
assert.Equal(t, "headerName", jwt.HeaderName)
|
||||||
|
|
||||||
|
assert.Equal(t, false, jwt.AllowLinking)
|
||||||
|
assert.Equal(t, false, jwt.AllowCreation)
|
||||||
|
assert.Equal(t, false, jwt.AllowAutoUpdate)
|
||||||
|
assert.Equal(t, domain.IDPAutoLinkingOptionEmail.String(), jwt.AllowAutoLinking)
|
||||||
|
assert.WithinRange(t, jwt.CreatedAt, beforeCreate, afterCreate)
|
||||||
|
assert.WithinRange(t, jwt.UpdatedAt, beforeCreate, afterCreate)
|
||||||
|
}, retryDuration, tick)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@@ -70,10 +70,10 @@ func (p *idpTemplateRelationalProjection) Reducers() []handler.AggregateReducer
|
|||||||
Event: instance.OIDCIDPMigratedGoogleEventType,
|
Event: instance.OIDCIDPMigratedGoogleEventType,
|
||||||
Reduce: p.reduceOIDCIDPRelationalMigratedGoogle,
|
Reduce: p.reduceOIDCIDPRelationalMigratedGoogle,
|
||||||
},
|
},
|
||||||
// {
|
{
|
||||||
// Event: instance.JWTIDPAddedEventType,
|
Event: instance.JWTIDPAddedEventType,
|
||||||
// Reduce: p.reduceJWTIDPAdded,
|
Reduce: p.reduceJWTIDPReducedAdded,
|
||||||
// },
|
},
|
||||||
// {
|
// {
|
||||||
// Event: instance.JWTIDPChangedEventType,
|
// Event: instance.JWTIDPChangedEventType,
|
||||||
// Reduce: p.reduceJWTIDPChanged,
|
// Reduce: p.reduceJWTIDPChanged,
|
||||||
@@ -349,7 +349,6 @@ func (p *idpTemplateRelationalProjection) reduceOAuthIDPRelationalAdded(event ev
|
|||||||
// default:
|
// default:
|
||||||
// }
|
// }
|
||||||
|
|
||||||
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> AZURE")
|
|
||||||
e, ok := event.(*instance.OAuthIDPAddedEvent)
|
e, ok := event.(*instance.OAuthIDPAddedEvent)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, zerrors.ThrowInvalidArgumentf(nil, "HANDL-ap9ihb", "reduce.wrong.event.type %v", []eventstore.EventType{org.OAuthIDPAddedEventType, instance.OAuthIDPAddedEventType})
|
return nil, zerrors.ThrowInvalidArgumentf(nil, "HANDL-ap9ihb", "reduce.wrong.event.type %v", []eventstore.EventType{org.OAuthIDPAddedEventType, instance.OAuthIDPAddedEventType})
|
||||||
@@ -647,54 +646,58 @@ func (p *idpTemplateRelationalProjection) reduceOIDCIDPRelationalMigratedGoogle(
|
|||||||
), nil
|
), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// func (p *idpTemplateProjection) reduceJWTIDPAdded(event eventstore.Event) (*handler.Statement, error) {
|
func (p *idpTemplateRelationalProjection) reduceJWTIDPReducedAdded(event eventstore.Event) (*handler.Statement, error) {
|
||||||
// var idpEvent idp.JWTIDPAddedEvent
|
// var e idp.JWTIDPAddedEvent
|
||||||
// var idpOwnerType domain.IdentityProviderType
|
// var idpOwnerType domain.IdentityProviderType
|
||||||
// switch e := event.(type) {
|
// switch e := event.(type) {
|
||||||
// case *org.JWTIDPAddedEvent:
|
// case *org.JWTIDPAddedEvent:
|
||||||
// idpEvent = e.JWTIDPAddedEvent
|
// idpEvent = e.JWTIDPAddedEvent
|
||||||
// idpOwnerType = domain.IdentityProviderTypeOrg
|
// idpOwnerType = domain.IdentityProviderTypeOrg
|
||||||
// case *instance.JWTIDPAddedEvent:
|
// case *instance.JWTIDPAddedEvent:
|
||||||
// idpEvent = e.JWTIDPAddedEvent
|
// idpEvent = e.JWTIDPAddedEvent
|
||||||
// idpOwnerType = domain.IdentityProviderTypeSystem
|
// idpOwnerType = domain.IdentityProviderTypeSystem
|
||||||
// default:
|
// default:
|
||||||
// return nil, zerrors.ThrowInvalidArgumentf(nil, "HANDL-xopi2s", "reduce.wrong.event.type %v", []eventstore.EventType{org.JWTIDPAddedEventType, instance.JWTIDPAddedEventType})
|
// return nil, zerrors.ThrowInvalidArgumentf(nil, "HANDL-xopi2s", "reduce.wrong.event.type %v", []eventstore.EventType{org.JWTIDPAddedEventType, instance.JWTIDPAddedEventType})
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// return handler.NewMultiStatement(
|
fmt.Println("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> JWWWWWWT")
|
||||||
// &idpEvent,
|
e, ok := event.(*instance.JWTIDPAddedEvent)
|
||||||
// handler.AddCreateStatement(
|
if !ok {
|
||||||
// []handler.Column{
|
return nil, zerrors.ThrowInvalidArgumentf(nil, "HANDL-xopi2s", "reduce.wrong.event.type %v", []eventstore.EventType{org.JWTIDPAddedEventType, instance.JWTIDPAddedEventType})
|
||||||
// handler.NewCol(IDPTemplateIDCol, idpEvent.ID),
|
}
|
||||||
// handler.NewCol(IDPTemplateCreationDateCol, idpEvent.CreationDate()),
|
|
||||||
// handler.NewCol(IDPTemplateChangeDateCol, idpEvent.CreationDate()),
|
jwt := domain.JWT{
|
||||||
// handler.NewCol(IDPTemplateSequenceCol, idpEvent.Sequence()),
|
JWTEndpoint: e.JWTEndpoint,
|
||||||
// handler.NewCol(IDPTemplateResourceOwnerCol, idpEvent.Aggregate().ResourceOwner),
|
Issuer: e.Issuer,
|
||||||
// handler.NewCol(IDPTemplateInstanceIDCol, idpEvent.Aggregate().InstanceID),
|
KeysEndpoint: e.KeysEndpoint,
|
||||||
// handler.NewCol(IDPTemplateStateCol, domain.IDPStateActive),
|
HeaderName: e.HeaderName,
|
||||||
// handler.NewCol(IDPTemplateNameCol, idpEvent.Name),
|
}
|
||||||
// handler.NewCol(IDPTemplateOwnerTypeCol, idpOwnerType),
|
|
||||||
// handler.NewCol(IDPTemplateTypeCol, domain.IDPTypeJWT),
|
payload, err := json.Marshal(jwt)
|
||||||
// handler.NewCol(IDPTemplateIsCreationAllowedCol, idpEvent.IsCreationAllowed),
|
if err != nil {
|
||||||
// handler.NewCol(IDPTemplateIsLinkingAllowedCol, idpEvent.IsLinkingAllowed),
|
return nil, err
|
||||||
// handler.NewCol(IDPTemplateIsAutoCreationCol, idpEvent.IsAutoCreation),
|
}
|
||||||
// handler.NewCol(IDPTemplateIsAutoUpdateCol, idpEvent.IsAutoUpdate),
|
|
||||||
// handler.NewCol(IDPTemplateAutoLinkingCol, idpEvent.AutoLinkingOption),
|
return handler.NewMultiStatement(
|
||||||
// },
|
e,
|
||||||
// ),
|
handler.AddCreateStatement(
|
||||||
// handler.AddCreateStatement(
|
[]handler.Column{
|
||||||
// []handler.Column{
|
handler.NewCol(IDPTemplateIDCol, e.ID),
|
||||||
// handler.NewCol(JWTIDCol, idpEvent.ID),
|
handler.NewCol(IDPTemplateInstanceIDCol, e.Aggregate().InstanceID),
|
||||||
// handler.NewCol(JWTInstanceIDCol, idpEvent.Aggregate().InstanceID),
|
handler.NewCol(IDPTemplateStateCol, domain.IDPStateActive.String()),
|
||||||
// handler.NewCol(JWTIssuerCol, idpEvent.Issuer),
|
handler.NewCol(IDPTemplateNameCol, e.Name),
|
||||||
// handler.NewCol(JWTEndpointCol, idpEvent.JWTEndpoint),
|
handler.NewCol(IDPTemplateTypeCol, domain.IDPTypeJWT.String()),
|
||||||
// handler.NewCol(JWTKeysEndpointCol, idpEvent.KeysEndpoint),
|
handler.NewCol(IDPRelationalAllowCreationCol, e.IsCreationAllowed),
|
||||||
// handler.NewCol(JWTHeaderNameCol, idpEvent.HeaderName),
|
handler.NewCol(IDPRelationalAllowLinkingCol, e.IsLinkingAllowed),
|
||||||
// },
|
handler.NewCol(IDPRelationalAllowAutoCreationCol, e.IsAutoCreation),
|
||||||
// handler.WithTableSuffix(IDPTemplateJWTSuffix),
|
handler.NewCol(IDPRelationalAllowAutoUpdateCol, e.IsAutoUpdate),
|
||||||
// ),
|
handler.NewCol(IDPRelationalAllowAutoLinkingCol, domain.IDPAutoLinkingOption(e.AutoLinkingOption).String()),
|
||||||
// ), nil
|
handler.NewCol(IDPRelationalPayloadCol, payload),
|
||||||
// }
|
handler.NewCol(CreatedAt, e.CreationDate()),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
), nil
|
||||||
|
}
|
||||||
|
|
||||||
// func (p *idpTemplateProjection) reduceJWTIDPChanged(event eventstore.Event) (*handler.Statement, error) {
|
// func (p *idpTemplateProjection) reduceJWTIDPChanged(event eventstore.Event) (*handler.Statement, error) {
|
||||||
// var idpEvent idp.JWTIDPChangedEvent
|
// var idpEvent idp.JWTIDPChangedEvent
|
||||||
|
Reference in New Issue
Block a user