feat(queries): user IDP links (#2751)

This commit is contained in:
Silvan
2021-12-07 08:33:52 +01:00
committed by GitHub
parent 2ad03285f1
commit 303d4945a7
13 changed files with 394 additions and 37 deletions

View File

@@ -134,6 +134,7 @@ const (
IDPStylingTypeCol = "styling_type"
IDPOwnerTypeCol = "owner_type"
IDPAutoRegisterCol = "auto_register"
IDPTypeCol = "type"
OIDCConfigIDPIDCol = "idp_id"
OIDCConfigClientIDCol = "client_id"
@@ -311,6 +312,7 @@ func (p *IDPProjection) reduceOIDCConfigAdded(event eventstore.EventReader) (*ha
[]handler.Column{
handler.NewCol(IDPChangeDateCol, idpEvent.CreationDate()),
handler.NewCol(IDPSequenceCol, idpEvent.Sequence()),
handler.NewCol(IDPTypeCol, domain.IDPConfigTypeOIDC),
},
[]handler.Condition{
handler.NewCond(IDPIDCol, idpEvent.IDPConfigID),
@@ -413,6 +415,7 @@ func (p *IDPProjection) reduceJWTConfigAdded(event eventstore.EventReader) (*han
[]handler.Column{
handler.NewCol(IDPChangeDateCol, idpEvent.CreationDate()),
handler.NewCol(IDPSequenceCol, idpEvent.Sequence()),
handler.NewCol(IDPTypeCol, domain.IDPConfigTypeJWT),
},
[]handler.Condition{
handler.NewCond(IDPIDCol, idpEvent.IDPConfigID),

View File

@@ -227,10 +227,11 @@ func TestIDPProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
expectedStmt: "UPDATE zitadel.projections.idps SET (change_date, sequence) = ($1, $2) WHERE (id = $3)",
expectedStmt: "UPDATE zitadel.projections.idps SET (change_date, sequence, type) = ($1, $2, $3) WHERE (id = $4)",
expectedArgs: []interface{}{
anyArg{},
uint64(15),
domain.IDPConfigTypeOIDC,
"idp-config-id",
},
},
@@ -353,10 +354,11 @@ func TestIDPProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
expectedStmt: "UPDATE zitadel.projections.idps SET (change_date, sequence) = ($1, $2) WHERE (id = $3)",
expectedStmt: "UPDATE zitadel.projections.idps SET (change_date, sequence, type) = ($1, $2, $3) WHERE (id = $4)",
expectedArgs: []interface{}{
anyArg{},
uint64(15),
domain.IDPConfigTypeJWT,
"idp-config-id",
},
},
@@ -643,10 +645,11 @@ func TestIDPProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
expectedStmt: "UPDATE zitadel.projections.idps SET (change_date, sequence) = ($1, $2) WHERE (id = $3)",
expectedStmt: "UPDATE zitadel.projections.idps SET (change_date, sequence, type) = ($1, $2, $3) WHERE (id = $4)",
expectedArgs: []interface{}{
anyArg{},
uint64(15),
domain.IDPConfigTypeOIDC,
"idp-config-id",
},
},
@@ -769,10 +772,11 @@ func TestIDPProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
expectedStmt: "UPDATE zitadel.projections.idps SET (change_date, sequence) = ($1, $2) WHERE (id = $3)",
expectedStmt: "UPDATE zitadel.projections.idps SET (change_date, sequence, type) = ($1, $2, $3) WHERE (id = $4)",
expectedArgs: []interface{}{
anyArg{},
uint64(15),
domain.IDPConfigTypeJWT,
"idp-config-id",
},
},

View File

@@ -15,10 +15,6 @@ type IDPUserLinkProjection struct {
crdb.StatementHandler
}
const (
IDPUserLinkTable = "zitadel.projections.idp_user_links"
)
func NewIDPUserLinkProjection(ctx context.Context, config crdb.StatementHandlerConfig) *IDPUserLinkProjection {
p := &IDPUserLinkProjection{}
config.ProjectionName = IDPUserLinkTable
@@ -50,6 +46,7 @@ func (p *IDPUserLinkProjection) reducers() []handler.AggregateReducer {
}
const (
IDPUserLinkTable = "zitadel.projections.idp_user_links"
IDPUserLinkIDPIDCol = "idp_id"
IDPUserLinkUserIDCol = "user_id"
IDPUserLinkExternalUserIDCol = "external_user_id"