feat: uniqueness (#1190)

* feat: uniqueness on events

* fix: some tests

* fix: add unique username

* fix: nice error message

* fix: add unique test

* fix: add unique test

* fix: add unique constraint to events

* fix: correct unique constraint on user events

* fix: remove user constraint

* fix: add unique constraints

* fix: add unique constraints

* fix: add unique constraints

* fix: unnique constraints without interface

* fix: unique idp config

* fix: unique constraint comments

* fix: unique constraints in one table

* fix: unique constraints error

* fix: fix unique constraint on create user

* fix: fix unique constraint on create project

* fix: fix unique constraint on idp configs
This commit is contained in:
Fabi
2021-01-21 10:49:38 +01:00
committed by GitHub
parent c2e6e782a8
commit 28bfe72930
62 changed files with 1046 additions and 313 deletions
@@ -23,6 +23,10 @@ func (e *ProjectSetEvent) Data() interface{} {
return e
}
func (e *ProjectSetEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewIAMProjectSetEvent(ctx context.Context, projectID string) *ProjectSetEvent {
return &ProjectSetEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
@@ -23,6 +23,10 @@ func (e *GlobalOrgSetEvent) Data() interface{} {
return e
}
func (e *GlobalOrgSetEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewGlobalOrgSetEventEvent(ctx context.Context, orgID string) *GlobalOrgSetEvent {
return &GlobalOrgSetEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
@@ -26,6 +26,10 @@ func (e *SetupStepEvent) Data() interface{} {
return e
}
func (e *SetupStepEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func SetupStepMapper(event *repository.Event) (eventstore.EventReader, error) {
step := &SetupStepEvent{
BaseEvent: *eventstore.BaseEventFromRepo(event),
+9 -5
View File
@@ -23,7 +23,7 @@ type IDPConfigAddedEvent struct {
func NewIDPConfigAddedEvent(
ctx context.Context,
configID string,
configID,
name string,
configType domain.IDPConfigType,
stylingType domain.IDPConfigStylingType,
@@ -31,9 +31,10 @@ func NewIDPConfigAddedEvent(
return &IDPConfigAddedEvent{
IDPConfigAddedEvent: *idpconfig.NewIDPConfigAddedEvent(
eventstore.NewBaseEventForPush(
eventstore.NewBaseEventForPushWithResourceOwner(
ctx,
IDPConfigAddedEventType,
domain.IAMID,
),
configID,
name,
@@ -87,16 +88,19 @@ type IDPConfigRemovedEvent struct {
func NewIDPConfigRemovedEvent(
ctx context.Context,
configID string,
resourceOwner,
configID,
name string,
) *IDPConfigRemovedEvent {
return &IDPConfigRemovedEvent{
IDPConfigRemovedEvent: *idpconfig.NewIDPConfigRemovedEvent(
eventstore.NewBaseEventForPush(
eventstore.NewBaseEventForPushWithResourceOwner(
ctx,
IDPConfigRemovedEventType,
resourceOwner,
),
configID,
name,
),
}
}