mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-05 22:52:46 +00:00
refactor: remove commandNew struct (#3465)
* refactor: remove commandNew struct * requested fixes
This commit is contained in:
parent
1305c14e49
commit
a7816a43b1
@ -11,6 +11,7 @@ import (
|
||||
"github.com/caos/zitadel/internal/crypto"
|
||||
crypto_db "github.com/caos/zitadel/internal/crypto/database"
|
||||
"github.com/caos/zitadel/internal/eventstore"
|
||||
webauthn_helper "github.com/caos/zitadel/internal/webauthn"
|
||||
)
|
||||
|
||||
type DefaultInstance struct {
|
||||
@ -39,7 +40,19 @@ func (mig *DefaultInstance) Execute(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd := command.NewCommandV2(mig.es, mig.defaults, userAlg, mig.zitadelRoles)
|
||||
cmd, err := command.StartCommands(mig.es,
|
||||
mig.defaults,
|
||||
mig.zitadelRoles,
|
||||
nil,
|
||||
nil,
|
||||
webauthn_helper.Config{},
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
userAlg,
|
||||
nil,
|
||||
nil)
|
||||
|
||||
ctx = authz.WithRequestedDomain(ctx, mig.domain)
|
||||
_, err = cmd.SetUpInstance(ctx, &mig.InstanceSetup)
|
||||
|
@ -117,7 +117,7 @@ func startZitadel(config *Config, masterKey string) error {
|
||||
Origin: http_util.BuildHTTP(config.ExternalDomain, config.ExternalPort, config.ExternalSecure),
|
||||
DisplayName: "ZITADEL",
|
||||
}
|
||||
commands, err := command.StartCommands(eventstoreClient, config.SystemDefaults, config.InternalAuthZ, storage, authZRepo, webAuthNConfig, keys.IDPConfig, keys.OTP, keys.SMTP, keys.SMS, keys.User, keys.DomainVerification, keys.OIDC)
|
||||
commands, err := command.StartCommands(eventstoreClient, config.SystemDefaults, config.InternalAuthZ.RolePermissionMappings, storage, authZRepo, webAuthNConfig, keys.IDPConfig, keys.OTP, keys.SMTP, keys.SMS, keys.User, keys.DomainVerification, keys.OIDC)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot start commands: %w", err)
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ func (s *Server) ListIAMMembers(ctx context.Context, req *admin_pb.ListIAMMember
|
||||
}
|
||||
|
||||
func (s *Server) AddIAMMember(ctx context.Context, req *admin_pb.AddIAMMemberRequest) (*admin_pb.AddIAMMemberResponse, error) {
|
||||
member, err := s.command.AddInstanceMember(ctx, AddIAMMemberToDomain(req))
|
||||
member, err := s.command.AddInstanceMember(ctx, req.UserId, req.Roles...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/caos/zitadel/internal/api/grpc/object"
|
||||
org_grpc "github.com/caos/zitadel/internal/api/grpc/org"
|
||||
"github.com/caos/zitadel/internal/command"
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
"github.com/caos/zitadel/internal/query"
|
||||
admin_pb "github.com/caos/zitadel/pkg/grpc/admin"
|
||||
@ -50,18 +51,15 @@ func (s *Server) SetUpOrg(ctx context.Context, req *admin_pb.SetUpOrgRequest) (*
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
human := setUpOrgHumanToDomain(req.User.(*admin_pb.SetUpOrgRequest_Human_).Human) //TODO: handle machine
|
||||
org := setUpOrgOrgToDomain(req.Org)
|
||||
_ = userIDs //TODO: handle userIDs
|
||||
human := setUpOrgHumanToCommand(req.User.(*admin_pb.SetUpOrgRequest_Human_).Human) //TODO: handle machine
|
||||
org := setUpOrgOrgToDomain(req.Org) //TODO: handle domain
|
||||
_ = org
|
||||
|
||||
initCodeGenerator, err := s.query.InitEncryptionGenerator(ctx, domain.SecretGeneratorTypeInitCode, s.userCodeAlg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
phoneCodeGenerator, err := s.query.InitEncryptionGenerator(ctx, domain.SecretGeneratorTypeVerifyPhoneCode, s.userCodeAlg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
objectDetails, err := s.command.SetUpOrg(ctx, org, human, initCodeGenerator, phoneCodeGenerator, userIDs, false)
|
||||
objectDetails, err := s.command.SetUpOrg(ctx, &command.OrgSetup{
|
||||
Name: req.Org.Name,
|
||||
Human: human,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -2,57 +2,44 @@ package admin
|
||||
|
||||
import (
|
||||
"github.com/caos/logging"
|
||||
user_grpc "github.com/caos/zitadel/internal/api/grpc/user"
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
admin_grpc "github.com/caos/zitadel/pkg/grpc/admin"
|
||||
"golang.org/x/text/language"
|
||||
|
||||
user_grpc "github.com/caos/zitadel/internal/api/grpc/user"
|
||||
"github.com/caos/zitadel/internal/command"
|
||||
admin_grpc "github.com/caos/zitadel/pkg/grpc/admin"
|
||||
)
|
||||
|
||||
func setUpOrgHumanToDomain(human *admin_grpc.SetUpOrgRequest_Human) *domain.Human {
|
||||
return &domain.Human{
|
||||
Username: human.UserName,
|
||||
Profile: setUpOrgHumanProfileToDomain(human.Profile),
|
||||
Email: setUpOrgHumanEmailToDomain(human.Email),
|
||||
Phone: setUpOrgHumanPhoneToDomain(human.Phone),
|
||||
Password: setUpOrgHumanPasswordToDomain(human.Password),
|
||||
}
|
||||
}
|
||||
|
||||
func setUpOrgHumanProfileToDomain(profile *admin_grpc.SetUpOrgRequest_Human_Profile) *domain.Profile {
|
||||
func setUpOrgHumanToCommand(human *admin_grpc.SetUpOrgRequest_Human) command.AddHuman {
|
||||
var lang language.Tag
|
||||
lang, err := language.Parse(profile.PreferredLanguage)
|
||||
logging.Log("ADMIN-tiMWs").OnError(err).Debug("unable to parse language")
|
||||
|
||||
return &domain.Profile{
|
||||
FirstName: profile.FirstName,
|
||||
LastName: profile.LastName,
|
||||
NickName: profile.NickName,
|
||||
DisplayName: profile.DisplayName,
|
||||
PreferredLanguage: lang,
|
||||
Gender: user_grpc.GenderToDomain(profile.Gender),
|
||||
lang, err := language.Parse(human.Profile.PreferredLanguage)
|
||||
logging.OnError(err).Debug("unable to parse language")
|
||||
return command.AddHuman{
|
||||
Username: human.UserName,
|
||||
FirstName: human.Profile.FirstName,
|
||||
LastName: human.Profile.LastName,
|
||||
NickName: human.Profile.NickName,
|
||||
DisplayName: human.Profile.DisplayName,
|
||||
PreferredLang: lang,
|
||||
Gender: user_grpc.GenderToDomain(human.Profile.Gender),
|
||||
Email: setUpOrgHumanEmailToDomain(human.Email),
|
||||
Phone: setUpOrgHumanPhoneToDomain(human.Phone),
|
||||
Password: human.Password,
|
||||
}
|
||||
}
|
||||
|
||||
func setUpOrgHumanEmailToDomain(email *admin_grpc.SetUpOrgRequest_Human_Email) *domain.Email {
|
||||
return &domain.Email{
|
||||
EmailAddress: email.Email,
|
||||
IsEmailVerified: email.IsEmailVerified,
|
||||
func setUpOrgHumanEmailToDomain(email *admin_grpc.SetUpOrgRequest_Human_Email) command.Email {
|
||||
return command.Email{
|
||||
Address: email.Email,
|
||||
Verified: email.IsEmailVerified,
|
||||
}
|
||||
}
|
||||
|
||||
func setUpOrgHumanPhoneToDomain(phone *admin_grpc.SetUpOrgRequest_Human_Phone) *domain.Phone {
|
||||
func setUpOrgHumanPhoneToDomain(phone *admin_grpc.SetUpOrgRequest_Human_Phone) command.Phone {
|
||||
if phone == nil {
|
||||
return nil
|
||||
return command.Phone{}
|
||||
}
|
||||
return &domain.Phone{
|
||||
PhoneNumber: phone.Phone,
|
||||
IsPhoneVerified: phone.IsPhoneVerified,
|
||||
return command.Phone{
|
||||
Number: phone.Phone,
|
||||
Verified: phone.IsPhoneVerified,
|
||||
}
|
||||
}
|
||||
|
||||
func setUpOrgHumanPasswordToDomain(password string) *domain.Password {
|
||||
if password == "" {
|
||||
return nil
|
||||
}
|
||||
return domain.NewPassword(password)
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ func (s *Server) ListOrgMembers(ctx context.Context, req *mgmt_pb.ListOrgMembers
|
||||
}
|
||||
|
||||
func (s *Server) AddOrgMember(ctx context.Context, req *mgmt_pb.AddOrgMemberRequest) (*mgmt_pb.AddOrgMemberResponse, error) {
|
||||
addedMember, err := s.command.AddOrgMember(ctx, AddOrgMemberRequestToDomain(ctx, req))
|
||||
addedMember, err := s.command.AddOrgMember(ctx, authz.GetCtxData(ctx).OrgID, req.UserId, req.Roles...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -66,10 +66,6 @@ func SetPrimaryOrgDomainRequestToDomain(ctx context.Context, req *mgmt_pb.SetPri
|
||||
}
|
||||
}
|
||||
|
||||
func AddOrgMemberRequestToDomain(ctx context.Context, req *mgmt_pb.AddOrgMemberRequest) *domain.Member {
|
||||
return domain.NewMember(authz.GetCtxData(ctx).OrgID, req.UserId, req.Roles...)
|
||||
}
|
||||
|
||||
func UpdateOrgMemberRequestToDomain(ctx context.Context, req *mgmt_pb.UpdateOrgMemberRequest) *domain.Member {
|
||||
return domain.NewMember(authz.GetCtxData(ctx).OrgID, req.UserId, req.Roles...)
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ package login
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/caos/zitadel/internal/command"
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
)
|
||||
|
||||
@ -65,17 +65,8 @@ func (l *Login) handleRegisterOrgCheck(w http.ResponseWriter, r *http.Request) {
|
||||
l.renderRegisterOrg(w, r, authRequest, data, err)
|
||||
return
|
||||
}
|
||||
initCodeGenerator, err := l.query.InitEncryptionGenerator(r.Context(), domain.SecretGeneratorTypePasswordlessInitCode, l.userCodeAlg)
|
||||
if err != nil {
|
||||
l.renderRegisterOrg(w, r, authRequest, data, err)
|
||||
return
|
||||
}
|
||||
phoneCodeGenerator, err := l.query.InitEncryptionGenerator(r.Context(), domain.SecretGeneratorTypeVerifyPhoneCode, l.userCodeAlg)
|
||||
if err != nil {
|
||||
l.renderRegisterOrg(w, r, authRequest, data, err)
|
||||
return
|
||||
}
|
||||
_, err = l.command.SetUpOrg(ctx, data.toOrgDomain(), data.toUserDomain(), initCodeGenerator, phoneCodeGenerator, userIDs, true)
|
||||
_ = userIDs //TODO: handle userIDs
|
||||
_, err = l.command.SetUpOrg(ctx, data.toCommandOrg())
|
||||
if err != nil {
|
||||
l.renderRegisterOrg(w, r, authRequest, data, err)
|
||||
return
|
||||
@ -145,8 +136,21 @@ func (d registerOrgFormData) toUserDomain() *domain.Human {
|
||||
}
|
||||
}
|
||||
|
||||
func (d registerOrgFormData) toOrgDomain() *domain.Org {
|
||||
return &domain.Org{
|
||||
func (d registerOrgFormData) toCommandOrg() *command.OrgSetup {
|
||||
if d.Username == "" {
|
||||
d.Username = d.Email
|
||||
}
|
||||
return &command.OrgSetup{
|
||||
Name: d.RegisterOrgName,
|
||||
Human: command.AddHuman{
|
||||
Username: d.Username,
|
||||
FirstName: d.Firstname,
|
||||
LastName: d.Lastname,
|
||||
Email: command.Email{
|
||||
Address: d.Email,
|
||||
},
|
||||
Password: d.Password,
|
||||
Register: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -30,36 +30,25 @@ type Commands struct {
|
||||
iamDomain string
|
||||
zitadelRoles []authz.RoleMapping
|
||||
|
||||
idpConfigSecretCrypto crypto.EncryptionAlgorithm
|
||||
smtpPasswordCrypto crypto.EncryptionAlgorithm
|
||||
smsCrypto crypto.EncryptionAlgorithm
|
||||
|
||||
idpConfigEncryption crypto.EncryptionAlgorithm
|
||||
smtpEncryption crypto.EncryptionAlgorithm
|
||||
smsEncryption crypto.EncryptionAlgorithm
|
||||
userEncryption crypto.EncryptionAlgorithm
|
||||
userPasswordAlg crypto.HashAlgorithm
|
||||
machineKeySize int
|
||||
applicationKeySize int
|
||||
domainVerificationAlg crypto.EncryptionAlgorithm
|
||||
domainVerificationGenerator crypto.Generator
|
||||
domainVerificationValidator func(domain, token, verifier string, checkType http.CheckType) error
|
||||
multifactors domain.MultifactorConfigs
|
||||
|
||||
multifactors domain.MultifactorConfigs
|
||||
webauthn *webauthn_helper.WebAuthN
|
||||
keySize int
|
||||
keyAlgorithm crypto.EncryptionAlgorithm
|
||||
privateKeyLifetime time.Duration
|
||||
publicKeyLifetime time.Duration
|
||||
tokenVerifier orgFeatureChecker
|
||||
|
||||
v2 *commandNew
|
||||
}
|
||||
|
||||
type commandNew struct {
|
||||
es *eventstore.Eventstore
|
||||
userPasswordAlg crypto.HashAlgorithm
|
||||
phoneAlg crypto.EncryptionAlgorithm
|
||||
emailAlg crypto.EncryptionAlgorithm
|
||||
initCodeAlg crypto.EncryptionAlgorithm
|
||||
zitadelRoles []authz.RoleMapping
|
||||
id id.Generator
|
||||
tokenVerifier orgFeatureChecker
|
||||
}
|
||||
|
||||
type orgFeatureChecker interface {
|
||||
@ -68,7 +57,7 @@ type orgFeatureChecker interface {
|
||||
|
||||
func StartCommands(es *eventstore.Eventstore,
|
||||
defaults sd.SystemDefaults,
|
||||
authZConfig authz.Config,
|
||||
zitadelRoles []authz.RoleMapping,
|
||||
staticStore static.Storage,
|
||||
authZRepo authz_repo.Repository,
|
||||
webAuthN webauthn_helper.Config,
|
||||
@ -85,16 +74,16 @@ func StartCommands(es *eventstore.Eventstore,
|
||||
static: staticStore,
|
||||
idGenerator: id.SonyFlakeGenerator,
|
||||
iamDomain: defaults.Domain,
|
||||
zitadelRoles: authZConfig.RolePermissionMappings,
|
||||
zitadelRoles: zitadelRoles,
|
||||
keySize: defaults.KeyConfig.Size,
|
||||
privateKeyLifetime: defaults.KeyConfig.PrivateKeyLifetime,
|
||||
publicKeyLifetime: defaults.KeyConfig.PublicKeyLifetime,
|
||||
idpConfigSecretCrypto: idpConfigEncryption,
|
||||
smtpPasswordCrypto: smtpEncryption,
|
||||
smsCrypto: smsEncryption,
|
||||
idpConfigEncryption: idpConfigEncryption,
|
||||
smtpEncryption: smtpEncryption,
|
||||
smsEncryption: smsEncryption,
|
||||
userEncryption: userEncryption,
|
||||
domainVerificationAlg: domainVerificationEncryption,
|
||||
keyAlgorithm: oidcEncryption,
|
||||
v2: NewCommandV2(es, defaults, userEncryption, authZConfig.RolePermissionMappings),
|
||||
}
|
||||
|
||||
instance_repo.RegisterEventMappers(repo.eventstore)
|
||||
@ -128,31 +117,6 @@ func StartCommands(es *eventstore.Eventstore,
|
||||
return repo, nil
|
||||
}
|
||||
|
||||
func NewCommandV2(
|
||||
es *eventstore.Eventstore,
|
||||
defaults sd.SystemDefaults,
|
||||
userAlg crypto.EncryptionAlgorithm,
|
||||
zitadelRoles []authz.RoleMapping,
|
||||
) *commandNew {
|
||||
instance_repo.RegisterEventMappers(es)
|
||||
org.RegisterEventMappers(es)
|
||||
usr_repo.RegisterEventMappers(es)
|
||||
usr_grant_repo.RegisterEventMappers(es)
|
||||
proj_repo.RegisterEventMappers(es)
|
||||
keypair.RegisterEventMappers(es)
|
||||
action.RegisterEventMappers(es)
|
||||
|
||||
return &commandNew{
|
||||
es: es,
|
||||
userPasswordAlg: crypto.NewBCrypt(defaults.SecretGenerators.PasswordSaltCost),
|
||||
initCodeAlg: userAlg,
|
||||
phoneAlg: userAlg,
|
||||
emailAlg: userAlg,
|
||||
zitadelRoles: zitadelRoles,
|
||||
id: id.SonyFlakeGenerator,
|
||||
}
|
||||
}
|
||||
|
||||
func AppendAndReduce(object interface {
|
||||
AppendEvents(...eventstore.Event)
|
||||
Reduce() error
|
||||
|
@ -158,13 +158,13 @@ func (s *InstanceSetup) generateIDs() (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *commandNew) SetUpInstance(ctx context.Context, setup *InstanceSetup) (*domain.ObjectDetails, error) {
|
||||
func (c *Commands) SetUpInstance(ctx context.Context, setup *InstanceSetup) (*domain.ObjectDetails, error) {
|
||||
instanceID, err := id.SonyFlakeGenerator.Next()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = c.es.NewInstance(ctx, instanceID); err != nil {
|
||||
if err = c.eventstore.NewInstance(ctx, instanceID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -189,7 +189,7 @@ func (c *commandNew) SetUpInstance(ctx context.Context, setup *InstanceSetup) (*
|
||||
setup.Org.Human.PasswordChangeRequired = true
|
||||
|
||||
instanceAgg := instance.NewAggregate(instanceID)
|
||||
orgAgg := org.NewAggregate(orgID, orgID)
|
||||
orgAgg := org.NewAggregate(orgID)
|
||||
userAgg := user.NewAggregate(userID, orgID)
|
||||
projectAgg := project.NewAggregate(setup.Zitadel.projectID, orgID)
|
||||
|
||||
@ -312,9 +312,9 @@ func (c *commandNew) SetUpInstance(ctx context.Context, setup *InstanceSetup) (*
|
||||
|
||||
validations = append(validations,
|
||||
AddOrgCommand(ctx, orgAgg, setup.Org.Name),
|
||||
addHumanCommand(userAgg, &setup.Org.Human, c.userPasswordAlg, c.phoneAlg, c.emailAlg, c.initCodeAlg),
|
||||
c.AddOrgMember(orgAgg, userID, domain.RoleOrgOwner),
|
||||
c.AddInstanceMember(instanceAgg, userID, domain.RoleIAMOwner),
|
||||
AddHumanCommand(userAgg, &setup.Org.Human, c.userPasswordAlg, c.smsEncryption, c.smtpEncryption, c.userEncryption),
|
||||
c.AddOrgMemberCommand(orgAgg, userID, domain.RoleOrgOwner),
|
||||
c.AddInstanceMemberCommand(instanceAgg, userID, domain.RoleIAMOwner),
|
||||
|
||||
AddProjectCommand(projectAgg, zitadelProjectName, userID, false, false, false, domain.PrivateLabelingSettingUnspecified),
|
||||
SetIAMProject(instanceAgg, projectAgg.ID),
|
||||
@ -359,12 +359,12 @@ func (c *commandNew) SetUpInstance(ctx context.Context, setup *InstanceSetup) (*
|
||||
SetIAMConsoleID(instanceAgg, &console.ClientID, &setup.Zitadel.consoleAppID),
|
||||
)
|
||||
|
||||
cmds, err := preparation.PrepareCommands(ctx, c.es.Filter, validations...)
|
||||
cmds, err := preparation.PrepareCommands(ctx, c.eventstore.Filter, validations...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
events, err := c.es.Push(ctx, cmds...)
|
||||
events, err := c.eventstore.Push(ctx, cmds...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ func (c *Commands) AddDefaultIDPConfig(ctx context.Context, config *domain.IDPCo
|
||||
),
|
||||
}
|
||||
if config.OIDCConfig != nil {
|
||||
clientSecret, err := crypto.Encrypt([]byte(config.OIDCConfig.ClientSecretString), c.idpConfigSecretCrypto)
|
||||
clientSecret, err := crypto.Encrypt([]byte(config.OIDCConfig.ClientSecretString), c.idpConfigEncryption)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4,10 +4,10 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/caos/zitadel/internal/api/authz"
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/caos/zitadel/internal/api/authz"
|
||||
"github.com/caos/zitadel/internal/crypto"
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
@ -199,9 +199,9 @@ func TestCommandSide_AddDefaultIDPConfig(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
r := &Commands{
|
||||
eventstore: tt.fields.eventstore,
|
||||
idGenerator: tt.fields.idGenerator,
|
||||
idpConfigSecretCrypto: tt.fields.secretCrypto,
|
||||
eventstore: tt.fields.eventstore,
|
||||
idGenerator: tt.fields.idGenerator,
|
||||
idpConfigEncryption: tt.fields.secretCrypto,
|
||||
}
|
||||
got, err := r.AddDefaultIDPConfig(tt.args.ctx, tt.args.config)
|
||||
if tt.res.err == nil {
|
||||
|
@ -238,8 +238,8 @@ func TestCommandSide_ChangeDefaultIDPJWTConfig(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
r := &Commands{
|
||||
eventstore: tt.fields.eventstore,
|
||||
idpConfigSecretCrypto: tt.fields.secretCrypto,
|
||||
eventstore: tt.fields.eventstore,
|
||||
idpConfigEncryption: tt.fields.secretCrypto,
|
||||
}
|
||||
got, err := r.ChangeDefaultIDPJWTConfig(tt.args.ctx, tt.args.config)
|
||||
if tt.res.err == nil {
|
||||
|
@ -31,7 +31,7 @@ func (c *Commands) ChangeDefaultIDPOIDCConfig(ctx context.Context, config *domai
|
||||
config.AuthorizationEndpoint,
|
||||
config.TokenEndpoint,
|
||||
config.ClientSecretString,
|
||||
c.idpConfigSecretCrypto,
|
||||
c.idpConfigEncryption,
|
||||
config.IDPDisplayNameMapping,
|
||||
config.UsernameMapping,
|
||||
config.Scopes...)
|
||||
|
@ -284,8 +284,8 @@ func TestCommandSide_ChangeDefaultIDPOIDCConfig(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
r := &Commands{
|
||||
eventstore: tt.fields.eventstore,
|
||||
idpConfigSecretCrypto: tt.fields.secretCrypto,
|
||||
eventstore: tt.fields.eventstore,
|
||||
idpConfigEncryption: tt.fields.secretCrypto,
|
||||
}
|
||||
got, err := r.ChangeDefaultIDPOIDCConfig(tt.args.ctx, tt.args.config)
|
||||
if tt.res.err == nil {
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"reflect"
|
||||
|
||||
"github.com/caos/zitadel/internal/api/authz"
|
||||
"github.com/caos/zitadel/internal/command/preparation"
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
@ -13,7 +14,7 @@ import (
|
||||
"github.com/caos/zitadel/internal/telemetry/tracing"
|
||||
)
|
||||
|
||||
func (c *commandNew) AddInstanceMember(a *instance.Aggregate, userID string, roles ...string) preparation.Validation {
|
||||
func (c *Commands) AddInstanceMemberCommand(a *instance.Aggregate, userID string, roles ...string) preparation.Validation {
|
||||
return func() (preparation.CreateCommands, error) {
|
||||
if userID == "" {
|
||||
return nil, errors.ThrowInvalidArgument(nil, "INSTA-SDSfs", "Errors.Invalid.Argument")
|
||||
@ -23,7 +24,7 @@ func (c *commandNew) AddInstanceMember(a *instance.Aggregate, userID string, rol
|
||||
}
|
||||
return func(ctx context.Context, filter preparation.FilterToQueryReducer) ([]eventstore.Command, error) {
|
||||
if exists, err := ExistsUser(ctx, filter, userID, ""); err != nil || !exists {
|
||||
return nil, errors.ThrowNotFound(err, "INSTA-GSXOn", "Errors.User.NotFound")
|
||||
return nil, errors.ThrowPreconditionFailed(err, "INSTA-GSXOn", "Errors.User.NotFound")
|
||||
}
|
||||
if isMember, err := IsInstanceMember(ctx, filter, a.ID, userID); err != nil || isMember {
|
||||
return nil, errors.ThrowAlreadyExists(err, "INSTA-pFDwe", "Errors.Instance.Member.AlreadyExists")
|
||||
@ -69,50 +70,24 @@ func IsInstanceMember(ctx context.Context, filter preparation.FilterToQueryReduc
|
||||
return isMember, nil
|
||||
}
|
||||
|
||||
func (c *Commands) AddInstanceMember(ctx context.Context, member *domain.Member) (*domain.Member, error) {
|
||||
if member.UserID == "" {
|
||||
return nil, caos_errs.ThrowInvalidArgument(nil, "INSTANCE-Mf83b", "Errors.IAM.MemberInvalid")
|
||||
}
|
||||
addedMember := NewInstanceMemberWriteModel(ctx, member.UserID)
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&addedMember.MemberWriteModel.WriteModel)
|
||||
err := c.checkUserExists(ctx, addedMember.UserID, "")
|
||||
if err != nil {
|
||||
return nil, caos_errs.ThrowPreconditionFailed(err, "INSTANCE-5N9vs", "Errors.User.NotFound")
|
||||
}
|
||||
event, err := c.addInstanceMember(ctx, instanceAgg, addedMember, member)
|
||||
func (c *Commands) AddInstanceMember(ctx context.Context, userID string, roles ...string) (*domain.Member, error) {
|
||||
instanceAgg := instance.NewAggregate(authz.GetInstance(ctx).InstanceID())
|
||||
cmds, err := preparation.PrepareCommands(ctx, c.eventstore.Filter, c.AddInstanceMemberCommand(instanceAgg, userID, roles...))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pushedEvents, err := c.eventstore.Push(ctx, event)
|
||||
events, err := c.eventstore.Push(ctx, cmds...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = AppendAndReduce(addedMember, pushedEvents...)
|
||||
addedMember := NewInstanceMemberWriteModel(ctx, userID)
|
||||
err = AppendAndReduce(addedMember, events...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return memberWriteModelToMember(&addedMember.MemberWriteModel), nil
|
||||
}
|
||||
|
||||
func (c *Commands) addInstanceMember(ctx context.Context, instanceAgg *eventstore.Aggregate, addedMember *InstanceMemberWriteModel, member *domain.Member) (eventstore.Command, error) {
|
||||
if !member.IsIAMValid() {
|
||||
return nil, caos_errs.ThrowInvalidArgument(nil, "INSTANCE-GR34U", "Errors.IAM.MemberInvalid")
|
||||
}
|
||||
if len(domain.CheckForInvalidRoles(member.Roles, domain.IAMRolePrefix, c.zitadelRoles)) > 0 {
|
||||
return nil, caos_errs.ThrowInvalidArgument(nil, "INSTANCE-4m0fS", "Errors.IAM.MemberInvalid")
|
||||
}
|
||||
err := c.eventstore.FilterToQueryReducer(ctx, addedMember)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if addedMember.State == domain.MemberStateActive {
|
||||
return nil, errors.ThrowAlreadyExists(nil, "INSTANCE-sdgQ4", "Errors.IAM.Member.AlreadyExists")
|
||||
}
|
||||
|
||||
return instance.NewMemberAddedEvent(ctx, instanceAgg, member.UserID, member.Roles...), nil
|
||||
}
|
||||
|
||||
//ChangeInstanceMember updates an existing member
|
||||
func (c *Commands) ChangeInstanceMember(ctx context.Context, member *domain.Member) (*domain.Member, error) {
|
||||
if !member.IsIAMValid() {
|
||||
|
@ -4,6 +4,11 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"github.com/caos/zitadel/internal/repository/user"
|
||||
|
||||
"github.com/caos/zitadel/internal/api/authz"
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
@ -12,9 +17,6 @@ import (
|
||||
"github.com/caos/zitadel/internal/eventstore/v1/models"
|
||||
"github.com/caos/zitadel/internal/repository/instance"
|
||||
"github.com/caos/zitadel/internal/repository/member"
|
||||
"github.com/caos/zitadel/internal/repository/user"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
func TestCommandSide_AddIAMMember(t *testing.T) {
|
||||
@ -24,7 +26,8 @@ func TestCommandSide_AddIAMMember(t *testing.T) {
|
||||
}
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
member *domain.Member
|
||||
userID string
|
||||
roles []string
|
||||
}
|
||||
type res struct {
|
||||
want *domain.Member
|
||||
@ -43,9 +46,24 @@ func TestCommandSide_AddIAMMember(t *testing.T) {
|
||||
t,
|
||||
),
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
},
|
||||
res: res{
|
||||
err: caos_errs.IsErrorInvalidArgument,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "invalid roles, error",
|
||||
fields: fields{
|
||||
eventstore: eventstoreExpect(
|
||||
t,
|
||||
),
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
member: &domain.Member{},
|
||||
userID: "user1",
|
||||
roles: []string{"IAM_OWNER"},
|
||||
},
|
||||
res: res{
|
||||
err: caos_errs.IsErrorInvalidArgument,
|
||||
@ -58,52 +76,21 @@ func TestCommandSide_AddIAMMember(t *testing.T) {
|
||||
t,
|
||||
expectFilter(),
|
||||
),
|
||||
zitadelRoles: []authz.RoleMapping{
|
||||
{
|
||||
Role: "IAM_OWNER",
|
||||
},
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
member: &domain.Member{
|
||||
UserID: "user1",
|
||||
Roles: []string{"IAM_OWNER"},
|
||||
},
|
||||
ctx: context.Background(),
|
||||
userID: "user1",
|
||||
roles: []string{"IAM_OWNER"},
|
||||
},
|
||||
res: res{
|
||||
err: caos_errs.IsPreconditionFailed,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "invalid roles, error",
|
||||
fields: fields{
|
||||
eventstore: eventstoreExpect(
|
||||
t,
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
user.NewHumanAddedEvent(context.Background(),
|
||||
&user.NewAggregate("user1", "org1").Aggregate,
|
||||
"username1",
|
||||
"firstname1",
|
||||
"lastname1",
|
||||
"nickname1",
|
||||
"displayname1",
|
||||
language.German,
|
||||
domain.GenderMale,
|
||||
"email1",
|
||||
true,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
member: &domain.Member{
|
||||
UserID: "user1",
|
||||
Roles: []string{"IAM_OWNER"},
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
err: caos_errs.IsErrorInvalidArgument,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "member already exists, precondition error",
|
||||
fields: fields{
|
||||
@ -141,11 +128,9 @@ func TestCommandSide_AddIAMMember(t *testing.T) {
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
member: &domain.Member{
|
||||
UserID: "user1",
|
||||
Roles: []string{"IAM_OWNER"},
|
||||
},
|
||||
ctx: context.Background(),
|
||||
userID: "user1",
|
||||
roles: []string{"IAM_OWNER"},
|
||||
},
|
||||
res: res{
|
||||
err: caos_errs.IsErrorAlreadyExists,
|
||||
@ -191,11 +176,9 @@ func TestCommandSide_AddIAMMember(t *testing.T) {
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
member: &domain.Member{
|
||||
UserID: "user1",
|
||||
Roles: []string{"IAM_OWNER"},
|
||||
},
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
userID: "user1",
|
||||
roles: []string{"IAM_OWNER"},
|
||||
},
|
||||
res: res{
|
||||
err: caos_errs.IsErrorAlreadyExists,
|
||||
@ -244,11 +227,9 @@ func TestCommandSide_AddIAMMember(t *testing.T) {
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
member: &domain.Member{
|
||||
UserID: "user1",
|
||||
Roles: []string{"IAM_OWNER"},
|
||||
},
|
||||
ctx: authz.WithInstanceID(context.Background(), "INSTANCE"),
|
||||
userID: "user1",
|
||||
roles: []string{"IAM_OWNER"},
|
||||
},
|
||||
res: res{
|
||||
want: &domain.Member{
|
||||
@ -269,7 +250,7 @@ func TestCommandSide_AddIAMMember(t *testing.T) {
|
||||
eventstore: tt.fields.eventstore,
|
||||
zitadelRoles: tt.fields.zitadelRoles,
|
||||
}
|
||||
got, err := r.AddInstanceMember(tt.args.ctx, tt.args.member)
|
||||
got, err := r.AddInstanceMember(tt.args.ctx, tt.args.userID, tt.args.roles...)
|
||||
if tt.res.err == nil {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
@ -3,43 +3,72 @@ package command
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/api/authz"
|
||||
"github.com/caos/zitadel/internal/command/preparation"
|
||||
"github.com/caos/zitadel/internal/crypto"
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore"
|
||||
"github.com/caos/zitadel/internal/repository/instance"
|
||||
)
|
||||
|
||||
func (c *Commands) AddSecretGeneratorConfig(ctx context.Context, generatorType domain.SecretGeneratorType, config *crypto.GeneratorConfig) (*domain.ObjectDetails, error) {
|
||||
if generatorType == domain.SecretGeneratorTypeUnspecified {
|
||||
return nil, caos_errs.ThrowInvalidArgument(nil, "COMMAND-0pkwf", "Errors.SecretGenerator.TypeMissing")
|
||||
func (c *Commands) AddSecretGeneratorConfig(ctx context.Context, typ domain.SecretGeneratorType, config *crypto.GeneratorConfig) (*domain.ObjectDetails, error) {
|
||||
agg := instance.NewAggregate(authz.GetInstance(ctx).InstanceID())
|
||||
cmds, err := preparation.PrepareCommands(ctx, c.eventstore.Filter, addSecretGeneratorConfig(agg, typ, config))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
generatorWriteModel, err := c.getSecretConfig(ctx, generatorType)
|
||||
events, err := c.eventstore.Push(ctx, cmds...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if generatorWriteModel.State == domain.SecretGeneratorStateActive {
|
||||
return nil, caos_errs.ThrowAlreadyExists(nil, "COMMAND-3n9ls", "Errors.SecretGenerator.AlreadyExists")
|
||||
return &domain.ObjectDetails{
|
||||
Sequence: events[len(events)-1].Sequence(),
|
||||
EventDate: events[len(events)-1].CreationDate(),
|
||||
ResourceOwner: agg.ResourceOwner,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func addSecretGeneratorConfig(a *instance.Aggregate, typ domain.SecretGeneratorType, config *crypto.GeneratorConfig) preparation.Validation {
|
||||
return func() (preparation.CreateCommands, error) {
|
||||
if !typ.Valid() {
|
||||
return nil, errors.ThrowInvalidArgument(nil, "V2-FGqVj", "Errors.InvalidArgument")
|
||||
}
|
||||
if config.Length < 1 {
|
||||
return nil, errors.ThrowInvalidArgument(nil, "V2-jEqCt", "Errors.InvalidArgument")
|
||||
}
|
||||
return func(ctx context.Context, filter preparation.FilterToQueryReducer) ([]eventstore.Command, error) {
|
||||
writeModel := NewInstanceSecretGeneratorConfigWriteModel(ctx, typ)
|
||||
events, err := filter(ctx, writeModel.Query())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
writeModel.AppendEvents(events...)
|
||||
if err = writeModel.Reduce(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if writeModel.State == domain.SecretGeneratorStateActive {
|
||||
return nil, errors.ThrowAlreadyExists(nil, "V2-6CqKo", "Errors.SecretGenerator.AlreadyExists")
|
||||
}
|
||||
|
||||
return []eventstore.Command{
|
||||
instance.NewSecretGeneratorAddedEvent(
|
||||
ctx,
|
||||
&a.Aggregate,
|
||||
typ,
|
||||
config.Length,
|
||||
config.Expiry,
|
||||
config.IncludeLowerLetters,
|
||||
config.IncludeUpperLetters,
|
||||
config.IncludeDigits,
|
||||
config.IncludeSymbols,
|
||||
),
|
||||
}, nil
|
||||
}, nil
|
||||
}
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&generatorWriteModel.WriteModel)
|
||||
pushedEvents, err := c.eventstore.Push(ctx, instance.NewSecretGeneratorAddedEvent(
|
||||
ctx,
|
||||
instanceAgg,
|
||||
generatorType,
|
||||
config.Length,
|
||||
config.Expiry,
|
||||
config.IncludeLowerLetters,
|
||||
config.IncludeUpperLetters,
|
||||
config.IncludeDigits,
|
||||
config.IncludeSymbols))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = AppendAndReduce(generatorWriteModel, pushedEvents...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return writeModelToObjectDetails(&generatorWriteModel.WriteModel), nil
|
||||
}
|
||||
|
||||
func (c *Commands) ChangeSecretGeneratorConfig(ctx context.Context, generatorType domain.SecretGeneratorType, config *crypto.GeneratorConfig) (*domain.ObjectDetails, error) {
|
||||
|
@ -21,7 +21,7 @@ type OrgSetup struct {
|
||||
Human AddHuman
|
||||
}
|
||||
|
||||
func (c *commandNew) SetUpOrg(ctx context.Context, o *OrgSetup) (*domain.ObjectDetails, error) {
|
||||
func (c *Commands) SetUpOrg(ctx context.Context, o *OrgSetup) (*domain.ObjectDetails, error) {
|
||||
orgID, err := id.SonyFlakeGenerator.Next()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -32,19 +32,19 @@ func (c *commandNew) SetUpOrg(ctx context.Context, o *OrgSetup) (*domain.ObjectD
|
||||
return nil, err
|
||||
}
|
||||
|
||||
orgAgg := org.NewAggregate(orgID, orgID)
|
||||
orgAgg := org.NewAggregate(orgID)
|
||||
userAgg := user_repo.NewAggregate(userID, orgID)
|
||||
|
||||
cmds, err := preparation.PrepareCommands(ctx, c.es.Filter,
|
||||
cmds, err := preparation.PrepareCommands(ctx, c.eventstore.Filter,
|
||||
AddOrgCommand(ctx, orgAgg, o.Name),
|
||||
addHumanCommand(userAgg, &o.Human, c.userPasswordAlg, c.phoneAlg, c.emailAlg, c.initCodeAlg),
|
||||
c.AddOrgMember(orgAgg, userID, domain.RoleOrgOwner),
|
||||
AddHumanCommand(userAgg, &o.Human, c.userPasswordAlg, c.smsEncryption, c.smtpEncryption, c.userEncryption),
|
||||
c.AddOrgMemberCommand(orgAgg, userID, domain.RoleOrgOwner),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
events, err := c.es.Push(ctx, cmds...)
|
||||
events, err := c.eventstore.Push(ctx, cmds...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -96,31 +96,6 @@ func (c *Commands) checkOrgExists(ctx context.Context, orgID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Commands) SetUpOrg(ctx context.Context, organisation *domain.Org, admin *domain.Human, initCodeGenerator, phoneCodeGenerator crypto.Generator, claimedUserIDs []string, selfregistered bool) (*domain.ObjectDetails, error) {
|
||||
domainPolicy, err := c.getDefaultDomainPolicy(ctx)
|
||||
if err != nil {
|
||||
return nil, caos_errs.ThrowPreconditionFailed(err, "COMMAND-33M9f", "Errors.Instance.DomainPolicy.NotFound")
|
||||
}
|
||||
pwPolicy, err := c.getDefaultPasswordComplexityPolicy(ctx)
|
||||
if err != nil {
|
||||
return nil, caos_errs.ThrowPreconditionFailed(err, "COMMAND-M5Fsd", "Errors.Instance.PasswordComplexity.NotFound")
|
||||
}
|
||||
_, orgWriteModel, _, _, events, err := c.setUpOrg(ctx, organisation, admin, domainPolicy, pwPolicy, initCodeGenerator, phoneCodeGenerator, claimedUserIDs, selfregistered)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pushedEvents, err := c.eventstore.Push(ctx, events...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = AppendAndReduce(orgWriteModel, pushedEvents...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return writeModelToObjectDetails(&orgWriteModel.WriteModel), nil
|
||||
}
|
||||
|
||||
func (c *Commands) AddOrg(ctx context.Context, name, userID, resourceOwner string, claimedUserIDs []string) (*domain.Org, error) {
|
||||
orgAgg, addedOrg, events, err := c.addOrg(ctx, &domain.Org{Name: name}, claimedUserIDs)
|
||||
if err != nil {
|
||||
|
@ -181,7 +181,7 @@ func (c *Commands) DeleteAction(ctx context.Context, actionID, resourceOwner str
|
||||
events := []eventstore.Command{
|
||||
action.NewRemovedEvent(ctx, actionAgg, existingAction.Name),
|
||||
}
|
||||
orgAgg := org.NewAggregate(resourceOwner, resourceOwner).Aggregate
|
||||
orgAgg := org.NewAggregate(resourceOwner).Aggregate
|
||||
for _, flowType := range flowTypes {
|
||||
events = append(events, org.NewTriggerActionsCascadeRemovedEvent(ctx, &orgAgg, flowType, actionID))
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ func TestCommands_AddAction(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
func() eventstore.Command {
|
||||
e, _ := org.NewFeaturesSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
[]features.FeaturesChanges{
|
||||
features.ChangeMaxActions(1),
|
||||
},
|
||||
@ -106,7 +106,7 @@ func TestCommands_AddAction(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
func() eventstore.Command {
|
||||
e, _ := org.NewFeaturesSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
[]features.FeaturesChanges{
|
||||
features.ChangeMaxActions(2),
|
||||
},
|
||||
@ -164,7 +164,7 @@ func TestCommands_AddAction(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
func() eventstore.Command {
|
||||
e, _ := org.NewFeaturesSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
[]features.FeaturesChanges{
|
||||
features.ChangeMaxActions(2),
|
||||
},
|
||||
@ -687,7 +687,7 @@ func TestCommands_ReactivateAction(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
func() eventstore.Command {
|
||||
e, _ := org.NewFeaturesSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
[]features.FeaturesChanges{
|
||||
features.ChangeMaxActions(1),
|
||||
},
|
||||
@ -742,7 +742,7 @@ func TestCommands_ReactivateAction(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
func() eventstore.Command {
|
||||
e, _ := org.NewFeaturesSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
[]features.FeaturesChanges{
|
||||
features.ChangeMaxActions(1),
|
||||
},
|
||||
@ -923,7 +923,7 @@ func TestCommands_DeleteAction(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewTriggerActionsCascadeRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.FlowTypeExternalAuthentication,
|
||||
"id1",
|
||||
),
|
||||
|
@ -15,7 +15,7 @@ func (c *Commands) SetOrgLoginText(ctx context.Context, resourceOwner string, lo
|
||||
if resourceOwner == "" {
|
||||
return nil, caos_errs.ThrowInvalidArgument(nil, "ORG-m29rF", "Errors.ResourceOwnerMissing")
|
||||
}
|
||||
iamAgg := org.NewAggregate(resourceOwner, resourceOwner)
|
||||
iamAgg := org.NewAggregate(resourceOwner)
|
||||
events, existingLoginText, err := c.setOrgLoginText(ctx, &iamAgg.Aggregate, loginText)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@ func (c *Commands) SetOrgMessageText(ctx context.Context, resourceOwner string,
|
||||
if resourceOwner == "" {
|
||||
return nil, caos_errs.ThrowInvalidArgument(nil, "ORG-2biiR", "Errors.ResourceOwnerMissing")
|
||||
}
|
||||
orgAgg := org.NewAggregate(resourceOwner, resourceOwner)
|
||||
orgAgg := org.NewAggregate(resourceOwner)
|
||||
events, existingMessageText, err := c.setOrgMessageText(ctx, &orgAgg.Aggregate, messageText)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -74,7 +74,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageGreeting,
|
||||
"Greeting",
|
||||
@ -83,7 +83,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageSubject,
|
||||
"Subject",
|
||||
@ -92,7 +92,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageTitle,
|
||||
"Title",
|
||||
@ -101,7 +101,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessagePreHeader,
|
||||
"PreHeader",
|
||||
@ -110,7 +110,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageText,
|
||||
"Text",
|
||||
@ -119,7 +119,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageButtonText,
|
||||
"ButtonText",
|
||||
@ -128,7 +128,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageFooterText,
|
||||
"Footer",
|
||||
@ -168,7 +168,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageGreeting,
|
||||
"Greeting",
|
||||
@ -177,7 +177,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageSubject,
|
||||
"Subject",
|
||||
@ -186,7 +186,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageTitle,
|
||||
"Title",
|
||||
@ -195,7 +195,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessagePreHeader,
|
||||
"PreHeader",
|
||||
@ -204,7 +204,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageText,
|
||||
"Text",
|
||||
@ -213,7 +213,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageButtonText,
|
||||
"ButtonText",
|
||||
@ -222,7 +222,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageFooterText,
|
||||
"Footer",
|
||||
@ -234,7 +234,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageGreeting,
|
||||
language.English,
|
||||
@ -242,7 +242,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageSubject,
|
||||
language.English,
|
||||
@ -250,7 +250,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageTitle,
|
||||
language.English,
|
||||
@ -258,7 +258,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessagePreHeader,
|
||||
language.English,
|
||||
@ -266,7 +266,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageText,
|
||||
language.English,
|
||||
@ -274,7 +274,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageButtonText,
|
||||
language.English,
|
||||
@ -282,7 +282,7 @@ func TestCommandSide_SetCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageFooterText,
|
||||
language.English,
|
||||
@ -409,7 +409,7 @@ func TestCommandSide_RemoveCustomMessageText(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageGreeting,
|
||||
"Greeting",
|
||||
@ -418,7 +418,7 @@ func TestCommandSide_RemoveCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageSubject,
|
||||
"Subject",
|
||||
@ -427,7 +427,7 @@ func TestCommandSide_RemoveCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageTitle,
|
||||
"Title",
|
||||
@ -436,7 +436,7 @@ func TestCommandSide_RemoveCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessagePreHeader,
|
||||
"PreHeader",
|
||||
@ -445,7 +445,7 @@ func TestCommandSide_RemoveCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageText,
|
||||
"Text",
|
||||
@ -454,7 +454,7 @@ func TestCommandSide_RemoveCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageButtonText,
|
||||
"ButtonText",
|
||||
@ -463,7 +463,7 @@ func TestCommandSide_RemoveCustomMessageText(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
domain.MessageFooterText,
|
||||
"Footer",
|
||||
@ -475,7 +475,7 @@ func TestCommandSide_RemoveCustomMessageText(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextTemplateRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"Template",
|
||||
language.English,
|
||||
),
|
||||
|
@ -29,7 +29,7 @@ func TestAddDomain(t *testing.T) {
|
||||
filter preparation.FilterToQueryReducer
|
||||
}
|
||||
|
||||
agg := org.NewAggregate("test", "test")
|
||||
agg := org.NewAggregate("test")
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -120,7 +120,7 @@ func TestVerifyDomain(t *testing.T) {
|
||||
{
|
||||
name: "invalid domain",
|
||||
args: args{
|
||||
a: org.NewAggregate("test", "test"),
|
||||
a: org.NewAggregate("test"),
|
||||
domain: "",
|
||||
},
|
||||
want: Want{
|
||||
@ -130,12 +130,12 @@ func TestVerifyDomain(t *testing.T) {
|
||||
{
|
||||
name: "correct",
|
||||
args: args{
|
||||
a: org.NewAggregate("test", "test"),
|
||||
a: org.NewAggregate("test"),
|
||||
domain: "domain",
|
||||
},
|
||||
want: Want{
|
||||
Commands: []eventstore.Command{
|
||||
org.NewDomainVerifiedEvent(context.Background(), &org.NewAggregate("test", "test").Aggregate, "domain"),
|
||||
org.NewDomainVerifiedEvent(context.Background(), &org.NewAggregate("test").Aggregate, "domain"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -154,7 +154,7 @@ func TestSetDomainPrimary(t *testing.T) {
|
||||
filter preparation.FilterToQueryReducer
|
||||
}
|
||||
|
||||
agg := org.NewAggregate("test", "test")
|
||||
agg := org.NewAggregate("test")
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -284,13 +284,13 @@ func TestCommandSide_AddOrgDomain(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
@ -318,7 +318,7 @@ func TestCommandSide_AddOrgDomain(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
@ -326,7 +326,7 @@ func TestCommandSide_AddOrgDomain(t *testing.T) {
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
)),
|
||||
},
|
||||
@ -456,7 +456,7 @@ func TestCommandSide_GenerateOrgDomainValidation(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
@ -485,19 +485,19 @@ func TestCommandSide_GenerateOrgDomainValidation(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
@ -526,13 +526,13 @@ func TestCommandSide_GenerateOrgDomainValidation(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
@ -540,7 +540,7 @@ func TestCommandSide_GenerateOrgDomainValidation(t *testing.T) {
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewDomainVerificationAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
domain.OrgDomainValidationTypeDNS,
|
||||
&crypto.CryptoValue{
|
||||
@ -578,13 +578,13 @@ func TestCommandSide_GenerateOrgDomainValidation(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
@ -592,7 +592,7 @@ func TestCommandSide_GenerateOrgDomainValidation(t *testing.T) {
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewDomainVerificationAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
domain.OrgDomainValidationTypeHTTP,
|
||||
&crypto.CryptoValue{
|
||||
@ -711,7 +711,7 @@ func TestCommandSide_ValidateOrgDomain(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
@ -740,19 +740,19 @@ func TestCommandSide_ValidateOrgDomain(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
@ -781,13 +781,13 @@ func TestCommandSide_ValidateOrgDomain(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
@ -816,19 +816,19 @@ func TestCommandSide_ValidateOrgDomain(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerificationAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
domain.OrgDomainValidationTypeDNS,
|
||||
&crypto.CryptoValue{
|
||||
@ -843,7 +843,7 @@ func TestCommandSide_ValidateOrgDomain(t *testing.T) {
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewDomainVerificationFailedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
)),
|
||||
},
|
||||
@ -874,19 +874,19 @@ func TestCommandSide_ValidateOrgDomain(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerificationAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
domain.OrgDomainValidationTypeDNS,
|
||||
&crypto.CryptoValue{
|
||||
@ -901,7 +901,7 @@ func TestCommandSide_ValidateOrgDomain(t *testing.T) {
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewDomainVerifiedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
)),
|
||||
},
|
||||
@ -935,19 +935,19 @@ func TestCommandSide_ValidateOrgDomain(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerificationAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
domain.OrgDomainValidationTypeDNS,
|
||||
&crypto.CryptoValue{
|
||||
@ -963,7 +963,7 @@ func TestCommandSide_ValidateOrgDomain(t *testing.T) {
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewDomainVerifiedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
)),
|
||||
},
|
||||
@ -998,19 +998,19 @@ func TestCommandSide_ValidateOrgDomain(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerificationAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
domain.OrgDomainValidationTypeDNS,
|
||||
&crypto.CryptoValue{
|
||||
@ -1041,12 +1041,12 @@ func TestCommandSide_ValidateOrgDomain(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
false, false))),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewDomainVerifiedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
)),
|
||||
eventFromEventPusher(user.NewDomainClaimedEvent(context.Background(),
|
||||
@ -1169,7 +1169,7 @@ func TestCommandSide_SetPrimaryDomain(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
@ -1198,13 +1198,13 @@ func TestCommandSide_SetPrimaryDomain(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
@ -1232,19 +1232,19 @@ func TestCommandSide_SetPrimaryDomain(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
@ -1252,7 +1252,7 @@ func TestCommandSide_SetPrimaryDomain(t *testing.T) {
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewDomainPrimarySetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
)),
|
||||
},
|
||||
@ -1356,7 +1356,7 @@ func TestCommandSide_RemoveOrgDomain(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
@ -1385,25 +1385,25 @@ func TestCommandSide_RemoveOrgDomain(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPrimarySetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
@ -1431,13 +1431,13 @@ func TestCommandSide_RemoveOrgDomain(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
@ -1445,7 +1445,7 @@ func TestCommandSide_RemoveOrgDomain(t *testing.T) {
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewDomainRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch", false,
|
||||
)),
|
||||
},
|
||||
@ -1475,19 +1475,19 @@ func TestCommandSide_RemoveOrgDomain(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"name",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch",
|
||||
),
|
||||
),
|
||||
@ -1495,7 +1495,7 @@ func TestCommandSide_RemoveOrgDomain(t *testing.T) {
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewDomainRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"domain.ch", true,
|
||||
)),
|
||||
},
|
||||
|
@ -149,7 +149,7 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1",
|
||||
),
|
||||
),
|
||||
@ -210,28 +210,28 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPrimarySetEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
@ -333,7 +333,7 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1",
|
||||
),
|
||||
),
|
||||
@ -394,49 +394,49 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPrimarySetEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"test1",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"test1",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"test2",
|
||||
),
|
||||
),
|
||||
@ -491,10 +491,10 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewDomainRemovedEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate, "test1", true),
|
||||
org.NewDomainRemovedEvent(context.Background(), &org.NewAggregate("org1").Aggregate, "test1", true),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainRemovedEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate, "test2", false),
|
||||
org.NewDomainRemovedEvent(context.Background(), &org.NewAggregate("org1").Aggregate, "test2", false),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
newFeaturesSetEvent(context.Background(), "org1", "Test", domain.FeaturesStateActive, time.Hour),
|
||||
@ -543,7 +543,7 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1",
|
||||
),
|
||||
),
|
||||
@ -604,56 +604,56 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPrimarySetEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"test1",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"test1",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPrimarySetEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"test1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"test2",
|
||||
),
|
||||
),
|
||||
@ -708,13 +708,13 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPrimarySetEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate, "org1.iam-domain"),
|
||||
org.NewDomainPrimarySetEvent(context.Background(), &org.NewAggregate("org1").Aggregate, "org1.iam-domain"),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainRemovedEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate, "test1", true),
|
||||
org.NewDomainRemovedEvent(context.Background(), &org.NewAggregate("org1").Aggregate, "test1", true),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainRemovedEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate, "test2", false),
|
||||
org.NewDomainRemovedEvent(context.Background(), &org.NewAggregate("org1").Aggregate, "test2", false),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
newFeaturesSetEvent(context.Background(), "org1", "Test", domain.FeaturesStateActive, time.Hour),
|
||||
@ -763,7 +763,7 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1",
|
||||
),
|
||||
),
|
||||
@ -824,63 +824,63 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPrimarySetEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"test1",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"test1",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPrimarySetEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"test1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"test2",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainRemovedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain", true,
|
||||
),
|
||||
),
|
||||
@ -935,16 +935,16 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate, "org1.iam-domain"),
|
||||
org.NewDomainAddedEvent(context.Background(), &org.NewAggregate("org1").Aggregate, "org1.iam-domain"),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPrimarySetEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate, "org1.iam-domain"),
|
||||
org.NewDomainPrimarySetEvent(context.Background(), &org.NewAggregate("org1").Aggregate, "org1.iam-domain"),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainRemovedEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate, "test1", true),
|
||||
org.NewDomainRemovedEvent(context.Background(), &org.NewAggregate("org1").Aggregate, "test1", true),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainRemovedEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate, "test2", false),
|
||||
org.NewDomainRemovedEvent(context.Background(), &org.NewAggregate("org1").Aggregate, "test2", false),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
newFeaturesSetEvent(context.Background(), "org1", "Test", domain.FeaturesStateActive, time.Hour),
|
||||
@ -994,7 +994,7 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1",
|
||||
),
|
||||
),
|
||||
@ -1070,7 +1070,7 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
instance.NewLoginPolicyMultiFactorAddedEvent(context.Background(), &instance.NewAggregate("INSTANCE").Aggregate, domain.MultiFactorTypeU2FWithPIN),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicySecondFactorAddedEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate, domain.SecondFactorTypeOTP),
|
||||
org.NewLoginPolicySecondFactorAddedEvent(context.Background(), &org.NewAggregate("org1").Aggregate, domain.SecondFactorTypeOTP),
|
||||
),
|
||||
),
|
||||
//addSecondFactorToLoginPolicy
|
||||
@ -1151,28 +1151,28 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPrimarySetEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
@ -1216,7 +1216,7 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
org.NewLockoutPolicyAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
5,
|
||||
false,
|
||||
),
|
||||
@ -1227,13 +1227,13 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicySecondFactorRemovedEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate, domain.SecondFactorTypeOTP),
|
||||
org.NewLoginPolicySecondFactorRemovedEvent(context.Background(), &org.NewAggregate("org1").Aggregate, domain.SecondFactorTypeOTP),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicySecondFactorAddedEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate, domain.SecondFactorTypeU2F),
|
||||
org.NewLoginPolicySecondFactorAddedEvent(context.Background(), &org.NewAggregate("org1").Aggregate, domain.SecondFactorTypeU2F),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyMultiFactorAddedEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate, domain.MultiFactorTypeU2FWithPIN),
|
||||
org.NewLoginPolicyMultiFactorAddedEvent(context.Background(), &org.NewAggregate("org1").Aggregate, domain.MultiFactorTypeU2FWithPIN),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
newLoginPolicyChangedEvent(context.Background(), "org1",
|
||||
@ -1245,22 +1245,22 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
nil),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordComplexityPolicyRemovedEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate),
|
||||
org.NewPasswordComplexityPolicyRemovedEvent(context.Background(), &org.NewAggregate("org1").Aggregate),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyRemovedEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate),
|
||||
org.NewLabelPolicyRemovedEvent(context.Background(), &org.NewAggregate("org1").Aggregate),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextTemplateRemovedEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate, domain.InitCodeMessageType, language.English),
|
||||
org.NewCustomTextTemplateRemovedEvent(context.Background(), &org.NewAggregate("org1").Aggregate, domain.InitCodeMessageType, language.English),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewCustomTextTemplateRemovedEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate, domain.LoginCustomText, language.English),
|
||||
org.NewCustomTextTemplateRemovedEvent(context.Background(), &org.NewAggregate("org1").Aggregate, domain.LoginCustomText, language.English),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewPrivacyPolicyRemovedEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate),
|
||||
org.NewPrivacyPolicyRemovedEvent(context.Background(), &org.NewAggregate("org1").Aggregate),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewLockoutPolicyRemovedEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate),
|
||||
org.NewLockoutPolicyRemovedEvent(context.Background(), &org.NewAggregate("org1").Aggregate),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
newFeaturesSetEvent(context.Background(), "org1", "Test", domain.FeaturesStateActive, time.Hour),
|
||||
@ -1308,7 +1308,7 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1",
|
||||
),
|
||||
),
|
||||
@ -1369,28 +1369,28 @@ func TestCommandSide_SetOrgFeatures(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPrimarySetEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
@ -1634,28 +1634,28 @@ func TestCommandSide_RemoveOrgFeatures(t *testing.T) {
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPrimarySetEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org1.iam-domain",
|
||||
),
|
||||
),
|
||||
@ -1710,7 +1710,7 @@ func TestCommandSide_RemoveOrgFeatures(t *testing.T) {
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewFeaturesRemovedEvent(context.Background(), &org.NewAggregate("org1", "org1").Aggregate),
|
||||
org.NewFeaturesRemovedEvent(context.Background(), &org.NewAggregate("org1").Aggregate),
|
||||
),
|
||||
},
|
||||
),
|
||||
@ -1764,7 +1764,7 @@ func newIAMFeaturesSetEvent(ctx context.Context, tierName string, state domain.F
|
||||
func newFeaturesSetEvent(ctx context.Context, orgID string, tierName string, state domain.FeaturesState, auditLog time.Duration) *org.FeaturesSetEvent {
|
||||
event, _ := org.NewFeaturesSetEvent(
|
||||
ctx,
|
||||
&org.NewAggregate(orgID, orgID).Aggregate,
|
||||
&org.NewAggregate(orgID).Aggregate,
|
||||
[]features.FeaturesChanges{
|
||||
features.ChangeTierName(tierName),
|
||||
features.ChangeState(state),
|
||||
|
@ -4,12 +4,13 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore"
|
||||
"github.com/caos/zitadel/internal/repository/action"
|
||||
"github.com/caos/zitadel/internal/repository/org"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCommands_ClearFlow(t *testing.T) {
|
||||
@ -70,7 +71,7 @@ func TestCommands_ClearFlow(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewTriggerActionsSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.FlowTypeExternalAuthentication,
|
||||
domain.TriggerTypePostAuthentication,
|
||||
[]string{"actionID1"},
|
||||
@ -80,7 +81,7 @@ func TestCommands_ClearFlow(t *testing.T) {
|
||||
expectPush(
|
||||
eventPusherToEvents(
|
||||
org.NewFlowClearedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.FlowTypeExternalAuthentication,
|
||||
),
|
||||
),
|
||||
@ -182,7 +183,7 @@ func TestCommands_SetTriggerActions(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewTriggerActionsSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.FlowTypeExternalAuthentication,
|
||||
domain.TriggerTypePostAuthentication,
|
||||
[]string{"actionID1"},
|
||||
@ -242,7 +243,7 @@ func TestCommands_SetTriggerActions(t *testing.T) {
|
||||
expectPush(
|
||||
eventPusherToEvents(
|
||||
org.NewTriggerActionsSetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.FlowTypeExternalAuthentication,
|
||||
domain.TriggerTypePostAuthentication,
|
||||
[]string{"actionID1"},
|
||||
|
@ -40,7 +40,7 @@ func (c *Commands) AddIDPConfig(ctx context.Context, config *domain.IDPConfig, r
|
||||
),
|
||||
}
|
||||
if config.OIDCConfig != nil {
|
||||
clientSecret, err := crypto.Crypt([]byte(config.OIDCConfig.ClientSecretString), c.idpConfigSecretCrypto)
|
||||
clientSecret, err := crypto.Crypt([]byte(config.OIDCConfig.ClientSecretString), c.idpConfigEncryption)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ func TestCommandSide_AddIDPConfig(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewIDPConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"name1",
|
||||
domain.IDPConfigTypeOIDC,
|
||||
@ -104,7 +104,7 @@ func TestCommandSide_AddIDPConfig(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewIDPOIDCConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"clientid1",
|
||||
"config1",
|
||||
"issuer",
|
||||
@ -170,7 +170,7 @@ func TestCommandSide_AddIDPConfig(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewIDPConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"name1",
|
||||
domain.IDPConfigTypeOIDC,
|
||||
@ -180,7 +180,7 @@ func TestCommandSide_AddIDPConfig(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewIDPJWTConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"jwt-endpoint",
|
||||
"issuer",
|
||||
@ -225,9 +225,9 @@ func TestCommandSide_AddIDPConfig(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
r := &Commands{
|
||||
eventstore: tt.fields.eventstore,
|
||||
idGenerator: tt.fields.idGenerator,
|
||||
idpConfigSecretCrypto: tt.fields.secretCrypto,
|
||||
eventstore: tt.fields.eventstore,
|
||||
idGenerator: tt.fields.idGenerator,
|
||||
idpConfigEncryption: tt.fields.secretCrypto,
|
||||
}
|
||||
got, err := r.AddIDPConfig(tt.args.ctx, tt.args.config, tt.args.resourceOwner)
|
||||
if tt.res.err == nil {
|
||||
@ -321,7 +321,7 @@ func TestCommandSide_ChangeIDPConfig(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewIDPConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"name1",
|
||||
domain.IDPConfigTypeOIDC,
|
||||
@ -331,7 +331,7 @@ func TestCommandSide_ChangeIDPConfig(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewIDPOIDCConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"clientid1",
|
||||
"config1",
|
||||
"issuer",
|
||||
@ -406,7 +406,7 @@ func TestCommandSide_ChangeIDPConfig(t *testing.T) {
|
||||
|
||||
func newIDPConfigChangedEvent(ctx context.Context, orgID, configID, oldName, newName string, stylingType domain.IDPConfigStylingType) *org.IDPConfigChangedEvent {
|
||||
event, _ := org.NewIDPConfigChangedEvent(ctx,
|
||||
&org.NewAggregate(orgID, orgID).Aggregate,
|
||||
&org.NewAggregate(orgID).Aggregate,
|
||||
configID,
|
||||
oldName,
|
||||
[]idpconfig.IDPConfigChanges{
|
||||
@ -464,7 +464,7 @@ func TestCommands_RemoveIDPConfig(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewIDPConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"idp1",
|
||||
"name1",
|
||||
domain.IDPConfigTypeOIDC,
|
||||
@ -476,7 +476,7 @@ func TestCommands_RemoveIDPConfig(t *testing.T) {
|
||||
expectPush(
|
||||
eventPusherToEvents(
|
||||
org.NewIDPConfigRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"idp1",
|
||||
"name1",
|
||||
),
|
||||
@ -506,7 +506,7 @@ func TestCommands_RemoveIDPConfig(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewIDPConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"idp1",
|
||||
"name1",
|
||||
domain.IDPConfigTypeOIDC,
|
||||
@ -518,7 +518,7 @@ func TestCommands_RemoveIDPConfig(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
user.NewHumanAddedEvent(context.Background(),
|
||||
&org.NewAggregate("user1", "org1").Aggregate,
|
||||
&user.NewAggregate("user1", "org1").Aggregate,
|
||||
"username",
|
||||
"firstname",
|
||||
"lastname",
|
||||
@ -532,7 +532,7 @@ func TestCommands_RemoveIDPConfig(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
user.NewUserIDPLinkAddedEvent(context.Background(),
|
||||
&org.NewAggregate("user1", "org1").Aggregate,
|
||||
&user.NewAggregate("user1", "org1").Aggregate,
|
||||
"idp1",
|
||||
"name",
|
||||
"id1",
|
||||
@ -542,12 +542,12 @@ func TestCommands_RemoveIDPConfig(t *testing.T) {
|
||||
expectPush(
|
||||
eventPusherToEvents(
|
||||
org.NewIDPConfigRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"idp1",
|
||||
"name1",
|
||||
),
|
||||
org.NewIdentityProviderCascadeRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"idp1",
|
||||
),
|
||||
user.NewUserIDPLinkCascadeRemovedEvent(context.Background(),
|
||||
|
@ -99,7 +99,7 @@ func TestCommandSide_ChangeIDPJWTConfig(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewIDPConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"name1",
|
||||
domain.IDPConfigTypeJWT,
|
||||
@ -109,7 +109,7 @@ func TestCommandSide_ChangeIDPJWTConfig(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewIDPJWTConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"jwt-endpoint",
|
||||
"issuer",
|
||||
@ -119,7 +119,7 @@ func TestCommandSide_ChangeIDPJWTConfig(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewIDPConfigRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"name",
|
||||
),
|
||||
@ -146,7 +146,7 @@ func TestCommandSide_ChangeIDPJWTConfig(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewIDPConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"name1",
|
||||
domain.IDPConfigTypeJWT,
|
||||
@ -156,7 +156,7 @@ func TestCommandSide_ChangeIDPJWTConfig(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewIDPJWTConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"jwt-endpoint",
|
||||
"issuer",
|
||||
@ -191,7 +191,7 @@ func TestCommandSide_ChangeIDPJWTConfig(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewIDPConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"name1",
|
||||
domain.IDPConfigTypeJWT,
|
||||
@ -201,7 +201,7 @@ func TestCommandSide_ChangeIDPJWTConfig(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewIDPJWTConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"jwt-endpoint",
|
||||
"issuer",
|
||||
@ -256,8 +256,8 @@ func TestCommandSide_ChangeIDPJWTConfig(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
r := &Commands{
|
||||
eventstore: tt.fields.eventstore,
|
||||
idpConfigSecretCrypto: tt.fields.secretCrypto,
|
||||
eventstore: tt.fields.eventstore,
|
||||
idpConfigEncryption: tt.fields.secretCrypto,
|
||||
}
|
||||
got, err := r.ChangeIDPJWTConfig(tt.args.ctx, tt.args.config, tt.args.resourceOwner)
|
||||
if tt.res.err == nil {
|
||||
@ -275,7 +275,7 @@ func TestCommandSide_ChangeIDPJWTConfig(t *testing.T) {
|
||||
|
||||
func newIDPJWTConfigChangedEvent(ctx context.Context, orgID, configID, jwtEndpoint, issuer, keysEndpoint, headerName string) *org.IDPJWTConfigChangedEvent {
|
||||
event, _ := org.NewIDPJWTConfigChangedEvent(ctx,
|
||||
&org.NewAggregate(orgID, orgID).Aggregate,
|
||||
&org.NewAggregate(orgID).Aggregate,
|
||||
configID,
|
||||
[]idpconfig.JWTConfigChanges{
|
||||
idpconfig.ChangeJWTEndpoint(jwtEndpoint),
|
||||
|
@ -34,7 +34,7 @@ func (c *Commands) ChangeIDPOIDCConfig(ctx context.Context, config *domain.OIDCI
|
||||
config.AuthorizationEndpoint,
|
||||
config.TokenEndpoint,
|
||||
config.ClientSecretString,
|
||||
c.idpConfigSecretCrypto,
|
||||
c.idpConfigEncryption,
|
||||
config.IDPDisplayNameMapping,
|
||||
config.UsernameMapping,
|
||||
config.Scopes...)
|
||||
|
@ -99,7 +99,7 @@ func TestCommandSide_ChangeIDPOIDCConfig(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewIDPConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"name1",
|
||||
domain.IDPConfigTypeOIDC,
|
||||
@ -109,7 +109,7 @@ func TestCommandSide_ChangeIDPOIDCConfig(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewIDPOIDCConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"clientid1",
|
||||
"config1",
|
||||
"issuer",
|
||||
@ -128,7 +128,7 @@ func TestCommandSide_ChangeIDPOIDCConfig(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewIDPConfigRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"name",
|
||||
),
|
||||
@ -155,7 +155,7 @@ func TestCommandSide_ChangeIDPOIDCConfig(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewIDPConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"name1",
|
||||
domain.IDPConfigTypeOIDC,
|
||||
@ -165,7 +165,7 @@ func TestCommandSide_ChangeIDPOIDCConfig(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewIDPOIDCConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"clientid1",
|
||||
"config1",
|
||||
"issuer",
|
||||
@ -212,7 +212,7 @@ func TestCommandSide_ChangeIDPOIDCConfig(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewIDPConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"name1",
|
||||
domain.IDPConfigTypeOIDC,
|
||||
@ -222,7 +222,7 @@ func TestCommandSide_ChangeIDPOIDCConfig(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewIDPOIDCConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"clientid1",
|
||||
"config1",
|
||||
"issuer",
|
||||
@ -302,8 +302,8 @@ func TestCommandSide_ChangeIDPOIDCConfig(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
r := &Commands{
|
||||
eventstore: tt.fields.eventstore,
|
||||
idpConfigSecretCrypto: tt.fields.secretCrypto,
|
||||
eventstore: tt.fields.eventstore,
|
||||
idpConfigEncryption: tt.fields.secretCrypto,
|
||||
}
|
||||
got, err := r.ChangeIDPOIDCConfig(tt.args.ctx, tt.args.config, tt.args.resourceOwner)
|
||||
if tt.res.err == nil {
|
||||
@ -321,7 +321,7 @@ func TestCommandSide_ChangeIDPOIDCConfig(t *testing.T) {
|
||||
|
||||
func newIDPOIDCConfigChangedEvent(ctx context.Context, orgID, configID, clientID, issuer, authorizationEndpoint, tokenEndpoint string, secret *crypto.CryptoValue, displayMapping, usernameMapping domain.OIDCMappingField, scopes []string) *org.IDPOIDCConfigChangedEvent {
|
||||
event, _ := org.NewIDPOIDCConfigChangedEvent(ctx,
|
||||
&org.NewAggregate(orgID, orgID).Aggregate,
|
||||
&org.NewAggregate(orgID).Aggregate,
|
||||
configID,
|
||||
[]idpconfig.OIDCConfigChanges{
|
||||
idpconfig.ChangeClientID(clientID),
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
"github.com/caos/zitadel/internal/telemetry/tracing"
|
||||
)
|
||||
|
||||
func (c *commandNew) AddOrgMember(a *org.Aggregate, userID string, roles ...string) preparation.Validation {
|
||||
func (c *Commands) AddOrgMemberCommand(a *org.Aggregate, userID string, roles ...string) preparation.Validation {
|
||||
return func() (preparation.CreateCommands, error) {
|
||||
if userID == "" {
|
||||
return nil, errors.ThrowInvalidArgument(nil, "ORG-4Mlfs", "Errors.Invalid.Argument")
|
||||
@ -26,7 +26,7 @@ func (c *commandNew) AddOrgMember(a *org.Aggregate, userID string, roles ...stri
|
||||
}
|
||||
return func(ctx context.Context, filter preparation.FilterToQueryReducer) ([]eventstore.Command, error) {
|
||||
if exists, err := ExistsUser(ctx, filter, userID, a.ID); err != nil || !exists {
|
||||
return nil, errors.ThrowNotFound(err, "ORG-GoXOn", "Errors.User.NotFound")
|
||||
return nil, errors.ThrowPreconditionFailed(err, "ORG-GoXOn", "Errors.User.NotFound")
|
||||
}
|
||||
if isMember, err := IsOrgMember(ctx, filter, a.ID, userID); err != nil || isMember {
|
||||
return nil, errors.ThrowAlreadyExists(err, "ORG-poWwe", "Errors.Org.Member.AlreadyExists")
|
||||
@ -73,25 +73,18 @@ func IsOrgMember(ctx context.Context, filter preparation.FilterToQueryReducer, o
|
||||
return isMember, nil
|
||||
}
|
||||
|
||||
func (c *Commands) AddOrgMember(ctx context.Context, member *domain.Member) (*domain.Member, error) {
|
||||
if member.UserID == "" {
|
||||
return nil, errors.ThrowInvalidArgument(nil, "Org-u8fkf", "Errors.Org.MemberInvalid")
|
||||
}
|
||||
addedMember := NewOrgMemberWriteModel(member.AggregateID, member.UserID)
|
||||
orgAgg := OrgAggregateFromWriteModel(&addedMember.WriteModel)
|
||||
err := c.checkUserExists(ctx, addedMember.UserID, "")
|
||||
if err != nil {
|
||||
return nil, errors.ThrowPreconditionFailed(err, "Org-2H8ds", "Errors.User.NotFound")
|
||||
}
|
||||
event, err := c.addOrgMember(ctx, orgAgg, addedMember, member)
|
||||
func (c *Commands) AddOrgMember(ctx context.Context, userID, orgID string, roles ...string) (*domain.Member, error) {
|
||||
orgAgg := org.NewAggregate(orgID)
|
||||
cmds, err := preparation.PrepareCommands(ctx, c.eventstore.Filter, c.AddOrgMemberCommand(orgAgg, userID, roles...))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pushedEvents, err := c.eventstore.Push(ctx, event)
|
||||
events, err := c.eventstore.Push(ctx, cmds...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = AppendAndReduce(addedMember, pushedEvents...)
|
||||
addedMember := NewOrgMemberWriteModel(orgID, userID)
|
||||
err = AppendAndReduce(addedMember, events...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ func TestAddMember(t *testing.T) {
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
agg := org.NewAggregate("test", "test")
|
||||
agg := org.NewAggregate("test")
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -85,7 +85,7 @@ func TestAddMember(t *testing.T) {
|
||||
}).Filter(),
|
||||
},
|
||||
want: Want{
|
||||
CreateErr: errors.ThrowNotFound(nil, "ORG-GoXOn", "Errors.User.NotFound"),
|
||||
CreateErr: errors.ThrowPreconditionFailed(nil, "ORG-GoXOn", "Errors.User.NotFound"),
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -116,7 +116,7 @@ func TestAddMember(t *testing.T) {
|
||||
return []eventstore.Event{
|
||||
org.NewMemberAddedEvent(
|
||||
ctx,
|
||||
&org.NewAggregate("id", "ro").Aggregate,
|
||||
&org.NewAggregate("id").Aggregate,
|
||||
"userID",
|
||||
),
|
||||
}, nil
|
||||
@ -165,7 +165,7 @@ func TestAddMember(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
AssertValidation(t, (&commandNew{zitadelRoles: tt.args.zitadelRoles}).AddOrgMember(tt.args.a, tt.args.userID, tt.args.roles...), tt.args.filter, tt.want)
|
||||
AssertValidation(t, (&Commands{zitadelRoles: tt.args.zitadelRoles}).AddOrgMemberCommand(tt.args.a, tt.args.userID, tt.args.roles...), tt.args.filter, tt.want)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -201,7 +201,7 @@ func TestIsMember(t *testing.T) {
|
||||
return []eventstore.Event{
|
||||
org.NewMemberAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("orgID", "ro").Aggregate,
|
||||
&org.NewAggregate("orgID").Aggregate,
|
||||
"userID",
|
||||
),
|
||||
}, nil
|
||||
@ -219,12 +219,12 @@ func TestIsMember(t *testing.T) {
|
||||
return []eventstore.Event{
|
||||
org.NewMemberAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("orgID", "ro").Aggregate,
|
||||
&org.NewAggregate("orgID").Aggregate,
|
||||
"userID",
|
||||
),
|
||||
org.NewMemberRemovedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("orgID", "ro").Aggregate,
|
||||
&org.NewAggregate("orgID").Aggregate,
|
||||
"userID",
|
||||
),
|
||||
}, nil
|
||||
@ -242,12 +242,12 @@ func TestIsMember(t *testing.T) {
|
||||
return []eventstore.Event{
|
||||
org.NewMemberAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("orgID", "ro").Aggregate,
|
||||
&org.NewAggregate("orgID").Aggregate,
|
||||
"userID",
|
||||
),
|
||||
org.NewMemberCascadeRemovedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("orgID", "ro").Aggregate,
|
||||
&org.NewAggregate("orgID").Aggregate,
|
||||
"userID",
|
||||
),
|
||||
}, nil
|
||||
@ -292,7 +292,9 @@ func TestCommandSide_AddOrgMember(t *testing.T) {
|
||||
}
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
member *domain.Member
|
||||
userID string
|
||||
orgID string
|
||||
roles []string
|
||||
}
|
||||
type res struct {
|
||||
want *domain.Member
|
||||
@ -312,12 +314,25 @@ func TestCommandSide_AddOrgMember(t *testing.T) {
|
||||
),
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
member: &domain.Member{
|
||||
ObjectRoot: models.ObjectRoot{
|
||||
AggregateID: "org1",
|
||||
},
|
||||
},
|
||||
ctx: context.Background(),
|
||||
orgID: "org1",
|
||||
},
|
||||
res: res{
|
||||
err: errors.IsErrorInvalidArgument,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "invalid roles, error",
|
||||
fields: fields{
|
||||
eventstore: eventstoreExpect(
|
||||
t,
|
||||
),
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
orgID: "org1",
|
||||
userID: "user1",
|
||||
roles: []string{"ORG_OWNER"},
|
||||
},
|
||||
res: res{
|
||||
err: errors.IsErrorInvalidArgument,
|
||||
@ -330,58 +345,22 @@ func TestCommandSide_AddOrgMember(t *testing.T) {
|
||||
t,
|
||||
expectFilter(),
|
||||
),
|
||||
zitadelRoles: []authz.RoleMapping{
|
||||
{
|
||||
Role: domain.RoleOrgOwner,
|
||||
},
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
member: &domain.Member{
|
||||
ObjectRoot: models.ObjectRoot{
|
||||
AggregateID: "org1",
|
||||
},
|
||||
UserID: "user1",
|
||||
Roles: []string{domain.RoleOrgOwner},
|
||||
},
|
||||
ctx: context.Background(),
|
||||
orgID: "org1",
|
||||
userID: "user1",
|
||||
roles: []string{domain.RoleOrgOwner},
|
||||
},
|
||||
res: res{
|
||||
err: errors.IsPreconditionFailed,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "invalid roles, error",
|
||||
fields: fields{
|
||||
eventstore: eventstoreExpect(
|
||||
t,
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
user.NewHumanAddedEvent(context.Background(),
|
||||
&user.NewAggregate("user1", "org1").Aggregate,
|
||||
"username1",
|
||||
"firstname1",
|
||||
"lastname1",
|
||||
"nickname1",
|
||||
"displayname1",
|
||||
language.German,
|
||||
domain.GenderMale,
|
||||
"email1",
|
||||
true,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
member: &domain.Member{
|
||||
ObjectRoot: models.ObjectRoot{
|
||||
AggregateID: "org1",
|
||||
},
|
||||
UserID: "user1",
|
||||
Roles: []string{"ORG_OWNER"},
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
err: errors.IsErrorInvalidArgument,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "member already exists, precondition error",
|
||||
fields: fields{
|
||||
@ -406,7 +385,7 @@ func TestCommandSide_AddOrgMember(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewMemberAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"user1",
|
||||
),
|
||||
),
|
||||
@ -419,14 +398,10 @@ func TestCommandSide_AddOrgMember(t *testing.T) {
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
member: &domain.Member{
|
||||
ObjectRoot: models.ObjectRoot{
|
||||
AggregateID: "org1",
|
||||
},
|
||||
UserID: "user1",
|
||||
Roles: []string{"ORG_OWNER"},
|
||||
},
|
||||
ctx: context.Background(),
|
||||
orgID: "org1",
|
||||
userID: "user1",
|
||||
roles: []string{"ORG_OWNER"},
|
||||
},
|
||||
res: res{
|
||||
err: errors.IsErrorAlreadyExists,
|
||||
@ -457,7 +432,7 @@ func TestCommandSide_AddOrgMember(t *testing.T) {
|
||||
expectPushFailed(errors.ThrowAlreadyExists(nil, "ERROR", "internal"),
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewMemberAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"user1",
|
||||
[]string{"ORG_OWNER"}...,
|
||||
)),
|
||||
@ -472,14 +447,10 @@ func TestCommandSide_AddOrgMember(t *testing.T) {
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
member: &domain.Member{
|
||||
ObjectRoot: models.ObjectRoot{
|
||||
AggregateID: "org1",
|
||||
},
|
||||
UserID: "user1",
|
||||
Roles: []string{"ORG_OWNER"},
|
||||
},
|
||||
ctx: context.Background(),
|
||||
orgID: "org1",
|
||||
userID: "user1",
|
||||
roles: []string{"ORG_OWNER"},
|
||||
},
|
||||
res: res{
|
||||
err: errors.IsErrorAlreadyExists,
|
||||
@ -510,7 +481,7 @@ func TestCommandSide_AddOrgMember(t *testing.T) {
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewMemberAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"user1",
|
||||
[]string{"ORG_OWNER"}...,
|
||||
)),
|
||||
@ -525,14 +496,10 @@ func TestCommandSide_AddOrgMember(t *testing.T) {
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
member: &domain.Member{
|
||||
ObjectRoot: models.ObjectRoot{
|
||||
AggregateID: "org1",
|
||||
},
|
||||
UserID: "user1",
|
||||
Roles: []string{"ORG_OWNER"},
|
||||
},
|
||||
ctx: context.Background(),
|
||||
orgID: "org1",
|
||||
userID: "user1",
|
||||
roles: []string{"ORG_OWNER"},
|
||||
},
|
||||
res: res{
|
||||
want: &domain.Member{
|
||||
@ -552,7 +519,7 @@ func TestCommandSide_AddOrgMember(t *testing.T) {
|
||||
eventstore: tt.fields.eventstore,
|
||||
zitadelRoles: tt.fields.zitadelRoles,
|
||||
}
|
||||
got, err := r.AddOrgMember(tt.args.ctx, tt.args.member)
|
||||
got, err := r.AddOrgMember(tt.args.ctx, tt.args.userID, tt.args.orgID, tt.args.roles...)
|
||||
if tt.res.err == nil {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
@ -660,7 +627,7 @@ func TestCommandSide_ChangeOrgMember(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewMemberAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"user1",
|
||||
[]string{"ORG_OWNER"}...,
|
||||
),
|
||||
@ -695,7 +662,7 @@ func TestCommandSide_ChangeOrgMember(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewMemberAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"user1",
|
||||
[]string{"ORG_OWNER"}...,
|
||||
),
|
||||
@ -704,7 +671,7 @@ func TestCommandSide_ChangeOrgMember(t *testing.T) {
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewMemberChangedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"user1",
|
||||
[]string{"ORG_OWNER", "ORG_OWNER_VIEWER"}...,
|
||||
)),
|
||||
|
@ -60,7 +60,7 @@ func TestCommandSide_AddDomainPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
),
|
||||
@ -90,7 +90,7 @@ func TestCommandSide_AddDomainPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
),
|
||||
@ -203,7 +203,7 @@ func TestCommandSide_ChangeDomainPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
),
|
||||
@ -231,7 +231,7 @@ func TestCommandSide_ChangeDomainPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
),
|
||||
@ -341,7 +341,7 @@ func TestCommandSide_RemoveDomainPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
),
|
||||
@ -351,7 +351,7 @@ func TestCommandSide_RemoveDomainPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPolicyRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate),
|
||||
&org.NewAggregate("org1").Aggregate),
|
||||
),
|
||||
},
|
||||
),
|
||||
@ -386,7 +386,7 @@ func TestCommandSide_RemoveDomainPolicy(t *testing.T) {
|
||||
|
||||
func newDomainPolicyChangedEvent(ctx context.Context, orgID string, userLoginMustBeDomain, validateOrgDomains bool) *org.DomainPolicyChangedEvent {
|
||||
event, _ := org.NewDomainPolicyChangedEvent(ctx,
|
||||
&org.NewAggregate(orgID, orgID).Aggregate,
|
||||
&org.NewAggregate(orgID).Aggregate,
|
||||
[]policy.DomainPolicyChanges{
|
||||
policy.ChangeUserLoginMustBeDomain(userLoginMustBeDomain),
|
||||
policy.ChangeValidateOrgDomains(validateOrgDomains),
|
||||
|
@ -66,7 +66,7 @@ func TestCommandSide_AddLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -180,7 +180,7 @@ func TestCommandSide_AddLabelPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -324,7 +324,7 @@ func TestCommandSide_ChangeLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -389,7 +389,7 @@ func TestCommandSide_ChangeLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -454,7 +454,7 @@ func TestCommandSide_ChangeLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -623,7 +623,7 @@ func TestCommandSide_ActivateLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -642,7 +642,7 @@ func TestCommandSide_ActivateLabelPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyActivatedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate),
|
||||
&org.NewAggregate("org1").Aggregate),
|
||||
),
|
||||
},
|
||||
),
|
||||
@ -727,7 +727,7 @@ func TestCommandSide_RemoveLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -746,7 +746,7 @@ func TestCommandSide_RemoveLabelPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate),
|
||||
&org.NewAggregate("org1").Aggregate),
|
||||
),
|
||||
},
|
||||
),
|
||||
@ -852,7 +852,7 @@ func TestCommandSide_AddLogoLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -894,7 +894,7 @@ func TestCommandSide_AddLogoLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -913,7 +913,7 @@ func TestCommandSide_AddLogoLabelPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyLogoAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"logo",
|
||||
),
|
||||
),
|
||||
@ -1022,7 +1022,7 @@ func TestCommandSide_RemoveLogoLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -1038,7 +1038,7 @@ func TestCommandSide_RemoveLogoLabelPolicy(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyLogoAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"key",
|
||||
),
|
||||
),
|
||||
@ -1047,7 +1047,7 @@ func TestCommandSide_RemoveLogoLabelPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyLogoRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"key",
|
||||
),
|
||||
),
|
||||
@ -1162,7 +1162,7 @@ func TestCommandSide_AddIconLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -1204,7 +1204,7 @@ func TestCommandSide_AddIconLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -1223,7 +1223,7 @@ func TestCommandSide_AddIconLabelPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyIconAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"icon",
|
||||
),
|
||||
),
|
||||
@ -1330,7 +1330,7 @@ func TestCommandSide_RemoveIconLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -1346,7 +1346,7 @@ func TestCommandSide_RemoveIconLabelPolicy(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyIconAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"key",
|
||||
),
|
||||
),
|
||||
@ -1355,7 +1355,7 @@ func TestCommandSide_RemoveIconLabelPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyIconRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"key",
|
||||
),
|
||||
),
|
||||
@ -1469,7 +1469,7 @@ func TestCommandSide_AddLogoDarkLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -1511,7 +1511,7 @@ func TestCommandSide_AddLogoDarkLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -1530,7 +1530,7 @@ func TestCommandSide_AddLogoDarkLabelPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyLogoDarkAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"logo",
|
||||
),
|
||||
),
|
||||
@ -1639,7 +1639,7 @@ func TestCommandSide_RemoveLogoDarkLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -1655,7 +1655,7 @@ func TestCommandSide_RemoveLogoDarkLabelPolicy(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyLogoDarkAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"key",
|
||||
),
|
||||
),
|
||||
@ -1664,7 +1664,7 @@ func TestCommandSide_RemoveLogoDarkLabelPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyLogoDarkRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"key",
|
||||
),
|
||||
),
|
||||
@ -1779,7 +1779,7 @@ func TestCommandSide_AddIconDarkLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -1821,7 +1821,7 @@ func TestCommandSide_AddIconDarkLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -1840,7 +1840,7 @@ func TestCommandSide_AddIconDarkLabelPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyIconDarkAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"icon",
|
||||
),
|
||||
),
|
||||
@ -1945,7 +1945,7 @@ func TestCommandSide_RemoveIconDarkLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -1961,7 +1961,7 @@ func TestCommandSide_RemoveIconDarkLabelPolicy(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyIconDarkAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"key",
|
||||
),
|
||||
),
|
||||
@ -1970,7 +1970,7 @@ func TestCommandSide_RemoveIconDarkLabelPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyIconDarkRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"key",
|
||||
),
|
||||
),
|
||||
@ -2076,7 +2076,7 @@ func TestCommandSide_AddFontLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -2118,7 +2118,7 @@ func TestCommandSide_AddFontLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -2137,7 +2137,7 @@ func TestCommandSide_AddFontLabelPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyFontAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"font",
|
||||
),
|
||||
),
|
||||
@ -2242,7 +2242,7 @@ func TestCommandSide_RemoveFontLabelPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
"#ffffff",
|
||||
@ -2258,7 +2258,7 @@ func TestCommandSide_RemoveFontLabelPolicy(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyFontAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"key",
|
||||
),
|
||||
),
|
||||
@ -2267,7 +2267,7 @@ func TestCommandSide_RemoveFontLabelPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLabelPolicyFontRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"key",
|
||||
),
|
||||
),
|
||||
@ -2308,7 +2308,7 @@ func TestCommandSide_RemoveFontLabelPolicy(t *testing.T) {
|
||||
|
||||
func newLabelPolicyChangedEvent(ctx context.Context, orgID, primaryColor, backgroundColor, warnColor, fontColor, primaryColorDark, backgroundColorDark, warnColorDark, fontColorDark string, hideLoginNameSuffix, errMsgPopup, disableWatermark bool) *org.LabelPolicyChangedEvent {
|
||||
event, _ := org.NewLabelPolicyChangedEvent(ctx,
|
||||
&org.NewAggregate(orgID, orgID).Aggregate,
|
||||
&org.NewAggregate(orgID).Aggregate,
|
||||
[]policy.LabelPolicyChanges{
|
||||
policy.ChangePrimaryColor(primaryColor),
|
||||
policy.ChangeBackgroundColor(backgroundColor),
|
||||
|
@ -60,7 +60,7 @@ func TestCommandSide_AddPasswordLockoutPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLockoutPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
10,
|
||||
true,
|
||||
),
|
||||
@ -90,7 +90,7 @@ func TestCommandSide_AddPasswordLockoutPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLockoutPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
10,
|
||||
true,
|
||||
),
|
||||
@ -203,7 +203,7 @@ func TestCommandSide_ChangePasswordLockoutPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLockoutPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
10,
|
||||
true,
|
||||
),
|
||||
@ -231,7 +231,7 @@ func TestCommandSide_ChangePasswordLockoutPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLockoutPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
10,
|
||||
true,
|
||||
),
|
||||
@ -341,7 +341,7 @@ func TestCommandSide_RemovePasswordLockoutPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLockoutPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
10,
|
||||
true,
|
||||
),
|
||||
@ -351,7 +351,7 @@ func TestCommandSide_RemovePasswordLockoutPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLockoutPolicyRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate),
|
||||
&org.NewAggregate("org1").Aggregate),
|
||||
),
|
||||
},
|
||||
),
|
||||
@ -386,7 +386,7 @@ func TestCommandSide_RemovePasswordLockoutPolicy(t *testing.T) {
|
||||
|
||||
func newPasswordLockoutPolicyChangedEvent(ctx context.Context, orgID string, maxAttempts uint64, showLockoutFailure bool) *org.LockoutPolicyChangedEvent {
|
||||
event, _ := org.NewLockoutPolicyChangedEvent(ctx,
|
||||
&org.NewAggregate(orgID, orgID).Aggregate,
|
||||
&org.NewAggregate(orgID).Aggregate,
|
||||
[]policy.LockoutPolicyChanges{
|
||||
policy.ChangeMaxAttempts(maxAttempts),
|
||||
policy.ChangeShowLockOutFailures(showLockoutFailure),
|
||||
|
@ -73,7 +73,7 @@ func TestCommandSide_AddLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
@ -185,7 +185,7 @@ func TestCommandSide_AddLoginPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
@ -334,7 +334,7 @@ func TestCommandSide_ChangeLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
@ -398,7 +398,7 @@ func TestCommandSide_ChangeLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
@ -463,7 +463,7 @@ func TestCommandSide_ChangeLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
@ -632,7 +632,7 @@ func TestCommandSide_RemoveLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
@ -651,7 +651,7 @@ func TestCommandSide_RemoveLoginPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate),
|
||||
&org.NewAggregate("org1").Aggregate),
|
||||
),
|
||||
},
|
||||
),
|
||||
@ -770,7 +770,7 @@ func TestCommandSide_AddIDPProviderLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
@ -809,7 +809,7 @@ func TestCommandSide_AddIDPProviderLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
@ -827,7 +827,7 @@ func TestCommandSide_AddIDPProviderLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewIDPConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"name",
|
||||
domain.IDPConfigTypeOIDC,
|
||||
@ -839,7 +839,7 @@ func TestCommandSide_AddIDPProviderLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewIdentityProviderAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "or1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
domain.IdentityProviderTypeOrg,
|
||||
),
|
||||
@ -868,7 +868,7 @@ func TestCommandSide_AddIDPProviderLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
@ -886,7 +886,7 @@ func TestCommandSide_AddIDPProviderLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewIDPConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"name",
|
||||
domain.IDPConfigTypeOIDC,
|
||||
@ -900,7 +900,7 @@ func TestCommandSide_AddIDPProviderLoginPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewIdentityProviderAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
domain.IdentityProviderTypeOrg),
|
||||
),
|
||||
@ -1030,7 +1030,7 @@ func TestCommandSide_RemoveIDPProviderLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
@ -1069,7 +1069,7 @@ func TestCommandSide_RemoveIDPProviderLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
@ -1087,14 +1087,14 @@ func TestCommandSide_RemoveIDPProviderLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewIdentityProviderAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
domain.IdentityProviderTypeOrg,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewIdentityProviderRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
),
|
||||
),
|
||||
@ -1120,7 +1120,7 @@ func TestCommandSide_RemoveIDPProviderLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
@ -1138,7 +1138,7 @@ func TestCommandSide_RemoveIDPProviderLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewIdentityProviderAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
domain.IdentityProviderTypeOrg,
|
||||
),
|
||||
@ -1148,7 +1148,7 @@ func TestCommandSide_RemoveIDPProviderLoginPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewIdentityProviderRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1"),
|
||||
),
|
||||
},
|
||||
@ -1178,7 +1178,7 @@ func TestCommandSide_RemoveIDPProviderLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
@ -1196,7 +1196,7 @@ func TestCommandSide_RemoveIDPProviderLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewIdentityProviderAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
domain.IdentityProviderTypeOrg,
|
||||
),
|
||||
@ -1206,7 +1206,7 @@ func TestCommandSide_RemoveIDPProviderLoginPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewIdentityProviderRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1"),
|
||||
),
|
||||
},
|
||||
@ -1244,7 +1244,7 @@ func TestCommandSide_RemoveIDPProviderLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
@ -1262,7 +1262,7 @@ func TestCommandSide_RemoveIDPProviderLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewIdentityProviderAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
domain.IdentityProviderTypeOrg,
|
||||
),
|
||||
@ -1279,7 +1279,7 @@ func TestCommandSide_RemoveIDPProviderLoginPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewIdentityProviderRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1"),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
@ -1390,7 +1390,7 @@ func TestCommandSide_AddSecondFactorLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicySecondFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeOTP,
|
||||
),
|
||||
),
|
||||
@ -1416,7 +1416,7 @@ func TestCommandSide_AddSecondFactorLoginPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicySecondFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeOTP),
|
||||
),
|
||||
},
|
||||
@ -1526,13 +1526,13 @@ func TestCommandSide_RemoveSecondFactoroginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicySecondFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeOTP,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicySecondFactorRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeOTP,
|
||||
),
|
||||
),
|
||||
@ -1556,7 +1556,7 @@ func TestCommandSide_RemoveSecondFactoroginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicySecondFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeOTP,
|
||||
),
|
||||
),
|
||||
@ -1565,7 +1565,7 @@ func TestCommandSide_RemoveSecondFactoroginPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicySecondFactorRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.SecondFactorTypeOTP),
|
||||
),
|
||||
},
|
||||
@ -1657,7 +1657,7 @@ func TestCommandSide_AddMultiFactorLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyMultiFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.MultiFactorTypeU2FWithPIN,
|
||||
),
|
||||
),
|
||||
@ -1683,7 +1683,7 @@ func TestCommandSide_AddMultiFactorLoginPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyMultiFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.MultiFactorTypeU2FWithPIN),
|
||||
),
|
||||
},
|
||||
@ -1793,13 +1793,13 @@ func TestCommandSide_RemoveMultiFactorLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyMultiFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.MultiFactorTypeU2FWithPIN,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyMultiFactorRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.MultiFactorTypeU2FWithPIN,
|
||||
),
|
||||
),
|
||||
@ -1823,7 +1823,7 @@ func TestCommandSide_RemoveMultiFactorLoginPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyMultiFactorAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.MultiFactorTypeU2FWithPIN,
|
||||
),
|
||||
),
|
||||
@ -1832,7 +1832,7 @@ func TestCommandSide_RemoveMultiFactorLoginPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyMultiFactorRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
domain.MultiFactorTypeU2FWithPIN),
|
||||
),
|
||||
},
|
||||
@ -1894,7 +1894,7 @@ func newLoginPolicyChangedEvent(ctx context.Context, orgID string, usernamePassw
|
||||
changes = append(changes, policy.ChangeMultiFactorCheckLifetime(*multiFactorLifetime))
|
||||
}
|
||||
event, _ := org.NewLoginPolicyChangedEvent(ctx,
|
||||
&org.NewAggregate(orgID, orgID).Aggregate,
|
||||
&org.NewAggregate(orgID).Aggregate,
|
||||
changes,
|
||||
)
|
||||
return event
|
||||
|
@ -59,7 +59,7 @@ func TestCommandSide_AddMailTemplate(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewMailTemplateAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
[]byte("template"),
|
||||
),
|
||||
),
|
||||
@ -87,7 +87,7 @@ func TestCommandSide_AddMailTemplate(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewMailTemplateAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
[]byte("template"),
|
||||
),
|
||||
),
|
||||
@ -195,7 +195,7 @@ func TestCommandSide_ChangeMailTemplate(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewMailTemplateAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
[]byte("template"),
|
||||
),
|
||||
),
|
||||
@ -221,7 +221,7 @@ func TestCommandSide_ChangeMailTemplate(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewMailTemplateAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
[]byte("template"),
|
||||
),
|
||||
),
|
||||
@ -328,7 +328,7 @@ func TestCommandSide_RemoveMailTemplate(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewMailTemplateAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
[]byte("template"),
|
||||
),
|
||||
),
|
||||
@ -337,7 +337,7 @@ func TestCommandSide_RemoveMailTemplate(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewMailTemplateRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate),
|
||||
&org.NewAggregate("org1").Aggregate),
|
||||
),
|
||||
},
|
||||
),
|
||||
@ -372,7 +372,7 @@ func TestCommandSide_RemoveMailTemplate(t *testing.T) {
|
||||
|
||||
func newMailTemplateChangedEvent(ctx context.Context, orgID string, template string) *org.MailTemplateChangedEvent {
|
||||
event, _ := org.NewMailTemplateChangedEvent(ctx,
|
||||
&org.NewAggregate(orgID, orgID).Aggregate,
|
||||
&org.NewAggregate(orgID).Aggregate,
|
||||
[]policy.MailTemplateChanges{
|
||||
policy.ChangeTemplate([]byte(template)),
|
||||
},
|
||||
|
@ -60,7 +60,7 @@ func TestCommandSide_AddPasswordAgePolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordAgePolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
365,
|
||||
10,
|
||||
),
|
||||
@ -90,7 +90,7 @@ func TestCommandSide_AddPasswordAgePolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordAgePolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
10,
|
||||
365,
|
||||
),
|
||||
@ -203,7 +203,7 @@ func TestCommandSide_ChangePasswordAgePolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordAgePolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
10,
|
||||
365,
|
||||
),
|
||||
@ -231,7 +231,7 @@ func TestCommandSide_ChangePasswordAgePolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordAgePolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
10,
|
||||
365,
|
||||
),
|
||||
@ -341,7 +341,7 @@ func TestCommandSide_RemovePasswordAgePolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordAgePolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
10,
|
||||
365,
|
||||
),
|
||||
@ -351,7 +351,7 @@ func TestCommandSide_RemovePasswordAgePolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordAgePolicyRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate),
|
||||
&org.NewAggregate("org1").Aggregate),
|
||||
),
|
||||
},
|
||||
),
|
||||
@ -389,7 +389,7 @@ func TestCommandSide_RemovePasswordAgePolicy(t *testing.T) {
|
||||
|
||||
func newPasswordAgePolicyChangedEvent(ctx context.Context, orgID string, maxAgeDays, expireWarnDays uint64) *org.PasswordAgePolicyChangedEvent {
|
||||
event, _ := org.NewPasswordAgePolicyChangedEvent(ctx,
|
||||
&org.NewAggregate(orgID, orgID).Aggregate,
|
||||
&org.NewAggregate(orgID).Aggregate,
|
||||
[]policy.PasswordAgePolicyChanges{
|
||||
policy.ChangeMaxAgeDays(maxAgeDays),
|
||||
policy.ChangeExpireWarnDays(expireWarnDays),
|
||||
|
@ -63,7 +63,7 @@ func TestCommandSide_AddPasswordComplexityPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordComplexityPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
8,
|
||||
true, true, true, true,
|
||||
),
|
||||
@ -96,7 +96,7 @@ func TestCommandSide_AddPasswordComplexityPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordComplexityPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
8,
|
||||
true, true, true, true,
|
||||
),
|
||||
@ -221,7 +221,7 @@ func TestCommandSide_ChangePasswordComplexityPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordComplexityPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
8,
|
||||
true, true, true, true,
|
||||
),
|
||||
@ -252,7 +252,7 @@ func TestCommandSide_ChangePasswordComplexityPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordComplexityPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
8,
|
||||
true, true, true, true,
|
||||
),
|
||||
@ -368,7 +368,7 @@ func TestCommandSide_RemovePasswordComplexityPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordComplexityPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
8,
|
||||
true, true, true, true,
|
||||
),
|
||||
@ -378,7 +378,7 @@ func TestCommandSide_RemovePasswordComplexityPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordComplexityPolicyRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate),
|
||||
&org.NewAggregate("org1").Aggregate),
|
||||
),
|
||||
},
|
||||
),
|
||||
@ -416,7 +416,7 @@ func TestCommandSide_RemovePasswordComplexityPolicy(t *testing.T) {
|
||||
|
||||
func newPasswordComplexityPolicyChangedEvent(ctx context.Context, orgID string, minLength uint64, hasUpper, hasLower, hasNumber, hasSymbol bool) *org.PasswordComplexityPolicyChangedEvent {
|
||||
event, _ := org.NewPasswordComplexityPolicyChangedEvent(ctx,
|
||||
&org.NewAggregate(orgID, orgID).Aggregate,
|
||||
&org.NewAggregate(orgID).Aggregate,
|
||||
[]policy.PasswordComplexityPolicyChanges{
|
||||
policy.ChangeMinLength(minLength),
|
||||
policy.ChangeHasUppercase(hasUpper),
|
||||
|
@ -61,7 +61,7 @@ func TestCommandSide_AddPrivacyPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPrivacyPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"TOSLink",
|
||||
"PrivacyLink",
|
||||
"HelpLink",
|
||||
@ -93,7 +93,7 @@ func TestCommandSide_AddPrivacyPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewPrivacyPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"TOSLink",
|
||||
"PrivacyLink",
|
||||
"HelpLink",
|
||||
@ -134,7 +134,7 @@ func TestCommandSide_AddPrivacyPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewPrivacyPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
@ -252,7 +252,7 @@ func TestCommandSide_ChangePrivacyPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPrivacyPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"TOSLink",
|
||||
"PrivacyLink",
|
||||
"HelpLink",
|
||||
@ -282,7 +282,7 @@ func TestCommandSide_ChangePrivacyPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPrivacyPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"TOSLink",
|
||||
"PrivacyLink",
|
||||
"HelpLink",
|
||||
@ -327,7 +327,7 @@ func TestCommandSide_ChangePrivacyPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPrivacyPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"TOSLink",
|
||||
"PrivacyLink",
|
||||
"HelpLink",
|
||||
@ -440,7 +440,7 @@ func TestCommandSide_RemovePrivacyPolicy(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPrivacyPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"TOSLink",
|
||||
"PrivacyLink",
|
||||
"HelpLink",
|
||||
@ -451,7 +451,7 @@ func TestCommandSide_RemovePrivacyPolicy(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(
|
||||
org.NewPrivacyPolicyRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate),
|
||||
&org.NewAggregate("org1").Aggregate),
|
||||
),
|
||||
},
|
||||
),
|
||||
@ -489,7 +489,7 @@ func TestCommandSide_RemovePrivacyPolicy(t *testing.T) {
|
||||
|
||||
func newPrivacyPolicyChangedEvent(ctx context.Context, orgID string, tosLink, privacyLink, helpLink string) *org.PrivacyPolicyChangedEvent {
|
||||
event, _ := org.NewPrivacyPolicyChangedEvent(ctx,
|
||||
&org.NewAggregate(orgID, orgID).Aggregate,
|
||||
&org.NewAggregate(orgID).Aggregate,
|
||||
[]policy.PrivacyPolicyChanges{
|
||||
policy.ChangeTOSLink(tosLink),
|
||||
policy.ChangePrivacyLink(privacyLink),
|
||||
|
@ -27,7 +27,7 @@ func TestAddOrg(t *testing.T) {
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
agg := org.NewAggregate("test", "test")
|
||||
agg := org.NewAggregate("test")
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -178,23 +178,23 @@ func TestCommandSide_AddOrg(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewOrgAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"Org")),
|
||||
eventFromEventPusher(org.NewDomainAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"org.iam-domain")),
|
||||
eventFromEventPusher(org.NewDomainVerifiedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"org.iam-domain")),
|
||||
eventFromEventPusher(org.NewDomainPrimarySetEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"org.iam-domain")),
|
||||
eventFromEventPusher(org.NewMemberAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"user1", domain.RoleOrgOwner)),
|
||||
},
|
||||
uniqueConstraintsFromEventConstraint(org.NewAddOrgNameUniqueConstraint("Org")),
|
||||
@ -247,23 +247,23 @@ func TestCommandSide_AddOrg(t *testing.T) {
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewOrgAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"Org")),
|
||||
eventFromEventPusher(org.NewDomainAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"org.iam-domain")),
|
||||
eventFromEventPusher(org.NewDomainVerifiedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"org.iam-domain")),
|
||||
eventFromEventPusher(org.NewDomainPrimarySetEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"org.iam-domain")),
|
||||
eventFromEventPusher(org.NewMemberAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"user1", domain.RoleOrgOwner)),
|
||||
},
|
||||
uniqueConstraintsFromEventConstraint(org.NewAddOrgNameUniqueConstraint("Org")),
|
||||
@ -315,22 +315,22 @@ func TestCommandSide_AddOrg(t *testing.T) {
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"Org",
|
||||
)),
|
||||
eventFromEventPusher(org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate, "org.iam-domain",
|
||||
&org.NewAggregate("org2").Aggregate, "org.iam-domain",
|
||||
)),
|
||||
eventFromEventPusher(org.NewDomainVerifiedEvent(context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"org.iam-domain",
|
||||
)),
|
||||
eventFromEventPusher(org.NewDomainPrimarySetEvent(context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"org.iam-domain",
|
||||
)),
|
||||
eventFromEventPusher(org.NewMemberAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"user1",
|
||||
domain.RoleOrgOwner,
|
||||
)),
|
||||
@ -450,7 +450,7 @@ func TestCommandSide_ChangeOrg(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org"),
|
||||
),
|
||||
),
|
||||
@ -459,7 +459,7 @@ func TestCommandSide_ChangeOrg(t *testing.T) {
|
||||
errors.ThrowInternal(nil, "id", "message"),
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewOrgChangedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate, "org", "neworg")),
|
||||
&org.NewAggregate("org1").Aggregate, "org", "neworg")),
|
||||
},
|
||||
uniqueConstraintsFromEventConstraint(org.NewRemoveOrgNameUniqueConstraint("org")),
|
||||
uniqueConstraintsFromEventConstraint(org.NewAddOrgNameUniqueConstraint("neworg")),
|
||||
@ -484,37 +484,37 @@ func TestCommandSide_ChangeOrg(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org"),
|
||||
),
|
||||
),
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org"),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org.zitadel.ch"),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org.zitadel.ch"),
|
||||
),
|
||||
),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewOrgChangedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate, "org", "neworg")),
|
||||
&org.NewAggregate("org1").Aggregate, "org", "neworg")),
|
||||
eventFromEventPusher(org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate, "neworg.zitadel.ch")),
|
||||
&org.NewAggregate("org1").Aggregate, "neworg.zitadel.ch")),
|
||||
eventFromEventPusher(org.NewDomainVerifiedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate, "neworg.zitadel.ch")),
|
||||
&org.NewAggregate("org1").Aggregate, "neworg.zitadel.ch")),
|
||||
eventFromEventPusher(org.NewDomainRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate, "org.zitadel.ch", true)),
|
||||
&org.NewAggregate("org1").Aggregate, "org.zitadel.ch", true)),
|
||||
},
|
||||
uniqueConstraintsFromEventConstraint(org.NewRemoveOrgNameUniqueConstraint("org")),
|
||||
uniqueConstraintsFromEventConstraint(org.NewAddOrgNameUniqueConstraint("neworg")),
|
||||
@ -539,44 +539,44 @@ func TestCommandSide_ChangeOrg(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org"),
|
||||
),
|
||||
),
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org"),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org.zitadel.ch"),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org.zitadel.ch"),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPrimarySetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org.zitadel.ch"),
|
||||
),
|
||||
),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewOrgChangedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate, "org", "neworg")),
|
||||
&org.NewAggregate("org1").Aggregate, "org", "neworg")),
|
||||
eventFromEventPusher(org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate, "neworg.zitadel.ch")),
|
||||
&org.NewAggregate("org1").Aggregate, "neworg.zitadel.ch")),
|
||||
eventFromEventPusher(org.NewDomainVerifiedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate, "neworg.zitadel.ch")),
|
||||
&org.NewAggregate("org1").Aggregate, "neworg.zitadel.ch")),
|
||||
eventFromEventPusher(org.NewDomainPrimarySetEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate, "neworg.zitadel.ch")),
|
||||
&org.NewAggregate("org1").Aggregate, "neworg.zitadel.ch")),
|
||||
eventFromEventPusher(org.NewDomainRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate, "org.zitadel.ch", true)),
|
||||
&org.NewAggregate("org1").Aggregate, "org.zitadel.ch", true)),
|
||||
},
|
||||
uniqueConstraintsFromEventConstraint(org.NewRemoveOrgNameUniqueConstraint("org")),
|
||||
uniqueConstraintsFromEventConstraint(org.NewAddOrgNameUniqueConstraint("neworg")),
|
||||
@ -654,12 +654,12 @@ func TestCommandSide_DeactivateOrg(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org"),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewOrgDeactivatedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate),
|
||||
&org.NewAggregate("org1").Aggregate),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -680,7 +680,7 @@ func TestCommandSide_DeactivateOrg(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org"),
|
||||
),
|
||||
),
|
||||
@ -688,7 +688,7 @@ func TestCommandSide_DeactivateOrg(t *testing.T) {
|
||||
errors.ThrowInternal(nil, "id", "message"),
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewOrgDeactivatedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate)),
|
||||
&org.NewAggregate("org1").Aggregate)),
|
||||
},
|
||||
),
|
||||
),
|
||||
@ -709,14 +709,14 @@ func TestCommandSide_DeactivateOrg(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org"),
|
||||
),
|
||||
),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewOrgDeactivatedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
)),
|
||||
},
|
||||
),
|
||||
@ -789,7 +789,7 @@ func TestCommandSide_ReactivateOrg(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org"),
|
||||
),
|
||||
),
|
||||
@ -811,12 +811,12 @@ func TestCommandSide_ReactivateOrg(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org"),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewOrgDeactivatedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -824,7 +824,7 @@ func TestCommandSide_ReactivateOrg(t *testing.T) {
|
||||
errors.ThrowInternal(nil, "id", "message"),
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewOrgReactivatedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
)),
|
||||
},
|
||||
),
|
||||
@ -846,18 +846,18 @@ func TestCommandSide_ReactivateOrg(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"org"),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewOrgDeactivatedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate),
|
||||
&org.NewAggregate("org1").Aggregate),
|
||||
),
|
||||
),
|
||||
expectPush(
|
||||
[]*repository.Event{
|
||||
eventFromEventPusher(org.NewOrgReactivatedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate)),
|
||||
&org.NewAggregate("org1").Aggregate)),
|
||||
},
|
||||
),
|
||||
),
|
||||
|
@ -2,6 +2,10 @@ package command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore"
|
||||
@ -12,8 +16,6 @@ import (
|
||||
"github.com/caos/zitadel/internal/repository/org"
|
||||
"github.com/caos/zitadel/internal/repository/project"
|
||||
"github.com/caos/zitadel/internal/repository/usergrant"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCommandSide_AddProjectGrant(t *testing.T) {
|
||||
@ -123,7 +125,7 @@ func TestCommandSide_AddProjectGrant(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("grantedorg1", "grantedorg1").Aggregate,
|
||||
&org.NewAggregate("grantedorg1").Aggregate,
|
||||
"granted org",
|
||||
),
|
||||
),
|
||||
@ -160,7 +162,7 @@ func TestCommandSide_AddProjectGrant(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("grantedorg1", "grantedorg1").Aggregate,
|
||||
&org.NewAggregate("grantedorg1").Aggregate,
|
||||
"granted org",
|
||||
),
|
||||
),
|
||||
@ -389,7 +391,7 @@ func TestCommandSide_ChangeProjectGrant(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("grantedorg1", "grantedorg1").Aggregate,
|
||||
&org.NewAggregate("grantedorg1").Aggregate,
|
||||
"granted org",
|
||||
),
|
||||
),
|
||||
@ -435,7 +437,7 @@ func TestCommandSide_ChangeProjectGrant(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("grantedorg1", "grantedorg1").Aggregate,
|
||||
&org.NewAggregate("grantedorg1").Aggregate,
|
||||
"granted org",
|
||||
),
|
||||
),
|
||||
@ -489,7 +491,7 @@ func TestCommandSide_ChangeProjectGrant(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("grantedorg1", "grantedorg1").Aggregate,
|
||||
&org.NewAggregate("grantedorg1").Aggregate,
|
||||
"granted org",
|
||||
),
|
||||
),
|
||||
@ -569,7 +571,7 @@ func TestCommandSide_ChangeProjectGrant(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("grantedorg1", "grantedorg1").Aggregate,
|
||||
&org.NewAggregate("grantedorg1").Aggregate,
|
||||
"granted org",
|
||||
),
|
||||
),
|
||||
@ -651,7 +653,7 @@ func TestCommandSide_ChangeProjectGrant(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewOrgAddedEvent(context.Background(),
|
||||
&org.NewAggregate("grantedorg1", "grantedorg1").Aggregate,
|
||||
&org.NewAggregate("grantedorg1").Aggregate,
|
||||
"granted org",
|
||||
),
|
||||
),
|
||||
|
@ -1,73 +0,0 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/api/authz"
|
||||
"github.com/caos/zitadel/internal/command/preparation"
|
||||
"github.com/caos/zitadel/internal/crypto"
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore"
|
||||
"github.com/caos/zitadel/internal/repository/instance"
|
||||
)
|
||||
|
||||
func (c *commandNew) AddSecretGeneratorConfig(ctx context.Context, typ domain.SecretGeneratorType, config *crypto.GeneratorConfig) (*domain.ObjectDetails, error) {
|
||||
agg := instance.NewAggregate(authz.GetInstance(ctx).InstanceID())
|
||||
cmds, err := preparation.PrepareCommands(ctx, c.es.Filter, addSecretGeneratorConfig(agg, typ, config))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
events, err := c.es.Push(ctx, cmds...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &domain.ObjectDetails{
|
||||
Sequence: events[len(events)-1].Sequence(),
|
||||
EventDate: events[len(events)-1].CreationDate(),
|
||||
ResourceOwner: agg.ResourceOwner,
|
||||
}, nil
|
||||
}
|
||||
|
||||
//AddOrg defines the commands to create a new org,
|
||||
// this includes the verified default domain
|
||||
func addSecretGeneratorConfig(a *instance.Aggregate, typ domain.SecretGeneratorType, config *crypto.GeneratorConfig) preparation.Validation {
|
||||
return func() (preparation.CreateCommands, error) {
|
||||
if !typ.Valid() {
|
||||
return nil, errors.ThrowInvalidArgument(nil, "V2-FGqVj", "Errors.InvalidArgument")
|
||||
}
|
||||
if config.Length < 1 {
|
||||
return nil, errors.ThrowInvalidArgument(nil, "V2-jEqCt", "Errors.InvalidArgument")
|
||||
}
|
||||
return func(ctx context.Context, filter preparation.FilterToQueryReducer) ([]eventstore.Command, error) {
|
||||
writeModel := NewInstanceSecretGeneratorConfigWriteModel(ctx, typ)
|
||||
events, err := filter(ctx, writeModel.Query())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
writeModel.AppendEvents(events...)
|
||||
if err = writeModel.Reduce(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if writeModel.State == domain.SecretGeneratorStateActive {
|
||||
return nil, errors.ThrowAlreadyExists(nil, "V2-6CqKo", "Errors.SecretGenerator.AlreadyExists")
|
||||
}
|
||||
|
||||
return []eventstore.Command{
|
||||
instance.NewSecretGeneratorAddedEvent(
|
||||
ctx,
|
||||
&a.Aggregate,
|
||||
typ,
|
||||
config.Length,
|
||||
config.Expiry,
|
||||
config.IncludeLowerLetters,
|
||||
config.IncludeUpperLetters,
|
||||
config.IncludeDigits,
|
||||
config.IncludeSymbols,
|
||||
),
|
||||
}, nil
|
||||
}, nil
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ func (c *Commands) AddSMSConfigTwilio(ctx context.Context, instanceID string, co
|
||||
|
||||
var token *crypto.CryptoValue
|
||||
if config.Token != "" {
|
||||
token, err = crypto.Encrypt([]byte(config.Token), c.smsCrypto)
|
||||
token, err = crypto.Encrypt([]byte(config.Token), c.smsEncryption)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
@ -91,7 +91,7 @@ func (c *Commands) ChangeSMSConfigTwilioToken(ctx context.Context, instanceID, i
|
||||
return nil, caos_errs.ThrowNotFound(nil, "COMMAND-fj9wf", "Errors.SMSConfig.NotFound")
|
||||
}
|
||||
iamAgg := InstanceAggregateFromWriteModel(&smsConfigWriteModel.WriteModel)
|
||||
newtoken, err := crypto.Encrypt([]byte(token), c.smsCrypto)
|
||||
newtoken, err := crypto.Encrypt([]byte(token), c.smsEncryption)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4,6 +4,9 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/caos/zitadel/internal/crypto"
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
@ -13,8 +16,6 @@ import (
|
||||
id_mock "github.com/caos/zitadel/internal/id/mock"
|
||||
"github.com/caos/zitadel/internal/notification/channels/twilio"
|
||||
"github.com/caos/zitadel/internal/repository/instance"
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCommandSide_AddSMSConfigTwilio(t *testing.T) {
|
||||
@ -85,9 +86,9 @@ func TestCommandSide_AddSMSConfigTwilio(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
r := &Commands{
|
||||
eventstore: tt.fields.eventstore,
|
||||
idGenerator: tt.fields.idGenerator,
|
||||
smsCrypto: tt.fields.alg,
|
||||
eventstore: tt.fields.eventstore,
|
||||
idGenerator: tt.fields.idGenerator,
|
||||
smsEncryption: tt.fields.alg,
|
||||
}
|
||||
_, got, err := r.AddSMSConfigTwilio(tt.args.ctx, tt.args.instanceID, tt.args.sms)
|
||||
if tt.res.err == nil {
|
||||
|
@ -20,7 +20,7 @@ func (c *Commands) AddSMTPConfig(ctx context.Context, instanceID string, config
|
||||
}
|
||||
var smtpPassword *crypto.CryptoValue
|
||||
if config.SMTP.Password != "" {
|
||||
smtpPassword, err = crypto.Encrypt([]byte(config.SMTP.Password), c.smtpPasswordCrypto)
|
||||
smtpPassword, err = crypto.Encrypt([]byte(config.SMTP.Password), c.smtpEncryption)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -90,7 +90,7 @@ func (c *Commands) ChangeSMTPConfigPassword(ctx context.Context, instanceID, pas
|
||||
return nil, caos_errs.ThrowNotFound(nil, "COMMAND-3n9ls", "Errors.SMTPConfig.NotFound")
|
||||
}
|
||||
iamAgg := InstanceAggregateFromWriteModel(&smtpConfigWriteModel.WriteModel)
|
||||
newPW, err := crypto.Encrypt([]byte(password), c.smtpPasswordCrypto)
|
||||
newPW, err := crypto.Encrypt([]byte(password), c.smtpEncryption)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4,15 +4,15 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/caos/zitadel/internal/crypto"
|
||||
"github.com/caos/zitadel/internal/notification/channels/smtp"
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/caos/zitadel/internal/crypto"
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore"
|
||||
"github.com/caos/zitadel/internal/eventstore/repository"
|
||||
"github.com/caos/zitadel/internal/notification/channels/smtp"
|
||||
"github.com/caos/zitadel/internal/repository/instance"
|
||||
)
|
||||
|
||||
@ -120,8 +120,8 @@ func TestCommandSide_AddSMTPConfig(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
r := &Commands{
|
||||
eventstore: tt.fields.eventstore,
|
||||
smtpPasswordCrypto: tt.fields.alg,
|
||||
eventstore: tt.fields.eventstore,
|
||||
smtpEncryption: tt.fields.alg,
|
||||
}
|
||||
got, err := r.AddSMTPConfig(tt.args.ctx, tt.args.instanceID, tt.args.smtp)
|
||||
if tt.res.err == nil {
|
||||
@ -372,8 +372,8 @@ func TestCommandSide_ChangeSMTPConfigPassword(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
r := &Commands{
|
||||
eventstore: tt.fields.eventstore,
|
||||
smtpPasswordCrypto: tt.fields.alg,
|
||||
eventstore: tt.fields.eventstore,
|
||||
smtpEncryption: tt.fields.alg,
|
||||
}
|
||||
got, err := r.ChangeSMTPConfigPassword(tt.args.ctx, tt.args.instanceID, tt.args.password)
|
||||
if tt.res.err == nil {
|
||||
|
@ -51,7 +51,7 @@ func Test_customDomainPolicy(t *testing.T) {
|
||||
return []eventstore.Event{
|
||||
org.NewDomainPolicyAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("id", "ro").Aggregate,
|
||||
&org.NewAggregate("id").Aggregate,
|
||||
true,
|
||||
true,
|
||||
),
|
||||
@ -61,7 +61,7 @@ func Test_customDomainPolicy(t *testing.T) {
|
||||
want: &PolicyDomainWriteModel{
|
||||
WriteModel: eventstore.WriteModel{
|
||||
AggregateID: "id",
|
||||
ResourceOwner: "ro",
|
||||
ResourceOwner: "id",
|
||||
Events: []eventstore.Event{},
|
||||
},
|
||||
UserLoginMustBeDomain: true,
|
||||
@ -183,7 +183,7 @@ func Test_DomainPolicy(t *testing.T) {
|
||||
return []eventstore.Event{
|
||||
org.NewDomainPolicyAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("id", "ro").Aggregate,
|
||||
&org.NewAggregate("id").Aggregate,
|
||||
true,
|
||||
true,
|
||||
),
|
||||
@ -193,7 +193,7 @@ func Test_DomainPolicy(t *testing.T) {
|
||||
want: &PolicyDomainWriteModel{
|
||||
WriteModel: eventstore.WriteModel{
|
||||
AggregateID: "id",
|
||||
ResourceOwner: "ro",
|
||||
ResourceOwner: "id",
|
||||
Events: []eventstore.Event{},
|
||||
},
|
||||
UserLoginMustBeDomain: true,
|
||||
|
@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"github.com/caos/zitadel/internal/command/preparation"
|
||||
"github.com/caos/zitadel/internal/crypto"
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
@ -11,7 +13,6 @@ import (
|
||||
"github.com/caos/zitadel/internal/eventstore"
|
||||
"github.com/caos/zitadel/internal/eventstore/v1/models"
|
||||
"github.com/caos/zitadel/internal/repository/user"
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
func (c *Commands) getHuman(ctx context.Context, userID, resourceowner string) (*domain.Human, error) {
|
||||
@ -54,24 +55,20 @@ type AddHuman struct {
|
||||
}
|
||||
|
||||
func (c *Commands) AddHuman(ctx context.Context, resourceOwner string, human *AddHuman) (*domain.HumanDetails, error) {
|
||||
return c.v2.AddHuman(ctx, resourceOwner, human)
|
||||
}
|
||||
|
||||
func (c *commandNew) AddHuman(ctx context.Context, resourceOwner string, human *AddHuman) (*domain.HumanDetails, error) {
|
||||
if resourceOwner == "" {
|
||||
return nil, errors.ThrowInvalidArgument(nil, "COMMA-5Ky74", "Errors.Internal")
|
||||
}
|
||||
userID, err := c.id.Next()
|
||||
userID, err := c.idGenerator.Next()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
agg := user.NewAggregate(userID, resourceOwner)
|
||||
cmds, err := preparation.PrepareCommands(ctx, c.es.Filter, addHumanCommand(agg, human, c.userPasswordAlg, c.phoneAlg, c.emailAlg, c.initCodeAlg))
|
||||
cmds, err := preparation.PrepareCommands(ctx, c.eventstore.Filter, AddHumanCommand(agg, human, c.userPasswordAlg, c.smsEncryption, c.smtpEncryption, c.userEncryption))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
events, err := c.es.Push(ctx, cmds...)
|
||||
events, err := c.eventstore.Push(ctx, cmds...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -92,7 +89,7 @@ type humanCreationCommand interface {
|
||||
AddPasswordData(secret *crypto.CryptoValue, changeRequired bool)
|
||||
}
|
||||
|
||||
func addHumanCommand(a *user.Aggregate, human *AddHuman, passwordAlg crypto.HashAlgorithm, phoneAlg, emailAlg, initCodeAlg crypto.EncryptionAlgorithm) preparation.Validation {
|
||||
func AddHumanCommand(a *user.Aggregate, human *AddHuman, passwordAlg crypto.HashAlgorithm, phoneAlg, emailAlg, initCodeAlg crypto.EncryptionAlgorithm) preparation.Validation {
|
||||
return func() (_ preparation.CreateCommands, err error) {
|
||||
if !human.Email.Valid() {
|
||||
return nil, errors.ThrowInvalidArgument(nil, "USER-Ec7dM", "Errors.Invalid.Argument")
|
||||
|
@ -177,7 +177,7 @@ func TestCommandSide_AddHumanOTP(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
),
|
||||
|
@ -1150,7 +1150,7 @@ func TestCommandSide_CheckPassword(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
@ -1185,7 +1185,7 @@ func TestCommandSide_CheckPassword(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
@ -1221,7 +1221,7 @@ func TestCommandSide_CheckPassword(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
@ -1273,7 +1273,7 @@ func TestCommandSide_CheckPassword(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
@ -1359,7 +1359,7 @@ func TestCommandSide_CheckPassword(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
@ -1452,7 +1452,7 @@ func TestCommandSide_CheckPassword(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
|
@ -688,13 +688,13 @@ func TestCommandSide_AddHuman(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
r := &commandNew{
|
||||
es: tt.fields.eventstore,
|
||||
r := &Commands{
|
||||
eventstore: tt.fields.eventstore,
|
||||
userPasswordAlg: tt.fields.userPasswordAlg,
|
||||
initCodeAlg: tt.fields.initCodeAlg,
|
||||
emailAlg: tt.fields.emailCodeAlg,
|
||||
id: tt.fields.idGenerator,
|
||||
phoneAlg: tt.fields.phoneAlg,
|
||||
userEncryption: tt.fields.initCodeAlg,
|
||||
smtpEncryption: tt.fields.emailCodeAlg,
|
||||
idGenerator: tt.fields.idGenerator,
|
||||
smsEncryption: tt.fields.phoneAlg,
|
||||
}
|
||||
got, err := r.AddHuman(tt.args.ctx, tt.args.orgID, tt.args.human)
|
||||
if tt.res.err == nil {
|
||||
@ -1568,7 +1568,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
),
|
||||
@ -1607,7 +1607,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
),
|
||||
@ -1616,7 +1616,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordComplexityPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
1,
|
||||
false,
|
||||
false,
|
||||
@ -1654,7 +1654,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
),
|
||||
@ -1663,7 +1663,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordComplexityPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
1,
|
||||
false,
|
||||
false,
|
||||
@ -1675,7 +1675,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
@ -1717,7 +1717,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
),
|
||||
@ -1726,7 +1726,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordComplexityPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
1,
|
||||
false,
|
||||
false,
|
||||
@ -1738,7 +1738,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
@ -1780,7 +1780,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
false,
|
||||
true,
|
||||
),
|
||||
@ -1789,7 +1789,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordComplexityPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
1,
|
||||
false,
|
||||
false,
|
||||
@ -1801,7 +1801,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
@ -1819,13 +1819,13 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"test.ch",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"test.ch",
|
||||
),
|
||||
),
|
||||
@ -1860,7 +1860,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
false,
|
||||
true,
|
||||
),
|
||||
@ -1869,7 +1869,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordComplexityPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
1,
|
||||
false,
|
||||
false,
|
||||
@ -1881,7 +1881,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
@ -1899,32 +1899,32 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"test.ch",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"test.ch",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org2", "org2").Aggregate,
|
||||
&org.NewAggregate("org2").Aggregate,
|
||||
"test.ch",
|
||||
true,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"test.ch",
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewDomainVerifiedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"test.ch",
|
||||
),
|
||||
),
|
||||
@ -1998,7 +1998,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
),
|
||||
@ -2007,7 +2007,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordComplexityPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
1,
|
||||
false,
|
||||
false,
|
||||
@ -2019,7 +2019,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
@ -2113,7 +2113,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordComplexityPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
1,
|
||||
false,
|
||||
false,
|
||||
@ -2125,7 +2125,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
@ -2204,7 +2204,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
),
|
||||
@ -2213,7 +2213,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordComplexityPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
1,
|
||||
false,
|
||||
false,
|
||||
@ -2225,7 +2225,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
@ -2326,7 +2326,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewDomainPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
true,
|
||||
true,
|
||||
),
|
||||
@ -2335,7 +2335,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewPasswordComplexityPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
1,
|
||||
false,
|
||||
false,
|
||||
@ -2347,7 +2347,7 @@ func TestCommandSide_RegisterHuman(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewLoginPolicyAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
@ -2897,7 +2897,7 @@ func TestAddHumanCommand(t *testing.T) {
|
||||
return []eventstore.Event{
|
||||
org.NewDomainPolicyAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("id", "ro").Aggregate,
|
||||
&org.NewAggregate("id").Aggregate,
|
||||
true,
|
||||
true,
|
||||
),
|
||||
@ -2908,7 +2908,7 @@ func TestAddHumanCommand(t *testing.T) {
|
||||
return []eventstore.Event{
|
||||
org.NewPasswordComplexityPolicyAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("id", "ro").Aggregate,
|
||||
&org.NewAggregate("id").Aggregate,
|
||||
8,
|
||||
true,
|
||||
true,
|
||||
@ -2940,7 +2940,7 @@ func TestAddHumanCommand(t *testing.T) {
|
||||
return []eventstore.Event{
|
||||
org.NewDomainPolicyAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("id", "ro").Aggregate,
|
||||
&org.NewAggregate("id").Aggregate,
|
||||
true,
|
||||
true,
|
||||
),
|
||||
@ -2951,7 +2951,7 @@ func TestAddHumanCommand(t *testing.T) {
|
||||
return []eventstore.Event{
|
||||
org.NewPasswordComplexityPolicyAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("id", "ro").Aggregate,
|
||||
&org.NewAggregate("id").Aggregate,
|
||||
2,
|
||||
false,
|
||||
false,
|
||||
@ -2984,7 +2984,7 @@ func TestAddHumanCommand(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
AssertValidation(t, addHumanCommand(tt.args.a, tt.args.human, tt.args.passwordAlg, tt.args.phoneAlg, tt.args.emailAlg, tt.args.initCodeAlg), tt.args.filter, tt.want)
|
||||
AssertValidation(t, AddHumanCommand(tt.args.a, tt.args.human, tt.args.passwordAlg, tt.args.phoneAlg, tt.args.emailAlg, tt.args.initCodeAlg), tt.args.filter, tt.want)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ func TestCommandSide_BulkAddUserIDPLinks(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
org.NewIDPConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"name",
|
||||
domain.IDPConfigTypeOIDC,
|
||||
@ -209,7 +209,7 @@ func TestCommandSide_BulkAddUserIDPLinks(t *testing.T) {
|
||||
expectFilter(
|
||||
eventFromEventPusher(
|
||||
instance.NewIDPConfigAddedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"config1",
|
||||
"name",
|
||||
domain.IDPConfigTypeOIDC,
|
||||
|
@ -18,8 +18,8 @@ func (c *Commands) removeUserMemberships(ctx context.Context, memberships []*que
|
||||
removeEvent := c.removeInstanceMember(ctx, &iamAgg.Aggregate, membership.UserID, true)
|
||||
events = append(events, removeEvent)
|
||||
} else if membership.Org != nil {
|
||||
iamAgg := org.NewAggregate(membership.Org.OrgID, membership.ResourceOwner)
|
||||
removeEvent := c.removeOrgMember(ctx, &iamAgg.Aggregate, membership.UserID, true)
|
||||
orgAgg := org.NewAggregate(membership.Org.OrgID)
|
||||
removeEvent := c.removeOrgMember(ctx, &orgAgg.Aggregate, membership.UserID, true)
|
||||
events = append(events, removeEvent)
|
||||
} else if membership.Project != nil {
|
||||
projectAgg := project.NewAggregate(membership.Project.ProjectID, membership.ResourceOwner)
|
||||
|
@ -51,7 +51,7 @@ func Test_customPasswordComplexityPolicy(t *testing.T) {
|
||||
return []eventstore.Event{
|
||||
org.NewPasswordComplexityPolicyAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("id", "ro").Aggregate,
|
||||
&org.NewAggregate("id").Aggregate,
|
||||
8,
|
||||
true,
|
||||
true,
|
||||
@ -64,7 +64,7 @@ func Test_customPasswordComplexityPolicy(t *testing.T) {
|
||||
want: &PasswordComplexityPolicyWriteModel{
|
||||
WriteModel: eventstore.WriteModel{
|
||||
AggregateID: "id",
|
||||
ResourceOwner: "ro",
|
||||
ResourceOwner: "id",
|
||||
Events: []eventstore.Event{},
|
||||
},
|
||||
MinLength: 8,
|
||||
@ -195,7 +195,7 @@ func Test_passwordComplexityPolicy(t *testing.T) {
|
||||
return []eventstore.Event{
|
||||
org.NewPasswordComplexityPolicyAddedEvent(
|
||||
context.Background(),
|
||||
&org.NewAggregate("id", "ro").Aggregate,
|
||||
&org.NewAggregate("id").Aggregate,
|
||||
8,
|
||||
true,
|
||||
true,
|
||||
@ -208,7 +208,7 @@ func Test_passwordComplexityPolicy(t *testing.T) {
|
||||
want: &PasswordComplexityPolicyWriteModel{
|
||||
WriteModel: eventstore.WriteModel{
|
||||
AggregateID: "id",
|
||||
ResourceOwner: "ro",
|
||||
ResourceOwner: "id",
|
||||
Events: []eventstore.Event{},
|
||||
},
|
||||
MinLength: 8,
|
||||
|
@ -5,11 +5,12 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"github.com/caos/zitadel/internal/repository/member"
|
||||
"github.com/caos/zitadel/internal/repository/org"
|
||||
"github.com/caos/zitadel/internal/repository/project"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"github.com/caos/zitadel/internal/command/preparation"
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
@ -1179,7 +1180,7 @@ func TestCommandSide_RemoveUser(t *testing.T) {
|
||||
),
|
||||
eventFromEventPusher(
|
||||
org.NewMemberCascadeRemovedEvent(context.Background(),
|
||||
&org.NewAggregate("org1", "org1").Aggregate,
|
||||
&org.NewAggregate("org1").Aggregate,
|
||||
"user1",
|
||||
),
|
||||
),
|
||||
|
@ -17,13 +17,13 @@ type Aggregate struct {
|
||||
eventstore.Aggregate
|
||||
}
|
||||
|
||||
func NewAggregate(id, resourceOwner string) *Aggregate {
|
||||
func NewAggregate(id string) *Aggregate {
|
||||
return &Aggregate{
|
||||
Aggregate: eventstore.Aggregate{
|
||||
Type: AggregateType,
|
||||
Version: AggregateVersion,
|
||||
ID: id,
|
||||
ResourceOwner: resourceOwner,
|
||||
ResourceOwner: id,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user