mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:17:32 +00:00
New eventstore policies (#1084)
* feat: login policy * feat: password complexity policy * feat: org iam policy * feat: label policy * feat: add and change policies * feat: second factors * feat: second and multi factors * feat: better naming * feat: better naming
This commit is contained in:
@@ -838,7 +838,7 @@ func (es *OrgEventstore) AddIDPProviderToLoginPolicy(ctx context.Context, provid
|
||||
if org.LoginPolicy == nil {
|
||||
return nil, errors.ThrowAlreadyExists(nil, "EVENT-sk9fW", "Errors.Org.LoginPolicy.NotExisting")
|
||||
}
|
||||
if _, m := org.LoginPolicy.GetIdpProvider(provider.IdpConfigID); m != nil {
|
||||
if _, m := org.LoginPolicy.GetIdpProvider(provider.IDPConfigID); m != nil {
|
||||
return nil, errors.ThrowAlreadyExists(nil, "EVENT-Lso9f", "Errors.Org.LoginPolicy.IdpProviderAlreadyExisting")
|
||||
}
|
||||
repoOrg := model.OrgFromModel(org)
|
||||
@@ -849,7 +849,7 @@ func (es *OrgEventstore) AddIDPProviderToLoginPolicy(ctx context.Context, provid
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, m := iam_es_model.GetIDPProvider(repoOrg.LoginPolicy.IDPProviders, provider.IdpConfigID); m != nil {
|
||||
if _, m := iam_es_model.GetIDPProvider(repoOrg.LoginPolicy.IDPProviders, provider.IDPConfigID); m != nil {
|
||||
return iam_es_model.IDPProviderToModel(m), nil
|
||||
}
|
||||
return nil, errors.ThrowInternal(nil, "EVENT-Slf9s", "Errors.Internal")
|
||||
@@ -863,11 +863,11 @@ func (es *OrgEventstore) PrepareRemoveIDPProviderFromLoginPolicy(ctx context.Con
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if _, m := org.LoginPolicy.GetIdpProvider(provider.IdpConfigID); m == nil {
|
||||
if _, m := org.LoginPolicy.GetIdpProvider(provider.IDPConfigID); m == nil {
|
||||
return nil, nil, errors.ThrowPreconditionFailed(nil, "EVENT-29skr", "Errors.IAM.LoginPolicy.IdpProviderNotExisting")
|
||||
}
|
||||
repoOrg := model.OrgFromModel(org)
|
||||
providerID := &iam_es_model.IDPProviderID{provider.IdpConfigID}
|
||||
providerID := &iam_es_model.IDPProviderID{provider.IDPConfigID}
|
||||
providerAggregates, err := LoginPolicyIDPProviderRemovedAggregate(ctx, es.Eventstore.AggregateCreator(), repoOrg, providerID, cascade)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
@@ -1882,7 +1882,7 @@ func TestChangeIdpConfiguration(t *testing.T) {
|
||||
t.Errorf("result has no id")
|
||||
}
|
||||
if result.IDPConfigID != tt.res.result.IDPConfigID {
|
||||
t.Errorf("got wrong result IdpConfigID: expected: %v, actual: %v ", tt.res.result.IDPConfigID, result.IDPConfigID)
|
||||
t.Errorf("got wrong result IDPConfigID: expected: %v, actual: %v ", tt.res.result.IDPConfigID, result.IDPConfigID)
|
||||
}
|
||||
if result.Name != tt.res.result.Name {
|
||||
t.Errorf("got wrong result name: expected: %v, actual: %v ", tt.res.result.Name, result.Name)
|
||||
@@ -2569,12 +2569,12 @@ func TestAddIdpProviderToLoginPolicy(t *testing.T) {
|
||||
ctx: authz.NewMockContext("orgID", "userID"),
|
||||
provider: &iam_model.IDPProvider{
|
||||
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
|
||||
IdpConfigID: "IdpConfigID2",
|
||||
IDPConfigID: "IdpConfigID2",
|
||||
Type: iam_model.IDPProviderTypeSystem,
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
result: &iam_model.IDPProvider{IdpConfigID: "IdpConfigID2"},
|
||||
result: &iam_model.IDPProvider{IDPConfigID: "IdpConfigID2"},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -2584,7 +2584,7 @@ func TestAddIdpProviderToLoginPolicy(t *testing.T) {
|
||||
ctx: authz.NewMockContext("orgID", "userID"),
|
||||
provider: &iam_model.IDPProvider{
|
||||
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
|
||||
IdpConfigID: "IDPConfigID",
|
||||
IDPConfigID: "IDPConfigID",
|
||||
Type: iam_model.IDPProviderTypeSystem,
|
||||
},
|
||||
},
|
||||
@@ -2614,7 +2614,7 @@ func TestAddIdpProviderToLoginPolicy(t *testing.T) {
|
||||
ctx: authz.NewMockContext("orgID", "userID"),
|
||||
provider: &iam_model.IDPProvider{
|
||||
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
|
||||
IdpConfigID: "IdpConfigID2",
|
||||
IDPConfigID: "IdpConfigID2",
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
@@ -2633,8 +2633,8 @@ func TestAddIdpProviderToLoginPolicy(t *testing.T) {
|
||||
if tt.res.wantErr && tt.res.errFunc(err) {
|
||||
return
|
||||
}
|
||||
if result.IdpConfigID != tt.res.result.IdpConfigID {
|
||||
t.Errorf("got wrong result IDPConfigID: expected: %v, actual: %v ", tt.res.result.IdpConfigID, result.IdpConfigID)
|
||||
if result.IDPConfigID != tt.res.result.IDPConfigID {
|
||||
t.Errorf("got wrong result IDPConfigID: expected: %v, actual: %v ", tt.res.result.IDPConfigID, result.IDPConfigID)
|
||||
}
|
||||
if result.Type != tt.res.result.Type {
|
||||
t.Errorf("got wrong result Type: expected: %v, actual: %v ", tt.res.result.Type, result.Type)
|
||||
@@ -2666,7 +2666,7 @@ func TestRemoveIdpProviderFromLoginPolicy(t *testing.T) {
|
||||
ctx: authz.NewMockContext("orgID", "userID"),
|
||||
provider: &iam_model.IDPProvider{
|
||||
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
|
||||
IdpConfigID: "IDPConfigID",
|
||||
IDPConfigID: "IDPConfigID",
|
||||
Type: iam_model.IDPProviderTypeSystem,
|
||||
},
|
||||
},
|
||||
@@ -2679,7 +2679,7 @@ func TestRemoveIdpProviderFromLoginPolicy(t *testing.T) {
|
||||
ctx: authz.NewMockContext("orgID", "userID"),
|
||||
provider: &iam_model.IDPProvider{
|
||||
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
|
||||
IdpConfigID: "IdpConfigID2",
|
||||
IDPConfigID: "IdpConfigID2",
|
||||
Type: iam_model.IDPProviderTypeSystem,
|
||||
},
|
||||
},
|
||||
@@ -2709,7 +2709,7 @@ func TestRemoveIdpProviderFromLoginPolicy(t *testing.T) {
|
||||
ctx: authz.NewMockContext("orgID", "userID"),
|
||||
provider: &iam_model.IDPProvider{
|
||||
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
|
||||
IdpConfigID: "IdpConfigID2",
|
||||
IDPConfigID: "IdpConfigID2",
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
|
Reference in New Issue
Block a user