mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 17:48:07 +00:00
fixup! fixup! fix(org): adding unique constrants to not allow an org to be added twice with same id
This commit is contained in:
@@ -52,7 +52,7 @@ func TestServer_CreateOrganization(t *testing.T) {
|
|||||||
ctx context.Context
|
ctx context.Context
|
||||||
req *v2beta_org.CreateOrganizationRequest
|
req *v2beta_org.CreateOrganizationRequest
|
||||||
id string
|
id string
|
||||||
testfunc func(ctx context.Context, t *testing.T)
|
testFunc func(ctx context.Context, t *testing.T)
|
||||||
want *v2beta_org.CreateOrganizationResponse
|
want *v2beta_org.CreateOrganizationResponse
|
||||||
wantErr bool
|
wantErr bool
|
||||||
}
|
}
|
||||||
@@ -85,8 +85,8 @@ func TestServer_CreateOrganization(t *testing.T) {
|
|||||||
Name: orgName,
|
Name: orgName,
|
||||||
Admins: nil,
|
Admins: nil,
|
||||||
},
|
},
|
||||||
testfunc: func(ctx context.Context, t *testing.T) {
|
testFunc: func(ctx context.Context, t *testing.T) {
|
||||||
// create org initally
|
// create org initially
|
||||||
_, err := Client.CreateOrganization(ctx, &v2beta_org.CreateOrganizationRequest{
|
_, err := Client.CreateOrganization(ctx, &v2beta_org.CreateOrganizationRequest{
|
||||||
Name: orgName,
|
Name: orgName,
|
||||||
})
|
})
|
||||||
@@ -238,14 +238,15 @@ func TestServer_CreateOrganization(t *testing.T) {
|
|||||||
name: "adding org with same ID twice",
|
name: "adding org with same ID twice",
|
||||||
ctx: CTX,
|
ctx: CTX,
|
||||||
req: &v2beta_org.CreateOrganizationRequest{
|
req: &v2beta_org.CreateOrganizationRequest{
|
||||||
Name: orgID,
|
Id: &orgID,
|
||||||
|
Name: gofakeit.Name(),
|
||||||
Admins: nil,
|
Admins: nil,
|
||||||
},
|
},
|
||||||
testfunc: func(ctx context.Context, t *testing.T) {
|
testFunc: func(ctx context.Context, t *testing.T) {
|
||||||
// create org initally
|
// create org initially
|
||||||
_, err := Client.CreateOrganization(ctx, &v2beta_org.CreateOrganizationRequest{
|
_, err := Client.CreateOrganization(ctx, &v2beta_org.CreateOrganizationRequest{
|
||||||
Name: gofakeit.AppName(),
|
|
||||||
Id: &orgID,
|
Id: &orgID,
|
||||||
|
Name: gofakeit.Name(),
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
},
|
},
|
||||||
@@ -255,8 +256,8 @@ func TestServer_CreateOrganization(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
if tt.testfunc != nil {
|
if tt.testFunc != nil {
|
||||||
tt.testfunc(tt.ctx, t)
|
tt.testFunc(tt.ctx, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
got, err := Client.CreateOrganization(tt.ctx, tt.req)
|
got, err := Client.CreateOrganization(tt.ctx, tt.req)
|
||||||
|
@@ -52,7 +52,6 @@ func NewRemoveOrgNameUniqueConstraint(orgName string) *eventstore.UniqueConstrai
|
|||||||
type OrgAddedEvent struct {
|
type OrgAddedEvent struct {
|
||||||
eventstore.BaseEvent `json:"-"`
|
eventstore.BaseEvent `json:"-"`
|
||||||
|
|
||||||
ID string `json:"id,omitempty"`
|
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +60,7 @@ func (e *OrgAddedEvent) Payload() interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *OrgAddedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
func (e *OrgAddedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||||
return []*eventstore.UniqueConstraint{NewAddOrgIDUniqueConstraint(e.ID), NewAddOrgNameUniqueConstraint(e.Name)}
|
return []*eventstore.UniqueConstraint{NewAddOrgIDUniqueConstraint(e.Aggregate().ID), NewAddOrgNameUniqueConstraint(e.Name)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *OrgAddedEvent) Fields() []*eventstore.FieldOperation {
|
func (e *OrgAddedEvent) Fields() []*eventstore.FieldOperation {
|
||||||
@@ -108,7 +107,6 @@ func NewOrgAddedEvent(ctx context.Context, aggregate *eventstore.Aggregate, name
|
|||||||
aggregate,
|
aggregate,
|
||||||
OrgAddedEventType,
|
OrgAddedEventType,
|
||||||
),
|
),
|
||||||
ID: aggregate.ID,
|
|
||||||
Name: name,
|
Name: name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,7 +289,6 @@ func OrgReactivatedEventMapper(event eventstore.Event) (eventstore.Event, error)
|
|||||||
|
|
||||||
type OrgRemovedEvent struct {
|
type OrgRemovedEvent struct {
|
||||||
eventstore.BaseEvent `json:"-"`
|
eventstore.BaseEvent `json:"-"`
|
||||||
id string
|
|
||||||
name string
|
name string
|
||||||
usernames []string
|
usernames []string
|
||||||
loginMustBeDomain bool
|
loginMustBeDomain bool
|
||||||
@@ -306,7 +303,7 @@ func (e *OrgRemovedEvent) Payload() interface{} {
|
|||||||
|
|
||||||
func (e *OrgRemovedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
func (e *OrgRemovedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||||
constraints := []*eventstore.UniqueConstraint{
|
constraints := []*eventstore.UniqueConstraint{
|
||||||
NewRemoveOrgIDUniqueConstraint(e.id),
|
NewRemoveOrgIDUniqueConstraint(e.Aggregate().ID),
|
||||||
NewRemoveOrgNameUniqueConstraint(e.name),
|
NewRemoveOrgNameUniqueConstraint(e.name),
|
||||||
}
|
}
|
||||||
for _, name := range e.usernames {
|
for _, name := range e.usernames {
|
||||||
@@ -338,7 +335,6 @@ func NewOrgRemovedEvent(ctx context.Context, aggregate *eventstore.Aggregate, na
|
|||||||
aggregate,
|
aggregate,
|
||||||
OrgRemovedEventType,
|
OrgRemovedEventType,
|
||||||
),
|
),
|
||||||
id: aggregate.ID,
|
|
||||||
name: name,
|
name: name,
|
||||||
usernames: usernames,
|
usernames: usernames,
|
||||||
domains: domains,
|
domains: domains,
|
||||||
|
@@ -196,7 +196,7 @@ Errors:
|
|||||||
AlreadyExists: Екземплярът вече съществува
|
AlreadyExists: Екземплярът вече съществува
|
||||||
NotChanged: Екземплярът не е променен
|
NotChanged: Екземплярът не е променен
|
||||||
Org:
|
Org:
|
||||||
AlreadyExists: Името на организацията вече е заето
|
AlreadyExists: Името или идентификационният номер на организацията вече е зает.
|
||||||
Invalid: Организацията е невалидна
|
Invalid: Организацията е невалидна
|
||||||
AlreadyDeactivated: Организацията вече е деактивирана
|
AlreadyDeactivated: Организацията вече е деактивирана
|
||||||
AlreadyActive: Организацията вече е активна
|
AlreadyActive: Организацията вече е активна
|
||||||
|
@@ -194,7 +194,7 @@ Errors:
|
|||||||
AlreadyExists: Instance již existuje
|
AlreadyExists: Instance již existuje
|
||||||
NotChanged: Instance nezměněna
|
NotChanged: Instance nezměněna
|
||||||
Org:
|
Org:
|
||||||
AlreadyExists: Název organizace je již obsazen
|
AlreadyExists: Името или идентификационният номер на организацията вече е зает
|
||||||
Invalid: Organizace je neplatná
|
Invalid: Organizace je neplatná
|
||||||
AlreadyDeactivated: Organizace je již deaktivována
|
AlreadyDeactivated: Organizace je již deaktivována
|
||||||
AlreadyActive: Organizace je již aktivní
|
AlreadyActive: Organizace je již aktivní
|
||||||
|
@@ -194,7 +194,7 @@ Errors:
|
|||||||
AlreadyExists: Instanz exisitiert bereits
|
AlreadyExists: Instanz exisitiert bereits
|
||||||
NotChanged: Instanz wurde nicht verändert
|
NotChanged: Instanz wurde nicht verändert
|
||||||
Org:
|
Org:
|
||||||
AlreadyExists: Organisationsname existiert bereits
|
AlreadyExists: Der Name oder die ID der Organisation ist bereits vorhanden
|
||||||
Invalid: Organisation ist ungültig
|
Invalid: Organisation ist ungültig
|
||||||
AlreadyDeactivated: Organisation ist bereits deaktiviert
|
AlreadyDeactivated: Organisation ist bereits deaktiviert
|
||||||
AlreadyActive: Organisation ist bereits aktiv
|
AlreadyActive: Organisation ist bereits aktiv
|
||||||
|
@@ -194,7 +194,7 @@ Errors:
|
|||||||
AlreadyExists: La instancia ya existe
|
AlreadyExists: La instancia ya existe
|
||||||
NotChanged: La instancia no ha cambiado
|
NotChanged: La instancia no ha cambiado
|
||||||
Org:
|
Org:
|
||||||
AlreadyExists: El nombre de la organización ya está cogido
|
AlreadyExists: El nombre o id de la organización ya está tomado
|
||||||
Invalid: El nombre de la organización no es válido
|
Invalid: El nombre de la organización no es válido
|
||||||
AlreadyDeactivated: La organización ya está desactivada
|
AlreadyDeactivated: La organización ya está desactivada
|
||||||
AlreadyActive: La organización ya está activada
|
AlreadyActive: La organización ya está activada
|
||||||
|
@@ -194,7 +194,7 @@ Errors:
|
|||||||
AlreadyExists: L'instance existe déjà
|
AlreadyExists: L'instance existe déjà
|
||||||
NotChanged: L'instance n'a pas changé
|
NotChanged: L'instance n'a pas changé
|
||||||
Org:
|
Org:
|
||||||
AlreadyExists: Le nom de l'organisation est déjà pris
|
AlreadyExists: Le nom de l'organisation ou l'identifiant est déjà pris
|
||||||
Invalid: L'organisation n'est pas valide
|
Invalid: L'organisation n'est pas valide
|
||||||
AlreadyDeactivated: L'organisation est déjà désactivée
|
AlreadyDeactivated: L'organisation est déjà désactivée
|
||||||
AlreadyActive: L'organisation est déjà active
|
AlreadyActive: L'organisation est déjà active
|
||||||
|
@@ -194,7 +194,7 @@ Errors:
|
|||||||
AlreadyExists: Az instance már létezik
|
AlreadyExists: Az instance már létezik
|
||||||
NotChanged: Az instance nem változott
|
NotChanged: Az instance nem változott
|
||||||
Org:
|
Org:
|
||||||
AlreadyExists: A szervezet neve már foglalt
|
AlreadyExists: A szervezet neve vagy azonosítója már foglalt
|
||||||
Invalid: A szervezet érvénytelen
|
Invalid: A szervezet érvénytelen
|
||||||
AlreadyDeactivated: A szervezet már deaktiválva van
|
AlreadyDeactivated: A szervezet már deaktiválva van
|
||||||
AlreadyActive: A szervezet már aktív
|
AlreadyActive: A szervezet már aktív
|
||||||
|
@@ -194,7 +194,7 @@ Errors:
|
|||||||
AlreadyExists: Contoh sudah ada
|
AlreadyExists: Contoh sudah ada
|
||||||
NotChanged: Contoh tidak berubah
|
NotChanged: Contoh tidak berubah
|
||||||
Org:
|
Org:
|
||||||
AlreadyExists: Nama organisasi sudah dipakai
|
AlreadyExists: Nama atau ID organisasi sudah digunakan
|
||||||
Invalid: Organisasi tidak valid
|
Invalid: Organisasi tidak valid
|
||||||
AlreadyDeactivated: Organisasi sudah dinonaktifkan
|
AlreadyDeactivated: Organisasi sudah dinonaktifkan
|
||||||
AlreadyActive: Organisasi sudah aktif
|
AlreadyActive: Organisasi sudah aktif
|
||||||
|
@@ -194,7 +194,7 @@ Errors:
|
|||||||
AlreadyExists: L'istanza esiste già
|
AlreadyExists: L'istanza esiste già
|
||||||
NotChanged: Istanza non modificata
|
NotChanged: Istanza non modificata
|
||||||
Org:
|
Org:
|
||||||
AlreadyExists: Nome dell'organizzazione già preso
|
AlreadyExists: Nome o ID dell'organizzazione già utilizzato
|
||||||
Invalid: L'organizzazione non è valida
|
Invalid: L'organizzazione non è valida
|
||||||
AlreadyDeactivated: L'organizzazione è già disattivata
|
AlreadyDeactivated: L'organizzazione è già disattivata
|
||||||
AlreadyActive: L'organizzazione è già attiva
|
AlreadyActive: L'organizzazione è già attiva
|
||||||
|
@@ -195,7 +195,7 @@ Errors:
|
|||||||
AlreadyExists: すでに存在するインスタンス
|
AlreadyExists: すでに存在するインスタンス
|
||||||
NotChanged: インスタンスは変更されていません
|
NotChanged: インスタンスは変更されていません
|
||||||
Org:
|
Org:
|
||||||
AlreadyExists: 組織の名前はすでに使用されています
|
AlreadyExists: 組織名またはIDはすでに使用されています
|
||||||
Invalid: 無効な組織です
|
Invalid: 無効な組織です
|
||||||
AlreadyDeactivated: 組織はすでに非アクティブです
|
AlreadyDeactivated: 組織はすでに非アクティブです
|
||||||
AlreadyActive: 組織はすでにアクティブです
|
AlreadyActive: 組織はすでにアクティブです
|
||||||
|
@@ -195,7 +195,7 @@ Errors:
|
|||||||
AlreadyExists: 인스턴스가 이미 존재합니다
|
AlreadyExists: 인스턴스가 이미 존재합니다
|
||||||
NotChanged: 인스턴스가 변경되지 않았습니다
|
NotChanged: 인스턴스가 변경되지 않았습니다
|
||||||
Org:
|
Org:
|
||||||
AlreadyExists: 조직 이름이 이미 사용 중입니다
|
AlreadyExists: 조직 이름 또는 ID가 이미 사용 중입니다
|
||||||
Invalid: 조직이 유효하지 않습니다
|
Invalid: 조직이 유효하지 않습니다
|
||||||
AlreadyDeactivated: 조직이 이미 비활성화되었습니다
|
AlreadyDeactivated: 조직이 이미 비활성화되었습니다
|
||||||
AlreadyActive: 조직이 이미 활성화되었습니다
|
AlreadyActive: 조직이 이미 활성화되었습니다
|
||||||
|
@@ -193,7 +193,7 @@ Errors:
|
|||||||
AlreadyExists: Инстанцата веќе постои
|
AlreadyExists: Инстанцата веќе постои
|
||||||
NotChanged: Инстанцата не е променета
|
NotChanged: Инстанцата не е променета
|
||||||
Org:
|
Org:
|
||||||
AlreadyExists: Името на организацијата е веќе зафатено
|
AlreadyExists: Името или ID-то на организацијата е веќе зафатено
|
||||||
Invalid: Организацијата е невалидна
|
Invalid: Организацијата е невалидна
|
||||||
AlreadyDeactivated: Организацијата е веќе деактивирана
|
AlreadyDeactivated: Организацијата е веќе деактивирана
|
||||||
AlreadyActive: Организацијата е веќе активна
|
AlreadyActive: Организацијата е веќе активна
|
||||||
|
@@ -194,7 +194,7 @@ Errors:
|
|||||||
AlreadyExists: Instantie bestaat al
|
AlreadyExists: Instantie bestaat al
|
||||||
NotChanged: Instantie is niet veranderd
|
NotChanged: Instantie is niet veranderd
|
||||||
Org:
|
Org:
|
||||||
AlreadyExists: Organisatienaam is al in gebruik
|
AlreadyExists: Organisatienaam of -id is al in gebruik
|
||||||
Invalid: Organisatie is ongeldig
|
Invalid: Organisatie is ongeldig
|
||||||
AlreadyDeactivated: Organisatie is al gedeactiveerd
|
AlreadyDeactivated: Organisatie is al gedeactiveerd
|
||||||
AlreadyActive: Organisatie is al actief
|
AlreadyActive: Organisatie is al actief
|
||||||
|
@@ -194,7 +194,7 @@ Errors:
|
|||||||
AlreadyExists: Instancja już istnieje
|
AlreadyExists: Instancja już istnieje
|
||||||
NotChanged: Instancja nie zmieniona
|
NotChanged: Instancja nie zmieniona
|
||||||
Org:
|
Org:
|
||||||
AlreadyExists: Nazwa organizacji jest już zajęta
|
AlreadyExists: Nazwa lub identyfikator organizacji jest już zajęty
|
||||||
Invalid: Organizacja jest nieprawidłowa
|
Invalid: Organizacja jest nieprawidłowa
|
||||||
AlreadyDeactivated: Organizacja jest już deaktywowana
|
AlreadyDeactivated: Organizacja jest już deaktywowana
|
||||||
AlreadyActive: Organizacja jest już aktywna
|
AlreadyActive: Organizacja jest już aktywna
|
||||||
|
@@ -193,7 +193,7 @@ Errors:
|
|||||||
AlreadyExists: Instância já existe
|
AlreadyExists: Instância já existe
|
||||||
NotChanged: Instância não alterada
|
NotChanged: Instância não alterada
|
||||||
Org:
|
Org:
|
||||||
AlreadyExists: Nome da organização já está em uso
|
AlreadyExists: O nome ou ID da organização já está em uso
|
||||||
Invalid: Organização é inválida
|
Invalid: Organização é inválida
|
||||||
AlreadyDeactivated: Organização já está desativada
|
AlreadyDeactivated: Organização já está desativada
|
||||||
AlreadyActive: Organização já está ativa
|
AlreadyActive: Organização já está ativa
|
||||||
|
@@ -195,7 +195,7 @@ Errors:
|
|||||||
AlreadyExists: Instanța există deja
|
AlreadyExists: Instanța există deja
|
||||||
NotChanged: Instanța nu a fost schimbată
|
NotChanged: Instanța nu a fost schimbată
|
||||||
Org:
|
Org:
|
||||||
AlreadyExists: Numele organizației este deja luat
|
AlreadyExists: Numele sau ID-ul organizației este deja utilizat
|
||||||
Invalid: Organizația este invalidă
|
Invalid: Organizația este invalidă
|
||||||
AlreadyDeactivated: Organizația este deja dezactivată
|
AlreadyDeactivated: Organizația este deja dezactivată
|
||||||
AlreadyActive: Organizația este deja activă
|
AlreadyActive: Organizația este deja activă
|
||||||
|
@@ -194,7 +194,7 @@ Errors:
|
|||||||
AlreadyExists: Экземпляр уже существует
|
AlreadyExists: Экземпляр уже существует
|
||||||
NotChanged: Экземпляр не изменён
|
NotChanged: Экземпляр не изменён
|
||||||
Org:
|
Org:
|
||||||
AlreadyExists: Название организации уже занято
|
AlreadyExists: Название организации или идентификатор уже занят
|
||||||
Invalid: Организация недействительна
|
Invalid: Организация недействительна
|
||||||
AlreadyDeactivated: Организация уже деактивирована
|
AlreadyDeactivated: Организация уже деактивирована
|
||||||
AlreadyActive: Организация уже активна
|
AlreadyActive: Организация уже активна
|
||||||
|
@@ -194,7 +194,7 @@ Errors:
|
|||||||
AlreadyExists: Instans finns redan
|
AlreadyExists: Instans finns redan
|
||||||
NotChanged: Instans ändrades inte
|
NotChanged: Instans ändrades inte
|
||||||
Org:
|
Org:
|
||||||
AlreadyExists: Organisationens namn är redan taget
|
AlreadyExists: Organisationens namn eller ID är redan upptaget
|
||||||
Invalid: Organisationen är ogiltigt
|
Invalid: Organisationen är ogiltigt
|
||||||
AlreadyDeactivated: Organisation är redan avaktiverad
|
AlreadyDeactivated: Organisation är redan avaktiverad
|
||||||
AlreadyActive: Organisationen är redan aktiv
|
AlreadyActive: Organisationen är redan aktiv
|
||||||
|
@@ -194,7 +194,7 @@ Errors:
|
|||||||
AlreadyExists: 实例已经存在
|
AlreadyExists: 实例已经存在
|
||||||
NotChanged: 实例没有改变
|
NotChanged: 实例没有改变
|
||||||
Org:
|
Org:
|
||||||
AlreadyExists: 组织名称已被占用
|
AlreadyExists: 该组织名称或 ID 已被占用
|
||||||
Invalid: 组织无效
|
Invalid: 组织无效
|
||||||
AlreadyDeactivated: 组织已停用
|
AlreadyDeactivated: 组织已停用
|
||||||
AlreadyActive: 组织已处于启用状态
|
AlreadyActive: 组织已处于启用状态
|
||||||
|
Reference in New Issue
Block a user