mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-06 09:57:38 +00:00
fix: all enums same style (#262)
* fix: all enums same style * fix: rename process to reduce * add some missing enum renaming Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
parent
c376b92315
commit
3cd3a238c2
@ -2,7 +2,6 @@ package eventstore
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/caos/zitadel/internal/org/repository/view/model"
|
||||
|
||||
admin_model "github.com/caos/zitadel/internal/admin/model"
|
||||
admin_view "github.com/caos/zitadel/internal/admin/repository/eventsourcing/view"
|
||||
@ -10,13 +9,14 @@ import (
|
||||
"github.com/caos/zitadel/internal/eventstore/sdk"
|
||||
org_model "github.com/caos/zitadel/internal/org/model"
|
||||
org_es "github.com/caos/zitadel/internal/org/repository/eventsourcing"
|
||||
"github.com/caos/zitadel/internal/org/repository/view/model"
|
||||
policy_model "github.com/caos/zitadel/internal/policy/model"
|
||||
policy_es "github.com/caos/zitadel/internal/policy/repository/eventsourcing"
|
||||
usr_es "github.com/caos/zitadel/internal/user/repository/eventsourcing"
|
||||
)
|
||||
|
||||
const (
|
||||
DEFAULT_POLICY = "0"
|
||||
orgOwnerRole = "ORG_OWNER"
|
||||
orgOwnerRole = "ORG_OWNER"
|
||||
)
|
||||
|
||||
type OrgRepo struct {
|
||||
@ -31,11 +31,11 @@ type OrgRepo struct {
|
||||
}
|
||||
|
||||
func (repo *OrgRepo) SetUpOrg(ctx context.Context, setUp *admin_model.SetupOrg) (*admin_model.SetupOrg, error) {
|
||||
pwPolicy, err := repo.PolicyEventstore.GetPasswordComplexityPolicy(ctx, DEFAULT_POLICY)
|
||||
pwPolicy, err := repo.PolicyEventstore.GetPasswordComplexityPolicy(ctx, policy_model.DefaultPolicy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
orgPolicy, err := repo.OrgEventstore.GetOrgIamPolicy(ctx, DEFAULT_POLICY)
|
||||
orgPolicy, err := repo.OrgEventstore.GetOrgIamPolicy(ctx, policy_model.DefaultPolicy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ func (o *Org) EventQuery() (*es_models.SearchQuery, error) {
|
||||
return eventsourcing.OrgQuery(sequence), nil
|
||||
}
|
||||
|
||||
func (o *Org) Process(event *es_models.Event) error {
|
||||
func (o *Org) Reduce(event *es_models.Event) error {
|
||||
org := new(org_model.OrgView)
|
||||
|
||||
switch event.Type {
|
||||
|
@ -45,21 +45,20 @@ type initializer struct {
|
||||
}
|
||||
|
||||
const (
|
||||
OrgOwnerRole = "ORG_OWNER"
|
||||
SETUP_USER = "SETUP"
|
||||
OIDCResponseType_CODE = "CODE"
|
||||
OIDCResponseType_ID_TOKEN = "ID_TOKEN"
|
||||
OIDCResponseType_TOKEN = "TOKEN"
|
||||
OIDCGrantType_AUTHORIZATION_CODE = "AUTHORIZATION_CODE"
|
||||
OIDCGrantType_IMPLICIT = "IMPLICIT"
|
||||
OIDCGrantType_REFRESH_TOKEN = "REFRESH_TOKEN"
|
||||
OIDCApplicationType_NATIVE = "NATIVE"
|
||||
OIDCApplicationType_USER_AGENT = "USER_AGENT"
|
||||
OIDCApplicationType_WEB = "WEB"
|
||||
OIDCAuthMethodType_NONE = "NONE"
|
||||
OIDCAuthMethodType_BASIC = "BASIC"
|
||||
OIDCAuthMethodType_POST = "POST"
|
||||
DEFAULT_POLICY = "0"
|
||||
OrgOwnerRole = "ORG_OWNER"
|
||||
SetupUser = "SETUP"
|
||||
OIDCResponseTypeCode = "CODE"
|
||||
OIDCResponseTypeIDToken = "ID_TOKEN"
|
||||
OIDCResponseTypeToken = "TOKEN"
|
||||
OIDCGrantTypeAuthorizationCode = "AUTHORIZATION_CODE"
|
||||
OIDCGrantTypeImplicit = "IMPLICIT"
|
||||
OIDCGrantTypeRefreshToken = "REFRESH_TOKEN"
|
||||
OIDCApplicationTypeNative = "NATIVE"
|
||||
OIDCApplicationTypeUserAgent = "USER_AGENT"
|
||||
OIDCApplicationTypeWeb = "WEB"
|
||||
OIDCAuthMethodTypeNone = "NONE"
|
||||
OIDCAuthMethodTypeBasic = "BASIC"
|
||||
OIDCAuthMethodTypePost = "POST"
|
||||
)
|
||||
|
||||
func StartSetup(sd systemdefaults.SystemDefaults, repos EventstoreRepos) *Setup {
|
||||
@ -97,7 +96,7 @@ func (s *Setup) Execute(ctx context.Context) error {
|
||||
createdProjects: make(map[string]*proj_model.Project),
|
||||
}
|
||||
|
||||
pwComplexityPolicy, err := s.repos.PolicyEvents.GetPasswordComplexityPolicy(ctx, DEFAULT_POLICY)
|
||||
pwComplexityPolicy, err := s.repos.PolicyEvents.GetPasswordComplexityPolicy(ctx, policy_model.DefaultPolicy)
|
||||
if err != nil {
|
||||
logging.Log("SETUP-9osWF").WithError(err).Error("unable to read complexity policy")
|
||||
return err
|
||||
@ -175,7 +174,7 @@ func (setUp *initializer) orgs(ctx context.Context, orgs []types.Org) error {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
policy, err = setUp.repos.OrgEvents.GetOrgIamPolicy(ctx, DEFAULT_POLICY)
|
||||
policy, err = setUp.repos.OrgEvents.GetOrgIamPolicy(ctx, policy_model.DefaultPolicy)
|
||||
if err != nil {
|
||||
logging.LogWithFields("SETUP-IS8wS", "Org Iam Policy", iamOrg.Name).WithError(err).Error("unable to get default iam org policy")
|
||||
return err
|
||||
@ -380,14 +379,14 @@ func getOIDCResponseTypes(responseTypes []string) []proj_model.OIDCResponseType
|
||||
|
||||
func getOIDCResponseType(responseType string) proj_model.OIDCResponseType {
|
||||
switch responseType {
|
||||
case OIDCResponseType_CODE:
|
||||
return proj_model.OIDCRESPONSETYPE_CODE
|
||||
case OIDCResponseType_ID_TOKEN:
|
||||
return proj_model.OIDCRESPONSETYPE_ID_TOKEN
|
||||
case OIDCResponseType_TOKEN:
|
||||
return proj_model.OIDCRESPONSETYPE_TOKEN
|
||||
case OIDCResponseTypeCode:
|
||||
return proj_model.OIDCResponseTypeCode
|
||||
case OIDCResponseTypeIDToken:
|
||||
return proj_model.OIDCResponseTypeIDToken
|
||||
case OIDCResponseTypeToken:
|
||||
return proj_model.OIDCResponseTypeToken
|
||||
}
|
||||
return proj_model.OIDCRESPONSETYPE_CODE
|
||||
return proj_model.OIDCResponseTypeCode
|
||||
}
|
||||
|
||||
func getOIDCGrantTypes(grantTypes []string) []proj_model.OIDCGrantType {
|
||||
@ -400,40 +399,40 @@ func getOIDCGrantTypes(grantTypes []string) []proj_model.OIDCGrantType {
|
||||
|
||||
func getOIDCGrantType(grantTypes string) proj_model.OIDCGrantType {
|
||||
switch grantTypes {
|
||||
case OIDCGrantType_AUTHORIZATION_CODE:
|
||||
return proj_model.OIDCGRANTTYPE_AUTHORIZATION_CODE
|
||||
case OIDCGrantType_IMPLICIT:
|
||||
return proj_model.OIDCGRANTTYPE_IMPLICIT
|
||||
case OIDCGrantType_REFRESH_TOKEN:
|
||||
return proj_model.OIDCGRANTTYPE_REFRESH_TOKEN
|
||||
case OIDCGrantTypeAuthorizationCode:
|
||||
return proj_model.OIDCGrantTypeAuthorizationCode
|
||||
case OIDCGrantTypeImplicit:
|
||||
return proj_model.OIDCGrantTypeImplicit
|
||||
case OIDCGrantTypeRefreshToken:
|
||||
return proj_model.OIDCGrantTypeRefreshToken
|
||||
}
|
||||
return proj_model.OIDCGRANTTYPE_AUTHORIZATION_CODE
|
||||
return proj_model.OIDCGrantTypeAuthorizationCode
|
||||
}
|
||||
|
||||
func getOIDCApplicationType(appType string) proj_model.OIDCApplicationType {
|
||||
switch appType {
|
||||
case OIDCApplicationType_NATIVE:
|
||||
return proj_model.OIDCAPPLICATIONTYPE_NATIVE
|
||||
case OIDCApplicationType_USER_AGENT:
|
||||
return proj_model.OIDCAPPLICATIONTYPE_USER_AGENT
|
||||
case OIDCApplicationType_WEB:
|
||||
return proj_model.OIDCAPPLICATIONTYPE_WEB
|
||||
case OIDCApplicationTypeNative:
|
||||
return proj_model.OIDCApplicationTypeNative
|
||||
case OIDCApplicationTypeUserAgent:
|
||||
return proj_model.OIDCApplicationTypeUserAgent
|
||||
case OIDCApplicationTypeWeb:
|
||||
return proj_model.OIDCApplicationTypeWeb
|
||||
}
|
||||
return proj_model.OIDCAPPLICATIONTYPE_WEB
|
||||
return proj_model.OIDCApplicationTypeWeb
|
||||
}
|
||||
|
||||
func getOIDCAuthMethod(authMethod string) proj_model.OIDCAuthMethodType {
|
||||
switch authMethod {
|
||||
case OIDCAuthMethodType_NONE:
|
||||
return proj_model.OIDCAUTHMETHODTYPE_NONE
|
||||
case OIDCAuthMethodType_BASIC:
|
||||
return proj_model.OIDCAUTHMETHODTYPE_BASIC
|
||||
case OIDCAuthMethodType_POST:
|
||||
return proj_model.OIDCAUTHMETHODTYPE_POST
|
||||
case OIDCAuthMethodTypeNone:
|
||||
return proj_model.OIDCAuthMethodTypeNone
|
||||
case OIDCAuthMethodTypeBasic:
|
||||
return proj_model.OIDCAuthMethodTypeBasic
|
||||
case OIDCAuthMethodTypePost:
|
||||
return proj_model.OIDCAuthMethodTypePost
|
||||
}
|
||||
return proj_model.OIDCAUTHMETHODTYPE_NONE
|
||||
return proj_model.OIDCAuthMethodTypeNone
|
||||
}
|
||||
|
||||
func setSetUpContextData(ctx context.Context, orgID string) context.Context {
|
||||
return auth.SetCtxData(ctx, auth.CtxData{UserID: SETUP_USER, OrgID: orgID})
|
||||
return auth.SetCtxData(ctx, auth.CtxData{UserID: SetupUser, OrgID: orgID})
|
||||
}
|
||||
|
@ -350,17 +350,17 @@ func activeUserByID(ctx context.Context, userViewProvider userViewProvider, user
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if user.State == user_model.USERSTATE_LOCKED || user.State == user_model.USERSTATE_SUSPEND {
|
||||
if user.State == user_model.UserStateLocked || user.State == user_model.UserStateSuspend {
|
||||
return nil, errors.ThrowPreconditionFailed(nil, "EVENT-FJ262", "Errors.User.Locked")
|
||||
}
|
||||
if !(user.State == user_model.USERSTATE_ACTIVE || user.State == user_model.USERSTATE_INITIAL) {
|
||||
if !(user.State == user_model.UserStateActive || user.State == user_model.UserStateInitial) {
|
||||
return nil, errors.ThrowPreconditionFailed(nil, "EVENT-FJ262", "Errors.User.NotActive")
|
||||
}
|
||||
org, err := orgViewProvider.OrgByID(user.ResourceOwner)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if org.State != int32(org_model.ORGSTATE_ACTIVE) {
|
||||
if org.State != int32(org_model.OrgStateActive) {
|
||||
return nil, errors.ThrowPreconditionFailed(nil, "EVENT-Zws3s", "Errors.User.NotActive")
|
||||
}
|
||||
return user, nil
|
||||
|
@ -113,7 +113,7 @@ func (m *mockViewUser) UserByID(string) (*user_view_model.UserView, error) {
|
||||
OTPState: m.OTPState,
|
||||
MfaMaxSetUp: m.MfaMaxSetUp,
|
||||
MfaInitSkipped: m.MfaInitSkipped,
|
||||
State: int32(user_model.USERSTATE_ACTIVE),
|
||||
State: int32(user_model.UserStateActive),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -242,7 +242,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
Type: user_es_model.UserDeactivated,
|
||||
},
|
||||
},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.ORGSTATE_ACTIVE},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.OrgStateActive},
|
||||
},
|
||||
args{&model.AuthRequest{UserID: "UserID"}, false},
|
||||
nil,
|
||||
@ -264,7 +264,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
fields{
|
||||
userViewProvider: &mockViewUser{},
|
||||
userEventProvider: &mockEventUser{},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.ORGSTATE_INACTIVE},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.OrgStateInactive},
|
||||
},
|
||||
args{&model.AuthRequest{UserID: "UserID"}, false},
|
||||
nil,
|
||||
@ -278,7 +278,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
PasswordSet: true,
|
||||
},
|
||||
userEventProvider: &mockEventUser{},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.ORGSTATE_ACTIVE},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.OrgStateActive},
|
||||
},
|
||||
args{&model.AuthRequest{UserID: "UserID"}, false},
|
||||
[]model.NextStep{&model.PasswordStep{}},
|
||||
@ -290,7 +290,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
userSessionViewProvider: &mockViewErrUserSession{},
|
||||
userViewProvider: &mockViewUser{},
|
||||
userEventProvider: &mockEventUser{},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.ORGSTATE_ACTIVE},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.OrgStateActive},
|
||||
},
|
||||
args{&model.AuthRequest{UserID: "UserID"}, false},
|
||||
nil,
|
||||
@ -305,7 +305,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
PasswordSet: true,
|
||||
},
|
||||
userEventProvider: &mockEventUser{},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.ORGSTATE_ACTIVE},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.OrgStateActive},
|
||||
},
|
||||
args{&model.AuthRequest{UserID: "UserID"}, false},
|
||||
[]model.NextStep{&model.InitUserStep{
|
||||
@ -319,7 +319,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
userSessionViewProvider: &mockViewUserSession{},
|
||||
userViewProvider: &mockViewUser{},
|
||||
userEventProvider: &mockEventUser{},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.ORGSTATE_ACTIVE},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.OrgStateActive},
|
||||
},
|
||||
args{&model.AuthRequest{UserID: "UserID"}, false},
|
||||
[]model.NextStep{&model.InitPasswordStep{}},
|
||||
@ -333,7 +333,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
PasswordSet: true,
|
||||
},
|
||||
userEventProvider: &mockEventUser{},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.ORGSTATE_ACTIVE},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.OrgStateActive},
|
||||
PasswordCheckLifeTime: 10 * 24 * time.Hour,
|
||||
},
|
||||
args{&model.AuthRequest{UserID: "UserID"}, false},
|
||||
@ -348,11 +348,11 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
},
|
||||
userViewProvider: &mockViewUser{
|
||||
PasswordSet: true,
|
||||
OTPState: int32(user_model.MFASTATE_READY),
|
||||
OTPState: int32(user_model.MfaStateReady),
|
||||
MfaMaxSetUp: int32(model.MfaLevelSoftware),
|
||||
},
|
||||
userEventProvider: &mockEventUser{},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.ORGSTATE_ACTIVE},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.OrgStateActive},
|
||||
PasswordCheckLifeTime: 10 * 24 * time.Hour,
|
||||
MfaSoftwareCheckLifeTime: 18 * time.Hour,
|
||||
},
|
||||
@ -376,7 +376,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
MfaMaxSetUp: int32(model.MfaLevelSoftware),
|
||||
},
|
||||
userEventProvider: &mockEventUser{},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.ORGSTATE_ACTIVE},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.OrgStateActive},
|
||||
PasswordCheckLifeTime: 10 * 24 * time.Hour,
|
||||
MfaSoftwareCheckLifeTime: 18 * time.Hour,
|
||||
},
|
||||
@ -396,7 +396,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
MfaMaxSetUp: int32(model.MfaLevelSoftware),
|
||||
},
|
||||
userEventProvider: &mockEventUser{},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.ORGSTATE_ACTIVE},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.OrgStateActive},
|
||||
PasswordCheckLifeTime: 10 * 24 * time.Hour,
|
||||
MfaSoftwareCheckLifeTime: 18 * time.Hour,
|
||||
},
|
||||
@ -417,7 +417,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
MfaMaxSetUp: int32(model.MfaLevelSoftware),
|
||||
},
|
||||
userEventProvider: &mockEventUser{},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.ORGSTATE_ACTIVE},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.OrgStateActive},
|
||||
PasswordCheckLifeTime: 10 * 24 * time.Hour,
|
||||
MfaSoftwareCheckLifeTime: 18 * time.Hour,
|
||||
},
|
||||
@ -438,7 +438,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
MfaMaxSetUp: int32(model.MfaLevelSoftware),
|
||||
},
|
||||
userEventProvider: &mockEventUser{},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.ORGSTATE_ACTIVE},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.OrgStateActive},
|
||||
PasswordCheckLifeTime: 10 * 24 * time.Hour,
|
||||
MfaSoftwareCheckLifeTime: 18 * time.Hour,
|
||||
},
|
||||
@ -459,7 +459,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
MfaMaxSetUp: int32(model.MfaLevelSoftware),
|
||||
},
|
||||
userEventProvider: &mockEventUser{},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.ORGSTATE_ACTIVE},
|
||||
orgViewProvider: &mockViewOrg{State: org_model.OrgStateActive},
|
||||
PasswordCheckLifeTime: 10 * 24 * time.Hour,
|
||||
MfaSoftwareCheckLifeTime: 18 * time.Hour,
|
||||
},
|
||||
@ -517,7 +517,7 @@ func TestAuthRequestRepo_mfaChecked(t *testing.T) {
|
||||
// args{
|
||||
// request: &model.AuthRequest{PossibleLOAs: []model.LevelOfAssurance{}},
|
||||
// user: &user_model.UserView{
|
||||
// OTPState: user_model.MFASTATE_READY,
|
||||
// OTPState: user_model.MfaStateReady,
|
||||
// },
|
||||
// },
|
||||
// false,
|
||||
@ -564,7 +564,7 @@ func TestAuthRequestRepo_mfaChecked(t *testing.T) {
|
||||
request: &model.AuthRequest{},
|
||||
user: &user_model.UserView{
|
||||
MfaMaxSetUp: model.MfaLevelSoftware,
|
||||
OTPState: user_model.MFASTATE_READY,
|
||||
OTPState: user_model.MfaStateReady,
|
||||
},
|
||||
userSession: &user_model.UserSessionView{MfaSoftwareVerification: time.Now().UTC().Add(-5 * time.Hour)},
|
||||
},
|
||||
@ -580,7 +580,7 @@ func TestAuthRequestRepo_mfaChecked(t *testing.T) {
|
||||
request: &model.AuthRequest{},
|
||||
user: &user_model.UserView{
|
||||
MfaMaxSetUp: model.MfaLevelSoftware,
|
||||
OTPState: user_model.MFASTATE_READY,
|
||||
OTPState: user_model.MfaStateReady,
|
||||
},
|
||||
userSession: &user_model.UserSessionView{},
|
||||
},
|
||||
@ -851,7 +851,7 @@ func Test_userByID(t *testing.T) {
|
||||
},
|
||||
&user_model.UserView{
|
||||
PasswordChangeRequired: true,
|
||||
State: user_model.USERSTATE_ACTIVE,
|
||||
State: user_model.UserStateActive,
|
||||
},
|
||||
nil,
|
||||
},
|
||||
@ -872,7 +872,7 @@ func Test_userByID(t *testing.T) {
|
||||
},
|
||||
&user_model.UserView{
|
||||
PasswordChangeRequired: true,
|
||||
State: user_model.USERSTATE_ACTIVE,
|
||||
State: user_model.UserStateActive,
|
||||
},
|
||||
nil,
|
||||
},
|
||||
@ -897,7 +897,7 @@ func Test_userByID(t *testing.T) {
|
||||
&user_model.UserView{
|
||||
PasswordChangeRequired: false,
|
||||
ChangeDate: time.Now().UTC().Round(1 * time.Second),
|
||||
State: user_model.USERSTATE_ACTIVE,
|
||||
State: user_model.UserStateActive,
|
||||
PasswordChanged: time.Now().UTC().Round(1 * time.Second),
|
||||
},
|
||||
nil,
|
||||
|
@ -212,7 +212,7 @@ func (repo *UserRepo) RequestPasswordReset(ctx context.Context, loginname string
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return repo.UserEvents.RequestSetPassword(ctx, user.ID, model.NOTIFICATIONTYPE_EMAIL)
|
||||
return repo.UserEvents.RequestSetPassword(ctx, user.ID, model.NotificationTypeEmail)
|
||||
}
|
||||
|
||||
func (repo *UserRepo) SetPassword(ctx context.Context, userID, code, password string) error {
|
||||
|
@ -23,7 +23,7 @@ type UserGrantRepo struct {
|
||||
|
||||
func (repo *UserGrantRepo) SearchMyUserGrants(ctx context.Context, request *grant_model.UserGrantSearchRequest) (*grant_model.UserGrantSearchResponse, error) {
|
||||
request.EnsureLimit(repo.SearchLimit)
|
||||
request.Queries = append(request.Queries, &grant_model.UserGrantSearchQuery{Key: grant_model.USERGRANTSEARCHKEY_USER_ID, Method: global_model.SEARCHMETHOD_EQUALS, Value: auth.GetCtxData(ctx).UserID})
|
||||
request.Queries = append(request.Queries, &grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyUserID, Method: global_model.SearchMethodEquals, Value: auth.GetCtxData(ctx).UserID})
|
||||
grants, count, err := repo.View.SearchUserGrants(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -55,7 +55,7 @@ func (repo *UserGrantRepo) SearchMyProjectOrgs(ctx context.Context, request *gra
|
||||
return repo.SearchAdminOrgs(request)
|
||||
}
|
||||
}
|
||||
request.Queries = append(request.Queries, &grant_model.UserGrantSearchQuery{Key: grant_model.USERGRANTSEARCHKEY_PROJECT_ID, Method: global_model.SEARCHMETHOD_EQUALS, Value: ctxData.ProjectID})
|
||||
request.Queries = append(request.Queries, &grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyProjectID, Method: global_model.SearchMethodEquals, Value: ctxData.ProjectID})
|
||||
|
||||
grants, err := repo.SearchMyUserGrants(ctx, request)
|
||||
if err != nil {
|
||||
@ -98,8 +98,8 @@ func (repo *UserGrantRepo) SearchAdminOrgs(request *grant_model.UserGrantSearchR
|
||||
searchRequest := &org_model.OrgSearchRequest{}
|
||||
if len(request.Queries) > 0 {
|
||||
for _, q := range request.Queries {
|
||||
if q.Key == grant_model.USERGRANTSEARCHKEY_ORG_NAME {
|
||||
searchRequest.Queries = append(searchRequest.Queries, &org_model.OrgSearchQuery{Key: org_model.ORGSEARCHKEY_ORG_NAME, Method: q.Method, Value: q.Value})
|
||||
if q.Key == grant_model.UserGrantSearchKeyOrgName {
|
||||
searchRequest.Queries = append(searchRequest.Queries, &org_model.OrgSearchQuery{Key: org_model.OrgSearchKeyOrgName, Method: q.Method, Value: q.Value})
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -113,7 +113,7 @@ func (repo *UserGrantRepo) SearchAdminOrgs(request *grant_model.UserGrantSearchR
|
||||
func (repo *UserGrantRepo) IsIamAdmin(ctx context.Context) (bool, error) {
|
||||
grantSearch := &grant_model.UserGrantSearchRequest{
|
||||
Queries: []*grant_model.UserGrantSearchQuery{
|
||||
&grant_model.UserGrantSearchQuery{Key: grant_model.USERGRANTSEARCHKEY_RESOURCEOWNER, Method: global_model.SEARCHMETHOD_EQUALS, Value: repo.IamID},
|
||||
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyResourceOwner, Method: global_model.SearchMethodEquals, Value: repo.IamID},
|
||||
}}
|
||||
result, err := repo.SearchMyUserGrants(ctx, grantSearch)
|
||||
if err != nil {
|
||||
|
@ -34,7 +34,7 @@ func (p *Application) EventQuery() (*models.SearchQuery, error) {
|
||||
return eventsourcing.ProjectQuery(sequence), nil
|
||||
}
|
||||
|
||||
func (p *Application) Process(event *models.Event) (err error) {
|
||||
func (p *Application) Reduce(event *models.Event) (err error) {
|
||||
app := new(view_model.ApplicationView)
|
||||
switch event.Type {
|
||||
case es_model.ApplicationAdded:
|
||||
|
@ -35,7 +35,7 @@ func (k *Key) EventQuery() (*models.SearchQuery, error) {
|
||||
return eventsourcing.KeyPairQuery(sequence), nil
|
||||
}
|
||||
|
||||
func (k *Key) Process(event *models.Event) error {
|
||||
func (k *Key) Reduce(event *models.Event) error {
|
||||
switch event.Type {
|
||||
case es_model.KeyPairAdded:
|
||||
privateKey, publicKey, err := view_model.KeysFromPairEvent(event)
|
||||
|
@ -32,7 +32,7 @@ func (o *Org) EventQuery() (*es_models.SearchQuery, error) {
|
||||
return eventsourcing.OrgQuery(sequence), nil
|
||||
}
|
||||
|
||||
func (o *Org) Process(event *es_models.Event) error {
|
||||
func (o *Org) Reduce(event *es_models.Event) error {
|
||||
org := new(org_model.OrgView)
|
||||
|
||||
switch event.Type {
|
||||
|
@ -44,7 +44,7 @@ func (u *Token) EventQuery() (*models.SearchQuery, error) {
|
||||
LatestSequenceFilter(sequence), nil
|
||||
}
|
||||
|
||||
func (u *Token) Process(event *models.Event) (err error) {
|
||||
func (u *Token) Reduce(event *models.Event) (err error) {
|
||||
switch event.Type {
|
||||
case user_es_model.SignedOut:
|
||||
id, err := agentIDFromSession(event)
|
||||
|
@ -43,7 +43,7 @@ func (p *User) EventQuery() (*models.SearchQuery, error) {
|
||||
LatestSequenceFilter(sequence), nil
|
||||
}
|
||||
|
||||
func (u *User) Process(event *models.Event) (err error) {
|
||||
func (u *User) Reduce(event *models.Event) (err error) {
|
||||
switch event.AggregateType {
|
||||
case es_model.UserAggregate:
|
||||
return u.ProcessUser(event)
|
||||
|
@ -63,7 +63,7 @@ func (u *UserGrant) EventQuery() (*models.SearchQuery, error) {
|
||||
LatestSequenceFilter(sequence), nil
|
||||
}
|
||||
|
||||
func (u *UserGrant) Process(event *models.Event) (err error) {
|
||||
func (u *UserGrant) Reduce(event *models.Event) (err error) {
|
||||
switch event.AggregateType {
|
||||
case grant_es_model.UserGrantAggregate:
|
||||
err = u.processUserGrant(event)
|
||||
|
@ -39,7 +39,7 @@ func (u *UserSession) EventQuery() (*models.SearchQuery, error) {
|
||||
return eventsourcing.UserQuery(sequence), nil
|
||||
}
|
||||
|
||||
func (u *UserSession) Process(event *models.Event) (err error) {
|
||||
func (u *UserSession) Reduce(event *models.Event) (err error) {
|
||||
var session *view_model.UserSessionView
|
||||
switch event.Type {
|
||||
case es_model.UserPasswordCheckSucceeded,
|
||||
|
@ -60,8 +60,8 @@ func (v *View) ApplicationByClientID(_ context.Context, clientID string) (*model
|
||||
Limit: 1,
|
||||
Queries: []*proj_model.ApplicationSearchQuery{
|
||||
{
|
||||
Key: proj_model.APPLICATIONSEARCHKEY_OIDC_CLIENT_ID,
|
||||
Method: global_model.SEARCHMETHOD_EQUALS,
|
||||
Key: proj_model.AppSearchKeyOIDCClientID,
|
||||
Method: global_model.SearchMethodEquals,
|
||||
Value: clientID,
|
||||
},
|
||||
},
|
||||
@ -84,8 +84,8 @@ func (v *View) AppIDsFromProjectByClientID(ctx context.Context, clientID string)
|
||||
req := &proj_model.ApplicationSearchRequest{
|
||||
Queries: []*proj_model.ApplicationSearchQuery{
|
||||
{
|
||||
Key: proj_model.APPLICATIONSEARCHKEY_PROJECT_ID,
|
||||
Method: global_model.SEARCHMETHOD_EQUALS,
|
||||
Key: proj_model.AppSearchKeyProjectID,
|
||||
Method: global_model.SearchMethodEquals,
|
||||
Value: app.ProjectID,
|
||||
},
|
||||
},
|
||||
|
@ -32,7 +32,7 @@ func (p *Application) EventQuery() (*models.SearchQuery, error) {
|
||||
return eventsourcing.ProjectQuery(sequence), nil
|
||||
}
|
||||
|
||||
func (p *Application) Process(event *models.Event) (err error) {
|
||||
func (p *Application) Reduce(event *models.Event) (err error) {
|
||||
app := new(view_model.ApplicationView)
|
||||
switch event.Type {
|
||||
case es_model.ApplicationAdded:
|
||||
|
@ -52,7 +52,7 @@ func (u *UserGrant) EventQuery() (*models.SearchQuery, error) {
|
||||
LatestSequenceFilter(sequence), nil
|
||||
}
|
||||
|
||||
func (u *UserGrant) Process(event *models.Event) (err error) {
|
||||
func (u *UserGrant) Reduce(event *models.Event) (err error) {
|
||||
switch event.AggregateType {
|
||||
case proj_es_model.ProjectAggregate:
|
||||
err = u.processProject(event)
|
||||
|
@ -7,6 +7,6 @@ import (
|
||||
type Handler interface {
|
||||
ViewModel() string
|
||||
EventQuery() (*models.SearchQuery, error)
|
||||
Process(*models.Event) error
|
||||
Reduce(*models.Event) error
|
||||
OnError(event *models.Event, err error) error
|
||||
}
|
||||
|
@ -63,18 +63,18 @@ func (mr *MockHandlerMockRecorder) EventQuery() *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EventQuery", reflect.TypeOf((*MockHandler)(nil).EventQuery))
|
||||
}
|
||||
|
||||
// Process mocks base method
|
||||
// Reduce mocks base method
|
||||
func (m *MockHandler) Process(arg0 *models.Event) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Process", arg0)
|
||||
ret := m.ctrl.Call(m, "Reduce", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Process indicates an expected call of Process
|
||||
// Reduce indicates an expected call of Reduce
|
||||
func (mr *MockHandlerMockRecorder) Process(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Process", reflect.TypeOf((*MockHandler)(nil).Process), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Reduce", reflect.TypeOf((*MockHandler)(nil).Process), arg0)
|
||||
}
|
||||
|
||||
// MinimumCycleDuration mocks base method
|
||||
|
@ -95,7 +95,7 @@ func (s *spooledHandler) process(ctx context.Context, events []*models.Event) er
|
||||
logging.Log("SPOOL-FTKwH").WithField("view", s.ViewModel()).Debug("context canceled")
|
||||
return nil
|
||||
default:
|
||||
if err := s.Process(event); err != nil {
|
||||
if err := s.Reduce(event); err != nil {
|
||||
return s.OnError(event, err)
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ func (h *testHandler) ViewModel() string {
|
||||
func (h *testHandler) EventQuery() (*models.SearchQuery, error) {
|
||||
return nil, h.queryError
|
||||
}
|
||||
func (h *testHandler) Process(*models.Event) error {
|
||||
func (h *testHandler) Reduce(*models.Event) error {
|
||||
<-time.After(h.processSleep)
|
||||
return h.processError
|
||||
}
|
||||
|
@ -42,11 +42,11 @@ type KeySearchRequest struct {
|
||||
type KeySearchKey int32
|
||||
|
||||
const (
|
||||
KEYSEARCHKEY_UNSPECIFIED KeySearchKey = iota
|
||||
KEYSEARCHKEY_ID
|
||||
KEYSEARCHKEY_PRIVATE
|
||||
KEYSEARCHKEY_EXPIRY
|
||||
KEYSEARCHKEY_USAGE
|
||||
KeySearchKeyUnspecified KeySearchKey = iota
|
||||
KeySearchKeyID
|
||||
KeySearchKeyPrivate
|
||||
KeySearchKeyExpiry
|
||||
KeySearchKeyUsage
|
||||
)
|
||||
|
||||
type KeySearchQuery struct {
|
||||
|
@ -14,8 +14,8 @@ import (
|
||||
func KeyByIDAndType(db *gorm.DB, table, keyID string, private bool) (*model.KeyView, error) {
|
||||
key := new(model.KeyView)
|
||||
query := view.PrepareGetByQuery(table,
|
||||
model.KeySearchQuery{Key: key_model.KEYSEARCHKEY_ID, Method: global_model.SEARCHMETHOD_EQUALS, Value: keyID},
|
||||
model.KeySearchQuery{Key: key_model.KEYSEARCHKEY_PRIVATE, Method: global_model.SEARCHMETHOD_EQUALS, Value: private},
|
||||
model.KeySearchQuery{Key: key_model.KeySearchKeyID, Method: global_model.SearchMethodEquals, Value: keyID},
|
||||
model.KeySearchQuery{Key: key_model.KeySearchKeyPrivate, Method: global_model.SearchMethodEquals, Value: private},
|
||||
)
|
||||
err := query(db, key)
|
||||
return key, err
|
||||
@ -24,9 +24,9 @@ func KeyByIDAndType(db *gorm.DB, table, keyID string, private bool) (*model.KeyV
|
||||
func GetSigningKey(db *gorm.DB, table string) (*model.KeyView, error) {
|
||||
key := new(model.KeyView)
|
||||
query := view.PrepareGetByQuery(table,
|
||||
model.KeySearchQuery{Key: key_model.KEYSEARCHKEY_PRIVATE, Method: global_model.SEARCHMETHOD_EQUALS, Value: true},
|
||||
model.KeySearchQuery{Key: key_model.KEYSEARCHKEY_USAGE, Method: global_model.SEARCHMETHOD_EQUALS, Value: key_model.KeyUsageSigning},
|
||||
model.KeySearchQuery{Key: key_model.KEYSEARCHKEY_EXPIRY, Method: global_model.SEARCHMETHOD_GREATER_THAN, Value: time.Now().UTC()},
|
||||
model.KeySearchQuery{Key: key_model.KeySearchKeyPrivate, Method: global_model.SearchMethodEquals, Value: true},
|
||||
model.KeySearchQuery{Key: key_model.KeySearchKeyUsage, Method: global_model.SearchMethodEquals, Value: key_model.KeyUsageSigning},
|
||||
model.KeySearchQuery{Key: key_model.KeySearchKeyExpiry, Method: global_model.SearchMethodGreaterThan, Value: time.Now().UTC()},
|
||||
)
|
||||
err := query(db, key)
|
||||
return key, err
|
||||
@ -37,9 +37,9 @@ func GetActivePublicKeys(db *gorm.DB, table string) ([]*model.KeyView, error) {
|
||||
query := view.PrepareSearchQuery(table,
|
||||
model.KeySearchRequest{
|
||||
Queries: []*key_model.KeySearchQuery{
|
||||
{Key: key_model.KEYSEARCHKEY_PRIVATE, Method: global_model.SEARCHMETHOD_EQUALS, Value: false},
|
||||
{Key: key_model.KEYSEARCHKEY_USAGE, Method: global_model.SEARCHMETHOD_EQUALS, Value: key_model.KeyUsageSigning},
|
||||
{Key: key_model.KEYSEARCHKEY_EXPIRY, Method: global_model.SEARCHMETHOD_GREATER_THAN, Value: time.Now().UTC()},
|
||||
{Key: key_model.KeySearchKeyPrivate, Method: global_model.SearchMethodEquals, Value: false},
|
||||
{Key: key_model.KeySearchKeyUsage, Method: global_model.SearchMethodEquals, Value: key_model.KeyUsageSigning},
|
||||
{Key: key_model.KeySearchKeyExpiry, Method: global_model.SearchMethodGreaterThan, Value: time.Now().UTC()},
|
||||
},
|
||||
},
|
||||
)
|
||||
@ -58,13 +58,13 @@ func PutKeys(db *gorm.DB, table string, privateKey, publicKey *model.KeyView) er
|
||||
|
||||
func DeleteKey(db *gorm.DB, table, keyID string, private bool) error {
|
||||
delete := view.PrepareDeleteByKeys(table,
|
||||
view.Key{Key: model.KeySearchKey(key_model.KEYSEARCHKEY_ID), Value: keyID},
|
||||
view.Key{Key: model.KeySearchKey(key_model.KEYSEARCHKEY_PRIVATE), Value: private},
|
||||
view.Key{Key: model.KeySearchKey(key_model.KeySearchKeyID), Value: keyID},
|
||||
view.Key{Key: model.KeySearchKey(key_model.KeySearchKeyPrivate), Value: private},
|
||||
)
|
||||
return delete(db)
|
||||
}
|
||||
|
||||
func DeleteKeyPair(db *gorm.DB, table, keyID string) error {
|
||||
delete := view.PrepareDeleteByKey(table, model.KeySearchKey(key_model.KEYSEARCHKEY_ID), keyID)
|
||||
delete := view.PrepareDeleteByKey(table, model.KeySearchKey(key_model.KeySearchKeyID), keyID)
|
||||
return delete(db)
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ func (req KeySearchRequest) GetOffset() uint64 {
|
||||
}
|
||||
|
||||
func (req KeySearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
if req.SortingColumn == key_model.KEYSEARCHKEY_UNSPECIFIED {
|
||||
if req.SortingColumn == key_model.KeySearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return KeySearchKey(req.SortingColumn)
|
||||
@ -51,13 +51,13 @@ func (req KeySearchQuery) GetValue() interface{} {
|
||||
|
||||
func (key KeySearchKey) ToColumnName() string {
|
||||
switch key_model.KeySearchKey(key) {
|
||||
case key_model.KEYSEARCHKEY_ID:
|
||||
case key_model.KeySearchKeyID:
|
||||
return KeyKeyID
|
||||
case key_model.KEYSEARCHKEY_PRIVATE:
|
||||
case key_model.KeySearchKeyPrivate:
|
||||
return KeyPrivate
|
||||
case key_model.KEYSEARCHKEY_USAGE:
|
||||
case key_model.KeySearchKeyUsage:
|
||||
return KeyUsage
|
||||
case key_model.KEYSEARCHKEY_EXPIRY:
|
||||
case key_model.KeySearchKeyExpiry:
|
||||
return KeyExpiry
|
||||
default:
|
||||
return ""
|
||||
|
@ -54,7 +54,7 @@ func (repo *OrgRepository) GetMyOrgIamPolicy(ctx context.Context) (*org_model.Or
|
||||
|
||||
func (repo *OrgRepository) SearchMyOrgDomains(ctx context.Context, request *org_model.OrgDomainSearchRequest) (*org_model.OrgDomainSearchResponse, error) {
|
||||
request.EnsureLimit(repo.SearchLimit)
|
||||
request.Queries = append(request.Queries, &org_model.OrgDomainSearchQuery{Key: org_model.ORGDOMAINSEARCHKEY_ORG_ID, Method: global_model.SEARCHMETHOD_EQUALS, Value: auth.GetCtxData(ctx).OrgID})
|
||||
request.Queries = append(request.Queries, &org_model.OrgDomainSearchQuery{Key: org_model.OrgDomainSearchKeyOrgID, Method: global_model.SearchMethodEquals, Value: auth.GetCtxData(ctx).OrgID})
|
||||
domains, count, err := repo.View.SearchOrgDomains(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -110,7 +110,7 @@ func (repo *OrgRepository) RemoveMyOrgMember(ctx context.Context, userID string)
|
||||
|
||||
func (repo *OrgRepository) SearchMyOrgMembers(ctx context.Context, request *org_model.OrgMemberSearchRequest) (*org_model.OrgMemberSearchResponse, error) {
|
||||
request.EnsureLimit(repo.SearchLimit)
|
||||
request.Queries[len(request.Queries)-1] = &org_model.OrgMemberSearchQuery{Key: org_model.ORGMEMBERSEARCHKEY_ORG_ID, Method: global_model.SEARCHMETHOD_EQUALS, Value: auth.GetCtxData(ctx).OrgID}
|
||||
request.Queries[len(request.Queries)-1] = &org_model.OrgMemberSearchQuery{Key: org_model.OrgMemberSearchKeyOrgID, Method: global_model.SearchMethodEquals, Value: auth.GetCtxData(ctx).OrgID}
|
||||
members, count, err := repo.View.SearchOrgMembers(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -62,7 +62,7 @@ func (repo *ProjectRepo) SearchProjects(ctx context.Context, request *proj_model
|
||||
permissions := auth.GetPermissionsFromCtx(ctx)
|
||||
if !auth.HasGlobalPermission(permissions) {
|
||||
ids := auth.GetPermissionCtxIDs(permissions)
|
||||
request.Queries = append(request.Queries, &proj_model.ProjectViewSearchQuery{Key: proj_model.PROJECTSEARCHKEY_PROJECTID, Method: global_model.SEARCHMETHOD_IS_ONE_OF, Value: ids})
|
||||
request.Queries = append(request.Queries, &proj_model.ProjectViewSearchQuery{Key: proj_model.ProjectViewSearchKeyProjectID, Method: global_model.SearchMethodIsOneOf, Value: ids})
|
||||
}
|
||||
|
||||
projects, count, err := repo.View.SearchProjects(request)
|
||||
|
@ -34,7 +34,7 @@ func (p *Application) EventQuery() (*models.SearchQuery, error) {
|
||||
return eventsourcing.ProjectQuery(sequence), nil
|
||||
}
|
||||
|
||||
func (p *Application) Process(event *models.Event) (err error) {
|
||||
func (p *Application) Reduce(event *models.Event) (err error) {
|
||||
app := new(view_model.ApplicationView)
|
||||
switch event.Type {
|
||||
case es_model.ApplicationAdded:
|
||||
|
@ -33,7 +33,7 @@ func (o *Org) EventQuery() (*es_models.SearchQuery, error) {
|
||||
return eventsourcing.OrgQuery(sequence), nil
|
||||
}
|
||||
|
||||
func (o *Org) Process(event *es_models.Event) error {
|
||||
func (o *Org) Reduce(event *es_models.Event) error {
|
||||
org := new(org_model.OrgView)
|
||||
|
||||
switch event.Type {
|
||||
|
@ -35,7 +35,7 @@ func (d *OrgDomain) EventQuery() (*models.SearchQuery, error) {
|
||||
LatestSequenceFilter(sequence), nil
|
||||
}
|
||||
|
||||
func (d *OrgDomain) Process(event *models.Event) (err error) {
|
||||
func (d *OrgDomain) Reduce(event *models.Event) (err error) {
|
||||
switch event.AggregateType {
|
||||
case model.OrgAggregate:
|
||||
err = d.processOrgDomain(event)
|
||||
|
@ -40,7 +40,7 @@ func (m *OrgMember) EventQuery() (*models.SearchQuery, error) {
|
||||
LatestSequenceFilter(sequence), nil
|
||||
}
|
||||
|
||||
func (m *OrgMember) Process(event *models.Event) (err error) {
|
||||
func (m *OrgMember) Reduce(event *models.Event) (err error) {
|
||||
switch event.AggregateType {
|
||||
case model.OrgAggregate:
|
||||
err = m.processOrgMember(event)
|
||||
|
@ -36,7 +36,7 @@ func (p *Project) EventQuery() (*models.SearchQuery, error) {
|
||||
return proj_event.ProjectQuery(sequence), nil
|
||||
}
|
||||
|
||||
func (p *Project) Process(event *models.Event) (err error) {
|
||||
func (p *Project) Reduce(event *models.Event) (err error) {
|
||||
project := new(view_model.ProjectView)
|
||||
switch event.Type {
|
||||
case es_model.ProjectAdded:
|
||||
|
@ -42,7 +42,7 @@ func (p *ProjectGrant) EventQuery() (*models.SearchQuery, error) {
|
||||
return proj_event.ProjectQuery(sequence), nil
|
||||
}
|
||||
|
||||
func (p *ProjectGrant) Process(event *models.Event) (err error) {
|
||||
func (p *ProjectGrant) Reduce(event *models.Event) (err error) {
|
||||
grantedProject := new(view_model.ProjectGrantView)
|
||||
switch event.Type {
|
||||
case es_model.ProjectChanged:
|
||||
|
@ -39,7 +39,7 @@ func (p *ProjectGrantMember) EventQuery() (*models.SearchQuery, error) {
|
||||
LatestSequenceFilter(sequence), nil
|
||||
}
|
||||
|
||||
func (p *ProjectGrantMember) Process(event *models.Event) (err error) {
|
||||
func (p *ProjectGrantMember) Reduce(event *models.Event) (err error) {
|
||||
switch event.AggregateType {
|
||||
case proj_es_model.ProjectAggregate:
|
||||
err = p.processProjectGrantMember(event)
|
||||
|
@ -39,7 +39,7 @@ func (p *ProjectMember) EventQuery() (*models.SearchQuery, error) {
|
||||
LatestSequenceFilter(sequence), nil
|
||||
}
|
||||
|
||||
func (p *ProjectMember) Process(event *models.Event) (err error) {
|
||||
func (p *ProjectMember) Reduce(event *models.Event) (err error) {
|
||||
switch event.AggregateType {
|
||||
case proj_es_model.ProjectAggregate:
|
||||
err = p.processProjectMember(event)
|
||||
|
@ -36,7 +36,7 @@ func (p *ProjectRole) EventQuery() (*models.SearchQuery, error) {
|
||||
return eventsourcing.ProjectQuery(sequence), nil
|
||||
}
|
||||
|
||||
func (p *ProjectRole) Process(event *models.Event) (err error) {
|
||||
func (p *ProjectRole) Reduce(event *models.Event) (err error) {
|
||||
role := new(view_model.ProjectRoleView)
|
||||
switch event.Type {
|
||||
case es_model.ProjectRoleAdded:
|
||||
|
@ -43,7 +43,7 @@ func (p *User) EventQuery() (*models.SearchQuery, error) {
|
||||
LatestSequenceFilter(sequence), nil
|
||||
}
|
||||
|
||||
func (u *User) Process(event *models.Event) (err error) {
|
||||
func (u *User) Reduce(event *models.Event) (err error) {
|
||||
switch event.AggregateType {
|
||||
case es_model.UserAggregate:
|
||||
return u.ProcessUser(event)
|
||||
|
@ -51,7 +51,7 @@ func (u *UserGrant) EventQuery() (*models.SearchQuery, error) {
|
||||
LatestSequenceFilter(sequence), nil
|
||||
}
|
||||
|
||||
func (u *UserGrant) Process(event *models.Event) (err error) {
|
||||
func (u *UserGrant) Reduce(event *models.Event) (err error) {
|
||||
switch event.AggregateType {
|
||||
case grant_es_model.UserGrantAggregate:
|
||||
err = u.processUserGrant(event)
|
||||
|
@ -3,15 +3,15 @@ package model
|
||||
type SearchMethod int32
|
||||
|
||||
const (
|
||||
SEARCHMETHOD_EQUALS SearchMethod = iota
|
||||
SEARCHMETHOD_STARTS_WITH
|
||||
SEARCHMETHOD_CONTAINS
|
||||
SEARCHMETHOD_EQUALS_IGNORE_CASE
|
||||
SEARCHMETHOD_STARTS_WITH_IGNORE_CASE
|
||||
SEARCHMETHOD_CONTAINS_IGNORE_CASE
|
||||
SEARCHMETHOD_NOT_EQUALS
|
||||
SEARCHMETHOD_GREATER_THAN
|
||||
SEARCHMETHOD_LESS_THAN
|
||||
SEARCHMETHOD_IS_ONE_OF
|
||||
SEARCHMETHOD_LIST_CONTAINS
|
||||
SearchMethodEquals SearchMethod = iota
|
||||
SearchMethodStartsWith
|
||||
SearchMethodContains
|
||||
SearchMethodEqualsIgnoreCase
|
||||
SearchMethodStartsWithIgnoreCase
|
||||
SearchMethodContainsIgnoreCase
|
||||
SearchMethodNotEquals
|
||||
SearchMethodGreaterThan
|
||||
SearchMethodLessThan
|
||||
SearchMethodIsOneOf
|
||||
SearchMethodListContains
|
||||
)
|
||||
|
@ -32,7 +32,7 @@ type Notification struct {
|
||||
|
||||
const (
|
||||
notificationTable = "notification.notifications"
|
||||
NOTIFY_USER = "NOTIFICATION"
|
||||
NotifyUserID = "NOTIFICATION"
|
||||
)
|
||||
|
||||
func (n *Notification) MinimumCycleDuration() time.Duration { return n.cycleDuration }
|
||||
@ -49,7 +49,7 @@ func (n *Notification) EventQuery() (*models.SearchQuery, error) {
|
||||
return eventsourcing.UserQuery(sequence), nil
|
||||
}
|
||||
|
||||
func (n *Notification) Process(event *models.Event) (err error) {
|
||||
func (n *Notification) Reduce(event *models.Event) (err error) {
|
||||
switch event.Type {
|
||||
case es_model.InitializedUserCodeAdded:
|
||||
err = n.handleInitUserCode(event)
|
||||
@ -168,5 +168,5 @@ func (n *Notification) OnError(event *models.Event, err error) error {
|
||||
}
|
||||
|
||||
func getSetNotifyContextData(orgID string) context.Context {
|
||||
return auth.SetCtxData(context.Background(), auth.CtxData{UserID: NOTIFY_USER, OrgID: orgID})
|
||||
return auth.SetCtxData(context.Background(), auth.CtxData{UserID: NotifyUserID, OrgID: orgID})
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ func (p *NotifyUser) EventQuery() (*models.SearchQuery, error) {
|
||||
return eventsourcing.UserQuery(sequence), nil
|
||||
}
|
||||
|
||||
func (p *NotifyUser) Process(event *models.Event) (err error) {
|
||||
func (p *NotifyUser) Reduce(event *models.Event) (err error) {
|
||||
user := new(view_model.NotifyUser)
|
||||
switch event.Type {
|
||||
case es_model.UserAdded,
|
||||
|
@ -25,11 +25,11 @@ type OrgDomainSearchRequest struct {
|
||||
type OrgDomainSearchKey int32
|
||||
|
||||
const (
|
||||
ORGDOMAINSEARCHKEY_UNSPECIFIED OrgDomainSearchKey = iota
|
||||
ORGDOMAINSEARCHKEY_DOMAIN
|
||||
ORGDOMAINSEARCHKEY_ORG_ID
|
||||
ORGDOMAINSEARCHKEY_VERIFIED
|
||||
ORGDOMAINSEARCHKEY_PRIMARY
|
||||
OrgDomainSearchKeyUnspecified OrgDomainSearchKey = iota
|
||||
OrgDomainSearchKeyDomain
|
||||
OrgDomainSearchKeyOrgID
|
||||
OrgDomainSearchKeyVerified
|
||||
OrgDomainSearchKeyPrimary
|
||||
)
|
||||
|
||||
type OrgDomainSearchQuery struct {
|
||||
|
@ -32,16 +32,16 @@ type OrgChange struct {
|
||||
type OrgState int32
|
||||
|
||||
const (
|
||||
ORGSTATE_ACTIVE OrgState = iota
|
||||
ORGSTATE_INACTIVE
|
||||
OrgStateActive OrgState = iota
|
||||
OrgStateInactive
|
||||
)
|
||||
|
||||
func NewOrg(id string) *Org {
|
||||
return &Org{ObjectRoot: es_models.ObjectRoot{AggregateID: id}, State: ORGSTATE_ACTIVE}
|
||||
return &Org{ObjectRoot: es_models.ObjectRoot{AggregateID: id}, State: OrgStateActive}
|
||||
}
|
||||
|
||||
func (o *Org) IsActive() bool {
|
||||
return o.State == ORGSTATE_ACTIVE
|
||||
return o.State == OrgStateActive
|
||||
}
|
||||
|
||||
func (o *Org) IsValid() bool {
|
||||
|
@ -16,6 +16,6 @@ type OrgIamPolicy struct {
|
||||
type PolicyState int32
|
||||
|
||||
const (
|
||||
POLICYSTATE_ACTIVE PolicyState = iota
|
||||
POLICYSTATE_REMOVED
|
||||
PolicyStateActive PolicyState = iota
|
||||
PolicyStateRemoved
|
||||
)
|
||||
|
@ -30,13 +30,13 @@ type OrgMemberSearchRequest struct {
|
||||
type OrgMemberSearchKey int32
|
||||
|
||||
const (
|
||||
ORGMEMBERSEARCHKEY_UNSPECIFIED OrgMemberSearchKey = iota
|
||||
ORGMEMBERSEARCHKEY_USER_NAME
|
||||
ORGMEMBERSEARCHKEY_EMAIL
|
||||
ORGMEMBERSEARCHKEY_FIRST_NAME
|
||||
ORGMEMBERSEARCHKEY_LAST_NAME
|
||||
ORGMEMBERSEARCHKEY_ORG_ID
|
||||
ORGMEMBERSEARCHKEY_USER_ID
|
||||
OrgMemberSearchKeyUnspecified OrgMemberSearchKey = iota
|
||||
OrgMemberSearchKeyUserName
|
||||
OrgMemberSearchKeyEmail
|
||||
OrgMemberSearchKeyFirstName
|
||||
OrgMemberSearchKeyLastName
|
||||
OrgMemberSearchKeyOrgID
|
||||
OrgMemberSearchKeyUserID
|
||||
)
|
||||
|
||||
type OrgMemberSearchQuery struct {
|
||||
|
@ -29,12 +29,12 @@ type OrgSearchRequest struct {
|
||||
type OrgSearchKey int32
|
||||
|
||||
const (
|
||||
ORGSEARCHKEY_UNSPECIFIED OrgSearchKey = iota
|
||||
ORGSEARCHKEY_ORG_ID
|
||||
ORGSEARCHKEY_ORG_NAME
|
||||
ORGSEARCHKEY_ORG_DOMAIN
|
||||
ORGSEARCHKEY_STATE
|
||||
ORGSEARCHKEY_RESOURCEOWNER
|
||||
OrgSearchKeyUnspecified OrgSearchKey = iota
|
||||
OrgSearchKeyOrgID
|
||||
OrgSearchKeyOrgName
|
||||
OrgSearchKeyOrgDomain
|
||||
OrgSearchKeyState
|
||||
OrgSearchKeyResourceOwner
|
||||
)
|
||||
|
||||
type OrgSearchQuery struct {
|
||||
|
@ -84,9 +84,9 @@ func (o *Org) AppendEvent(event *es_models.Event) error {
|
||||
return err
|
||||
}
|
||||
case OrgDeactivated:
|
||||
o.State = int32(org_model.ORGSTATE_INACTIVE)
|
||||
o.State = int32(org_model.OrgStateInactive)
|
||||
case OrgReactivated:
|
||||
o.State = int32(org_model.ORGSTATE_ACTIVE)
|
||||
o.State = int32(org_model.OrgStateActive)
|
||||
case OrgMemberAdded:
|
||||
member, err := OrgMemberFromEvent(nil, event)
|
||||
if err != nil {
|
||||
|
@ -26,7 +26,7 @@ func TestOrgFromEvents(t *testing.T) {
|
||||
},
|
||||
org: &Org{Name: "OrgName"},
|
||||
},
|
||||
result: &Org{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, State: int32(model.ORGSTATE_ACTIVE), Name: "OrgName"},
|
||||
result: &Org{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, State: int32(model.OrgStateActive), Name: "OrgName"},
|
||||
},
|
||||
{
|
||||
name: "org from events, nil org",
|
||||
@ -36,7 +36,7 @@ func TestOrgFromEvents(t *testing.T) {
|
||||
},
|
||||
org: nil,
|
||||
},
|
||||
result: &Org{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, State: int32(model.ORGSTATE_ACTIVE)},
|
||||
result: &Org{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, State: int32(model.OrgStateActive)},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
@ -69,7 +69,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
event: &es_models.Event{AggregateID: "ID", Sequence: 1, Type: OrgAdded},
|
||||
org: &Org{Name: "OrgName"},
|
||||
},
|
||||
result: &Org{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, State: int32(model.ORGSTATE_ACTIVE), Name: "OrgName"},
|
||||
result: &Org{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, State: int32(model.OrgStateActive), Name: "OrgName"},
|
||||
},
|
||||
{
|
||||
name: "append change event",
|
||||
@ -77,28 +77,28 @@ func TestAppendEvent(t *testing.T) {
|
||||
event: &es_models.Event{AggregateID: "ID", Sequence: 1, Type: OrgChanged, Data: []byte(`{"name": "OrgName}`)},
|
||||
org: &Org{Name: "OrgNameChanged"},
|
||||
},
|
||||
result: &Org{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, State: int32(model.ORGSTATE_ACTIVE), Name: "OrgNameChanged"},
|
||||
result: &Org{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, State: int32(model.OrgStateActive), Name: "OrgNameChanged"},
|
||||
},
|
||||
{
|
||||
name: "append deactivate event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "ID", Sequence: 1, Type: OrgDeactivated},
|
||||
},
|
||||
result: &Org{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, State: int32(model.ORGSTATE_INACTIVE)},
|
||||
result: &Org{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, State: int32(model.OrgStateInactive)},
|
||||
},
|
||||
{
|
||||
name: "append reactivate event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "ID", Sequence: 1, Type: OrgReactivated},
|
||||
},
|
||||
result: &Org{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, State: int32(model.ORGSTATE_ACTIVE)},
|
||||
result: &Org{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, State: int32(model.OrgStateActive)},
|
||||
},
|
||||
{
|
||||
name: "append added domain event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "ID", Sequence: 1, Type: OrgDomainAdded},
|
||||
},
|
||||
result: &Org{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, State: int32(model.ORGSTATE_ACTIVE)},
|
||||
result: &Org{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, State: int32(model.OrgStateActive)},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
@ -141,7 +141,7 @@ func orgDeactivateAggregate(aggCreator *es_models.AggregateCreator, org *model.O
|
||||
if org == nil {
|
||||
return nil, errors.ThrowPreconditionFailed(nil, "EVENT-R03z8", "Errors.Internal")
|
||||
}
|
||||
if org.State == int32(org_model.ORGSTATE_INACTIVE) {
|
||||
if org.State == int32(org_model.OrgStateInactive) {
|
||||
return nil, errors.ThrowInvalidArgument(nil, "EVENT-mcPH0", "Errors.Internal.AlreadyDeactivated")
|
||||
}
|
||||
agg, err := OrgAggregate(ctx, aggCreator, org.AggregateID, org.Sequence)
|
||||
@ -158,7 +158,7 @@ func orgReactivateAggregate(aggCreator *es_models.AggregateCreator, org *model.O
|
||||
if org == nil {
|
||||
return nil, errors.ThrowPreconditionFailed(nil, "EVENT-cTHLd", "Errors.Internal")
|
||||
}
|
||||
if org.State == int32(org_model.ORGSTATE_ACTIVE) {
|
||||
if org.State == int32(org_model.OrgStateActive) {
|
||||
return nil, errors.ThrowInvalidArgument(nil, "EVENT-pUSMs", "Errors.Org.AlreadyActive")
|
||||
}
|
||||
agg, err := OrgAggregate(ctx, aggCreator, org.AggregateID, org.Sequence)
|
||||
|
@ -236,7 +236,7 @@ func TestOrgReactivateAggregate(t *testing.T) {
|
||||
AggregateID: "orgID",
|
||||
Sequence: 2,
|
||||
},
|
||||
State: int32(org_model.ORGSTATE_INACTIVE),
|
||||
State: int32(org_model.OrgStateInactive),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -250,7 +250,7 @@ func TestOrgReactivateAggregate(t *testing.T) {
|
||||
AggregateID: "orgID",
|
||||
Sequence: 2,
|
||||
},
|
||||
State: int32(org_model.ORGSTATE_ACTIVE),
|
||||
State: int32(org_model.OrgStateActive),
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
@ -310,7 +310,7 @@ func TestOrgDeactivateAggregate(t *testing.T) {
|
||||
AggregateID: "orgID",
|
||||
Sequence: 2,
|
||||
},
|
||||
State: int32(org_model.ORGSTATE_ACTIVE),
|
||||
State: int32(org_model.OrgStateActive),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -324,7 +324,7 @@ func TestOrgDeactivateAggregate(t *testing.T) {
|
||||
AggregateID: "orgID",
|
||||
Sequence: 2,
|
||||
},
|
||||
State: int32(org_model.ORGSTATE_INACTIVE),
|
||||
State: int32(org_model.OrgStateInactive),
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
|
@ -69,16 +69,16 @@ func (o *OrgView) AppendEvent(event *es_models.Event) (err error) {
|
||||
switch event.Type {
|
||||
case model.OrgAdded:
|
||||
o.CreationDate = event.CreationDate
|
||||
o.State = int32(org_model.ORGSTATE_ACTIVE)
|
||||
o.State = int32(org_model.OrgStateActive)
|
||||
o.setRootData(event)
|
||||
err = o.SetData(event)
|
||||
case model.OrgChanged:
|
||||
o.setRootData(event)
|
||||
err = o.SetData(event)
|
||||
case model.OrgDeactivated:
|
||||
o.State = int32(org_model.ORGSTATE_INACTIVE)
|
||||
o.State = int32(org_model.OrgStateInactive)
|
||||
case model.OrgReactivated:
|
||||
o.State = int32(org_model.ORGSTATE_ACTIVE)
|
||||
o.State = int32(org_model.OrgStateActive)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ func (req OrgDomainSearchRequest) GetOffset() uint64 {
|
||||
}
|
||||
|
||||
func (req OrgDomainSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
if req.SortingColumn == org_model.ORGDOMAINSEARCHKEY_UNSPECIFIED {
|
||||
if req.SortingColumn == org_model.OrgDomainSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return OrgDomainSearchKey(req.SortingColumn)
|
||||
@ -51,13 +51,13 @@ func (req OrgDomainSearchQuery) GetValue() interface{} {
|
||||
|
||||
func (key OrgDomainSearchKey) ToColumnName() string {
|
||||
switch org_model.OrgDomainSearchKey(key) {
|
||||
case org_model.ORGDOMAINSEARCHKEY_DOMAIN:
|
||||
case org_model.OrgDomainSearchKeyDomain:
|
||||
return OrgDomainKeyDomain
|
||||
case org_model.ORGDOMAINSEARCHKEY_ORG_ID:
|
||||
case org_model.OrgDomainSearchKeyOrgID:
|
||||
return OrgDomainKeyOrgID
|
||||
case org_model.ORGDOMAINSEARCHKEY_VERIFIED:
|
||||
case org_model.OrgDomainSearchKeyVerified:
|
||||
return OrgDomainKeyVerified
|
||||
case org_model.ORGDOMAINSEARCHKEY_PRIMARY:
|
||||
case org_model.OrgDomainSearchKeyPrimary:
|
||||
return OrgDomainKeyPrimary
|
||||
default:
|
||||
return ""
|
||||
|
@ -19,7 +19,7 @@ func (req OrgMemberSearchRequest) GetOffset() uint64 {
|
||||
}
|
||||
|
||||
func (req OrgMemberSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
if req.SortingColumn == proj_model.ORGMEMBERSEARCHKEY_UNSPECIFIED {
|
||||
if req.SortingColumn == proj_model.OrgMemberSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return OrgMemberSearchKey(req.SortingColumn)
|
||||
@ -51,17 +51,17 @@ func (req OrgMemberSearchQuery) GetValue() interface{} {
|
||||
|
||||
func (key OrgMemberSearchKey) ToColumnName() string {
|
||||
switch proj_model.OrgMemberSearchKey(key) {
|
||||
case proj_model.ORGMEMBERSEARCHKEY_EMAIL:
|
||||
case proj_model.OrgMemberSearchKeyEmail:
|
||||
return OrgMemberKeyEmail
|
||||
case proj_model.ORGMEMBERSEARCHKEY_FIRST_NAME:
|
||||
case proj_model.OrgMemberSearchKeyFirstName:
|
||||
return OrgMemberKeyFirstName
|
||||
case proj_model.ORGMEMBERSEARCHKEY_LAST_NAME:
|
||||
case proj_model.OrgMemberSearchKeyLastName:
|
||||
return OrgMemberKeyLastName
|
||||
case proj_model.ORGMEMBERSEARCHKEY_USER_NAME:
|
||||
case proj_model.OrgMemberSearchKeyUserName:
|
||||
return OrgMemberKeyUserName
|
||||
case proj_model.ORGMEMBERSEARCHKEY_USER_ID:
|
||||
case proj_model.OrgMemberSearchKeyUserID:
|
||||
return OrgMemberKeyUserID
|
||||
case proj_model.ORGMEMBERSEARCHKEY_ORG_ID:
|
||||
case proj_model.OrgMemberSearchKeyOrgID:
|
||||
return OrgMemberKeyOrgID
|
||||
default:
|
||||
return ""
|
||||
|
@ -19,7 +19,7 @@ func (req OrgSearchRequest) GetOffset() uint64 {
|
||||
}
|
||||
|
||||
func (req OrgSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
if req.SortingColumn == usr_model.ORGSEARCHKEY_UNSPECIFIED {
|
||||
if req.SortingColumn == usr_model.OrgSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return OrgSearchKey(req.SortingColumn)
|
||||
@ -51,15 +51,15 @@ func (req OrgSearchQuery) GetValue() interface{} {
|
||||
|
||||
func (key OrgSearchKey) ToColumnName() string {
|
||||
switch usr_model.OrgSearchKey(key) {
|
||||
case usr_model.ORGSEARCHKEY_ORG_DOMAIN:
|
||||
case usr_model.OrgSearchKeyOrgDomain:
|
||||
return OrgKeyOrgDomain
|
||||
case usr_model.ORGSEARCHKEY_ORG_ID:
|
||||
case usr_model.OrgSearchKeyOrgID:
|
||||
return OrgKeyOrgID
|
||||
case usr_model.ORGSEARCHKEY_ORG_NAME:
|
||||
case usr_model.OrgSearchKeyOrgName:
|
||||
return OrgKeyOrgName
|
||||
case usr_model.ORGSEARCHKEY_RESOURCEOWNER:
|
||||
case usr_model.OrgSearchKeyResourceOwner:
|
||||
return OrgKeyResourceOwner
|
||||
case usr_model.ORGSEARCHKEY_STATE:
|
||||
case usr_model.OrgSearchKeyState:
|
||||
return OrgKeyState
|
||||
default:
|
||||
return ""
|
||||
|
@ -10,8 +10,8 @@ import (
|
||||
|
||||
func OrgDomainByOrgIDAndDomain(db *gorm.DB, table, orgID, domain string) (*model.OrgDomainView, error) {
|
||||
domainView := new(model.OrgDomainView)
|
||||
orgIDQuery := &model.OrgDomainSearchQuery{Key: org_model.ORGDOMAINSEARCHKEY_ORG_ID, Value: orgID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
domainQuery := &model.OrgDomainSearchQuery{Key: org_model.ORGDOMAINSEARCHKEY_DOMAIN, Value: domain, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
orgIDQuery := &model.OrgDomainSearchQuery{Key: org_model.OrgDomainSearchKeyOrgID, Value: orgID, Method: global_model.SearchMethodEquals}
|
||||
domainQuery := &model.OrgDomainSearchQuery{Key: org_model.OrgDomainSearchKeyDomain, Value: domain, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, orgIDQuery, domainQuery)
|
||||
err := query(db, domainView)
|
||||
return domainView, err
|
||||
@ -19,8 +19,8 @@ func OrgDomainByOrgIDAndDomain(db *gorm.DB, table, orgID, domain string) (*model
|
||||
|
||||
func VerifiedOrgDomain(db *gorm.DB, table, domain string) (*model.OrgDomainView, error) {
|
||||
domainView := new(model.OrgDomainView)
|
||||
domainQuery := &model.OrgDomainSearchQuery{Key: org_model.ORGDOMAINSEARCHKEY_DOMAIN, Value: domain, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
verifiedQuery := &model.OrgDomainSearchQuery{Key: org_model.ORGDOMAINSEARCHKEY_VERIFIED, Value: true, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
domainQuery := &model.OrgDomainSearchQuery{Key: org_model.OrgDomainSearchKeyDomain, Value: domain, Method: global_model.SearchMethodEquals}
|
||||
verifiedQuery := &model.OrgDomainSearchQuery{Key: org_model.OrgDomainSearchKeyVerified, Value: true, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, domainQuery, verifiedQuery)
|
||||
err := query(db, domainView)
|
||||
return domainView, err
|
||||
@ -40,9 +40,9 @@ func OrgDomainsByOrgID(db *gorm.DB, table string, orgID string) ([]*model.OrgDom
|
||||
domains := make([]*model.OrgDomainView, 0)
|
||||
queries := []*org_model.OrgDomainSearchQuery{
|
||||
{
|
||||
Key: org_model.ORGDOMAINSEARCHKEY_ORG_ID,
|
||||
Key: org_model.OrgDomainSearchKeyOrgID,
|
||||
Value: orgID,
|
||||
Method: global_model.SEARCHMETHOD_EQUALS,
|
||||
Method: global_model.SearchMethodEquals,
|
||||
},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.OrgDomainSearchRequest{Queries: queries})
|
||||
@ -60,8 +60,8 @@ func PutOrgDomain(db *gorm.DB, table string, role *model.OrgDomainView) error {
|
||||
|
||||
func DeleteOrgDomain(db *gorm.DB, table, orgID, domain string) error {
|
||||
delete := view.PrepareDeleteByKeys(table,
|
||||
view.Key{Key: model.OrgDomainSearchKey(org_model.ORGDOMAINSEARCHKEY_DOMAIN), Value: domain},
|
||||
view.Key{Key: model.OrgDomainSearchKey(org_model.ORGDOMAINSEARCHKEY_ORG_ID), Value: orgID},
|
||||
view.Key{Key: model.OrgDomainSearchKey(org_model.OrgDomainSearchKeyDomain), Value: domain},
|
||||
view.Key{Key: model.OrgDomainSearchKey(org_model.OrgDomainSearchKeyOrgID), Value: orgID},
|
||||
)
|
||||
return delete(db)
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ import (
|
||||
func OrgMemberByIDs(db *gorm.DB, table, orgID, userID string) (*model.OrgMemberView, error) {
|
||||
member := new(model.OrgMemberView)
|
||||
|
||||
orgIDQuery := &model.OrgMemberSearchQuery{Key: org_model.ORGMEMBERSEARCHKEY_ORG_ID, Value: orgID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
userIDQuery := &model.OrgMemberSearchQuery{Key: org_model.ORGMEMBERSEARCHKEY_USER_ID, Value: userID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
orgIDQuery := &model.OrgMemberSearchQuery{Key: org_model.OrgMemberSearchKeyOrgID, Value: orgID, Method: global_model.SearchMethodEquals}
|
||||
userIDQuery := &model.OrgMemberSearchQuery{Key: org_model.OrgMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, orgIDQuery, userIDQuery)
|
||||
err := query(db, member)
|
||||
return member, err
|
||||
@ -31,9 +31,9 @@ func OrgMembersByUserID(db *gorm.DB, table string, userID string) ([]*model.OrgM
|
||||
members := make([]*model.OrgMemberView, 0)
|
||||
queries := []*org_model.OrgMemberSearchQuery{
|
||||
{
|
||||
Key: org_model.ORGMEMBERSEARCHKEY_USER_ID,
|
||||
Key: org_model.OrgMemberSearchKeyUserID,
|
||||
Value: userID,
|
||||
Method: global_model.SEARCHMETHOD_EQUALS,
|
||||
Method: global_model.SearchMethodEquals,
|
||||
},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.OrgMemberSearchRequest{Queries: queries})
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
func OrgByID(db *gorm.DB, table, orgID string) (*model.OrgView, error) {
|
||||
org := new(model.OrgView)
|
||||
query := view.PrepareGetByKey(table, model.OrgSearchKey(org_model.ORGSEARCHKEY_ORG_ID), orgID)
|
||||
query := view.PrepareGetByKey(table, model.OrgSearchKey(org_model.OrgSearchKeyOrgID), orgID)
|
||||
err := query(db, org)
|
||||
return org, err
|
||||
}
|
||||
@ -30,6 +30,6 @@ func PutOrg(db *gorm.DB, table string, org *model.OrgView) error {
|
||||
}
|
||||
|
||||
func DeleteOrg(db *gorm.DB, table, orgID string) error {
|
||||
delete := view.PrepareDeleteByKey(table, model.OrgSearchKey(org_model.ORGSEARCHKEY_ORG_ID), orgID)
|
||||
delete := view.PrepareDeleteByKey(table, model.OrgSearchKey(org_model.OrgSearchKeyOrgID), orgID)
|
||||
return delete(db)
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package model
|
||||
import "github.com/caos/zitadel/internal/eventstore/models"
|
||||
|
||||
const (
|
||||
//default
|
||||
DefaultPolicy = "0"
|
||||
|
||||
// complexity
|
||||
PasswordComplexityPolicyAggregate models.AggregateType = "policy.password.complexity"
|
||||
|
||||
@ -25,6 +28,6 @@ const (
|
||||
type PolicyState int32
|
||||
|
||||
const (
|
||||
POLICYSTATE_ACTIVE PolicyState = iota
|
||||
POLICYSTATE_INACTIVE
|
||||
PolicyStateActive PolicyState = iota
|
||||
PolicyStateInactive
|
||||
)
|
||||
|
@ -143,7 +143,7 @@ func TestPasswordAgePolicyCreateAggregate(t *testing.T) {
|
||||
name: "policy update aggregate ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
new: &PasswordAgePolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName", State: int32(policy_model.POLICYSTATE_ACTIVE)},
|
||||
new: &PasswordAgePolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName", State: int32(policy_model.PolicyStateActive)},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
res: res{
|
||||
@ -208,8 +208,8 @@ func TestPasswordAgePolicyUpdateAggregate(t *testing.T) {
|
||||
name: "policy update aggregate ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &PasswordAgePolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName", State: int32(policy_model.POLICYSTATE_ACTIVE)},
|
||||
new: &PasswordAgePolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName_Changed", State: int32(policy_model.POLICYSTATE_ACTIVE)},
|
||||
existing: &PasswordAgePolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName", State: int32(policy_model.PolicyStateActive)},
|
||||
new: &PasswordAgePolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName_Changed", State: int32(policy_model.PolicyStateActive)},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
res: res{
|
||||
@ -235,7 +235,7 @@ func TestPasswordAgePolicyUpdateAggregate(t *testing.T) {
|
||||
name: "new policy nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &PasswordAgePolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "ProjectName", State: int32(policy_model.POLICYSTATE_ACTIVE)},
|
||||
existing: &PasswordAgePolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "ProjectName", State: int32(policy_model.PolicyStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
|
@ -143,7 +143,7 @@ func TestPasswordComplexityPolicyCreateAggregate(t *testing.T) {
|
||||
name: "policy update aggregate ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
new: &PasswordComplexityPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName", State: int32(policy_model.POLICYSTATE_ACTIVE)},
|
||||
new: &PasswordComplexityPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName", State: int32(policy_model.PolicyStateActive)},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
res: res{
|
||||
@ -208,8 +208,8 @@ func TestPasswordComplexityPolicyUpdateAggregate(t *testing.T) {
|
||||
name: "policy update aggregate ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &PasswordComplexityPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName", State: int32(policy_model.POLICYSTATE_ACTIVE)},
|
||||
new: &PasswordComplexityPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName_Changed", State: int32(policy_model.POLICYSTATE_ACTIVE)},
|
||||
existing: &PasswordComplexityPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName", State: int32(policy_model.PolicyStateActive)},
|
||||
new: &PasswordComplexityPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName_Changed", State: int32(policy_model.PolicyStateActive)},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
res: res{
|
||||
@ -235,7 +235,7 @@ func TestPasswordComplexityPolicyUpdateAggregate(t *testing.T) {
|
||||
name: "new policy nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &PasswordComplexityPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "ProjectName", State: int32(policy_model.POLICYSTATE_ACTIVE)},
|
||||
existing: &PasswordComplexityPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "ProjectName", State: int32(policy_model.PolicyStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
|
@ -143,7 +143,7 @@ func TestPasswordLockoutPolicyCreateAggregate(t *testing.T) {
|
||||
name: "policy update aggregate ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
new: &PasswordLockoutPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName", State: int32(policy_model.POLICYSTATE_ACTIVE)},
|
||||
new: &PasswordLockoutPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName", State: int32(policy_model.PolicyStateActive)},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
res: res{
|
||||
@ -208,8 +208,8 @@ func TestPasswordLockoutPolicyUpdateAggregate(t *testing.T) {
|
||||
name: "policy update aggregate ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &PasswordLockoutPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName", State: int32(policy_model.POLICYSTATE_ACTIVE)},
|
||||
new: &PasswordLockoutPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName_Changed", State: int32(policy_model.POLICYSTATE_ACTIVE)},
|
||||
existing: &PasswordLockoutPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName", State: int32(policy_model.PolicyStateActive)},
|
||||
new: &PasswordLockoutPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName_Changed", State: int32(policy_model.PolicyStateActive)},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
res: res{
|
||||
@ -235,7 +235,7 @@ func TestPasswordLockoutPolicyUpdateAggregate(t *testing.T) {
|
||||
name: "new policy nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &PasswordLockoutPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "ProjectName", State: int32(policy_model.POLICYSTATE_ACTIVE)},
|
||||
existing: &PasswordLockoutPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "ProjectName", State: int32(policy_model.PolicyStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
|
@ -30,20 +30,20 @@ type ApplicationChange struct {
|
||||
type AppState int32
|
||||
|
||||
const (
|
||||
APPSTATE_ACTIVE AppState = iota
|
||||
APPSTATE_INACTIVE
|
||||
AppStateActive AppState = iota
|
||||
AppStateInactive
|
||||
)
|
||||
|
||||
type AppType int32
|
||||
|
||||
const (
|
||||
APPTYPE_UNDEFINED AppType = iota
|
||||
APPTYPE_OIDC
|
||||
APPTYPE_SAML
|
||||
AppTypeUnspecified AppType = iota
|
||||
AppTypeOIDC
|
||||
AppTypeSAML
|
||||
)
|
||||
|
||||
func NewApplication(projectID, appID string) *Application {
|
||||
return &Application{ObjectRoot: es_models.ObjectRoot{AggregateID: projectID}, AppID: appID, State: APPSTATE_ACTIVE}
|
||||
return &Application{ObjectRoot: es_models.ObjectRoot{AggregateID: projectID}, AppID: appID, State: AppStateActive}
|
||||
}
|
||||
|
||||
func (a *Application) IsValid(includeConfig bool) bool {
|
||||
@ -53,7 +53,7 @@ func (a *Application) IsValid(includeConfig bool) bool {
|
||||
if !includeConfig {
|
||||
return true
|
||||
}
|
||||
if a.Type == APPTYPE_OIDC && !a.OIDCConfig.IsValid() {
|
||||
if a.Type == AppTypeOIDC && !a.OIDCConfig.IsValid() {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
@ -21,10 +21,10 @@ func TestApplicationValid(t *testing.T) {
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
Type: APPTYPE_OIDC,
|
||||
Type: AppTypeOIDC,
|
||||
OIDCConfig: &OIDCConfig{
|
||||
ResponseTypes: []OIDCResponseType{OIDCRESPONSETYPE_CODE},
|
||||
GrantTypes: []OIDCGrantType{OIDCGRANTTYPE_AUTHORIZATION_CODE},
|
||||
ResponseTypes: []OIDCResponseType{OIDCResponseTypeCode},
|
||||
GrantTypes: []OIDCGrantType{OIDCGrantTypeAuthorizationCode},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -37,10 +37,10 @@ func TestApplicationValid(t *testing.T) {
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
Type: APPTYPE_OIDC,
|
||||
Type: AppTypeOIDC,
|
||||
OIDCConfig: &OIDCConfig{
|
||||
ResponseTypes: []OIDCResponseType{OIDCRESPONSETYPE_CODE},
|
||||
GrantTypes: []OIDCGrantType{OIDCGRANTTYPE_IMPLICIT},
|
||||
ResponseTypes: []OIDCResponseType{OIDCResponseTypeCode},
|
||||
GrantTypes: []OIDCGrantType{OIDCGrantTypeImplicit},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -53,10 +53,10 @@ func TestApplicationValid(t *testing.T) {
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
Type: APPTYPE_OIDC,
|
||||
Type: AppTypeOIDC,
|
||||
OIDCConfig: &OIDCConfig{
|
||||
ResponseTypes: []OIDCResponseType{OIDCRESPONSETYPE_ID_TOKEN},
|
||||
GrantTypes: []OIDCGrantType{OIDCGRANTTYPE_IMPLICIT},
|
||||
ResponseTypes: []OIDCResponseType{OIDCResponseTypeIDToken},
|
||||
GrantTypes: []OIDCGrantType{OIDCGrantTypeImplicit},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -69,10 +69,10 @@ func TestApplicationValid(t *testing.T) {
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
Type: APPTYPE_OIDC,
|
||||
Type: AppTypeOIDC,
|
||||
OIDCConfig: &OIDCConfig{
|
||||
ResponseTypes: []OIDCResponseType{OIDCRESPONSETYPE_ID_TOKEN},
|
||||
GrantTypes: []OIDCGrantType{OIDCGRANTTYPE_AUTHORIZATION_CODE},
|
||||
ResponseTypes: []OIDCResponseType{OIDCResponseTypeIDToken},
|
||||
GrantTypes: []OIDCGrantType{OIDCGrantTypeAuthorizationCode},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -85,10 +85,10 @@ func TestApplicationValid(t *testing.T) {
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
Type: APPTYPE_OIDC,
|
||||
Type: AppTypeOIDC,
|
||||
OIDCConfig: &OIDCConfig{
|
||||
ResponseTypes: []OIDCResponseType{OIDCRESPONSETYPE_TOKEN},
|
||||
GrantTypes: []OIDCGrantType{OIDCGRANTTYPE_IMPLICIT},
|
||||
ResponseTypes: []OIDCResponseType{OIDCResponseTypeToken},
|
||||
GrantTypes: []OIDCGrantType{OIDCGrantTypeImplicit},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -101,10 +101,10 @@ func TestApplicationValid(t *testing.T) {
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
Type: APPTYPE_OIDC,
|
||||
Type: AppTypeOIDC,
|
||||
OIDCConfig: &OIDCConfig{
|
||||
ResponseTypes: []OIDCResponseType{OIDCRESPONSETYPE_TOKEN},
|
||||
GrantTypes: []OIDCGrantType{OIDCGRANTTYPE_AUTHORIZATION_CODE},
|
||||
ResponseTypes: []OIDCResponseType{OIDCResponseTypeToken},
|
||||
GrantTypes: []OIDCGrantType{OIDCGrantTypeAuthorizationCode},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -117,10 +117,10 @@ func TestApplicationValid(t *testing.T) {
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
Type: APPTYPE_OIDC,
|
||||
Type: AppTypeOIDC,
|
||||
OIDCConfig: &OIDCConfig{
|
||||
ResponseTypes: []OIDCResponseType{OIDCRESPONSETYPE_CODE, OIDCRESPONSETYPE_ID_TOKEN},
|
||||
GrantTypes: []OIDCGrantType{OIDCGRANTTYPE_AUTHORIZATION_CODE, OIDCGRANTTYPE_IMPLICIT},
|
||||
ResponseTypes: []OIDCResponseType{OIDCResponseTypeCode, OIDCResponseTypeIDToken},
|
||||
GrantTypes: []OIDCGrantType{OIDCGrantTypeAuthorizationCode, OIDCGrantTypeImplicit},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -133,10 +133,10 @@ func TestApplicationValid(t *testing.T) {
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
Type: APPTYPE_OIDC,
|
||||
Type: AppTypeOIDC,
|
||||
OIDCConfig: &OIDCConfig{
|
||||
ResponseTypes: []OIDCResponseType{OIDCRESPONSETYPE_CODE, OIDCRESPONSETYPE_TOKEN},
|
||||
GrantTypes: []OIDCGrantType{OIDCGRANTTYPE_AUTHORIZATION_CODE, OIDCGRANTTYPE_IMPLICIT},
|
||||
ResponseTypes: []OIDCResponseType{OIDCResponseTypeCode, OIDCResponseTypeToken},
|
||||
GrantTypes: []OIDCGrantType{OIDCGrantTypeAuthorizationCode, OIDCGrantTypeImplicit},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -149,10 +149,10 @@ func TestApplicationValid(t *testing.T) {
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
Type: APPTYPE_OIDC,
|
||||
Type: AppTypeOIDC,
|
||||
OIDCConfig: &OIDCConfig{
|
||||
ResponseTypes: []OIDCResponseType{OIDCRESPONSETYPE_CODE, OIDCRESPONSETYPE_ID_TOKEN, OIDCRESPONSETYPE_TOKEN},
|
||||
GrantTypes: []OIDCGrantType{OIDCGRANTTYPE_AUTHORIZATION_CODE, OIDCGRANTTYPE_IMPLICIT},
|
||||
ResponseTypes: []OIDCResponseType{OIDCResponseTypeCode, OIDCResponseTypeIDToken, OIDCResponseTypeToken},
|
||||
GrantTypes: []OIDCGrantType{OIDCGrantTypeAuthorizationCode, OIDCGrantTypeImplicit},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -28,23 +28,23 @@ type ApplicationView struct {
|
||||
type ApplicationSearchRequest struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
SortingColumn ApplicationSearchKey
|
||||
SortingColumn AppSearchKey
|
||||
Asc bool
|
||||
Queries []*ApplicationSearchQuery
|
||||
}
|
||||
|
||||
type ApplicationSearchKey int32
|
||||
type AppSearchKey int32
|
||||
|
||||
const (
|
||||
APPLICATIONSEARCHKEY_UNSPECIFIED ApplicationSearchKey = iota
|
||||
APPLICATIONSEARCHKEY_NAME
|
||||
APPLICATIONSEARCHKEY_OIDC_CLIENT_ID
|
||||
APPLICATIONSEARCHKEY_PROJECT_ID
|
||||
APPLICATIONSEARCHKEY_APP_ID
|
||||
AppSearchKeyUnspecified AppSearchKey = iota
|
||||
AppSearchKeyName
|
||||
AppSearchKeyOIDCClientID
|
||||
AppSearchKeyProjectID
|
||||
AppSearchKeyAppID
|
||||
)
|
||||
|
||||
type ApplicationSearchQuery struct {
|
||||
Key ApplicationSearchKey
|
||||
Key AppSearchKey
|
||||
Method model.SearchMethod
|
||||
Value interface{}
|
||||
}
|
||||
|
@ -22,33 +22,33 @@ type OIDCConfig struct {
|
||||
type OIDCResponseType int32
|
||||
|
||||
const (
|
||||
OIDCRESPONSETYPE_CODE OIDCResponseType = iota
|
||||
OIDCRESPONSETYPE_ID_TOKEN
|
||||
OIDCRESPONSETYPE_TOKEN
|
||||
OIDCResponseTypeCode OIDCResponseType = iota
|
||||
OIDCResponseTypeIDToken
|
||||
OIDCResponseTypeToken
|
||||
)
|
||||
|
||||
type OIDCGrantType int32
|
||||
|
||||
const (
|
||||
OIDCGRANTTYPE_AUTHORIZATION_CODE OIDCGrantType = iota
|
||||
OIDCGRANTTYPE_IMPLICIT
|
||||
OIDCGRANTTYPE_REFRESH_TOKEN
|
||||
OIDCGrantTypeAuthorizationCode OIDCGrantType = iota
|
||||
OIDCGrantTypeImplicit
|
||||
OIDCGrantTypeRefreshToken
|
||||
)
|
||||
|
||||
type OIDCApplicationType int32
|
||||
|
||||
const (
|
||||
OIDCAPPLICATIONTYPE_WEB OIDCApplicationType = iota
|
||||
OIDCAPPLICATIONTYPE_USER_AGENT
|
||||
OIDCAPPLICATIONTYPE_NATIVE
|
||||
OIDCApplicationTypeWeb OIDCApplicationType = iota
|
||||
OIDCApplicationTypeUserAgent
|
||||
OIDCApplicationTypeNative
|
||||
)
|
||||
|
||||
type OIDCAuthMethodType int32
|
||||
|
||||
const (
|
||||
OIDCAUTHMETHODTYPE_BASIC OIDCAuthMethodType = iota
|
||||
OIDCAUTHMETHODTYPE_POST
|
||||
OIDCAUTHMETHODTYPE_NONE
|
||||
OIDCAuthMethodTypeBasic OIDCAuthMethodType = iota
|
||||
OIDCAuthMethodTypePost
|
||||
OIDCAuthMethodTypeNone
|
||||
)
|
||||
|
||||
func (c *OIDCConfig) IsValid() bool {
|
||||
@ -67,11 +67,11 @@ func (c *OIDCConfig) getRequiredGrantTypes() []OIDCGrantType {
|
||||
implicit := false
|
||||
for _, r := range c.ResponseTypes {
|
||||
switch r {
|
||||
case OIDCRESPONSETYPE_CODE:
|
||||
grantTypes = append(grantTypes, OIDCGRANTTYPE_AUTHORIZATION_CODE)
|
||||
case OIDCRESPONSETYPE_ID_TOKEN, OIDCRESPONSETYPE_TOKEN:
|
||||
case OIDCResponseTypeCode:
|
||||
grantTypes = append(grantTypes, OIDCGrantTypeAuthorizationCode)
|
||||
case OIDCResponseTypeIDToken, OIDCResponseTypeToken:
|
||||
if !implicit {
|
||||
grantTypes = append(grantTypes, OIDCGRANTTYPE_IMPLICIT)
|
||||
grantTypes = append(grantTypes, OIDCGrantTypeImplicit)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,17 +31,17 @@ type ProjectChange struct {
|
||||
type ProjectState int32
|
||||
|
||||
const (
|
||||
PROJECTSTATE_ACTIVE ProjectState = iota
|
||||
PROJECTSTATE_INACTIVE
|
||||
PROJECTSTATE_REMOVED
|
||||
ProjectStateActive ProjectState = iota
|
||||
ProjectStateInactive
|
||||
ProjectStateRemoved
|
||||
)
|
||||
|
||||
func NewProject(id string) *Project {
|
||||
return &Project{ObjectRoot: es_models.ObjectRoot{AggregateID: id}, State: PROJECTSTATE_ACTIVE}
|
||||
return &Project{ObjectRoot: es_models.ObjectRoot{AggregateID: id}, State: ProjectStateActive}
|
||||
}
|
||||
|
||||
func (p *Project) IsActive() bool {
|
||||
return p.State == PROJECTSTATE_ACTIVE
|
||||
return p.State == ProjectStateActive
|
||||
}
|
||||
|
||||
func (p *Project) IsValid() bool {
|
||||
|
@ -22,16 +22,16 @@ type ProjectGrantIDs struct {
|
||||
type ProjectGrantState int32
|
||||
|
||||
const (
|
||||
PROJECTGRANTSTATE_ACTIVE ProjectGrantState = iota
|
||||
PROJECTGRANTSTATE_INACTIVE
|
||||
ProjectGrantStateActive ProjectGrantState = iota
|
||||
ProjectGrantStateInactive
|
||||
)
|
||||
|
||||
func NewProjectGrant(projectID, grantID string) *ProjectGrant {
|
||||
return &ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: projectID}, GrantID: grantID, State: PROJECTGRANTSTATE_ACTIVE}
|
||||
return &ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: projectID}, GrantID: grantID, State: ProjectGrantStateActive}
|
||||
}
|
||||
|
||||
func (p *ProjectGrant) IsActive() bool {
|
||||
return p.State == PROJECTGRANTSTATE_ACTIVE
|
||||
return p.State == ProjectGrantStateActive
|
||||
}
|
||||
|
||||
func (p *ProjectGrant) IsValid() bool {
|
||||
|
@ -30,13 +30,13 @@ type ProjectGrantMemberSearchRequest struct {
|
||||
type ProjectGrantMemberSearchKey int32
|
||||
|
||||
const (
|
||||
PROJECTGRANTMEMBERSEARCHKEY_UNSPECIFIED ProjectGrantMemberSearchKey = iota
|
||||
PROJECTGRANTMEMBERSEARCHKEY_USER_NAME
|
||||
PROJECTGRANTMEMBERSEARCHKEY_EMAIL
|
||||
PROJECTGRANTMEMBERSEARCHKEY_FIRST_NAME
|
||||
PROJECTGRANTMEMBERSEARCHKEY_LAST_NAME
|
||||
PROJECTGRANTMEMBERSEARCHKEY_GRANT_ID
|
||||
PROJECTGRANTMEMBERSEARCHKEY_USER_ID
|
||||
ProjectGrantMemberSearchKeyUnspecified ProjectGrantMemberSearchKey = iota
|
||||
ProjectGrantMemberSearchKeyUserName
|
||||
ProjectGrantMemberSearchKeyEmail
|
||||
ProjectGrantMemberSearchKeyFirstName
|
||||
ProjectGrantMemberSearchKeyLastName
|
||||
ProjectGrantMemberSearchKeyGrantID
|
||||
ProjectGrantMemberSearchKeyUserID
|
||||
)
|
||||
|
||||
type ProjectGrantMemberSearchQuery struct {
|
||||
|
@ -32,13 +32,13 @@ type ProjectGrantViewSearchRequest struct {
|
||||
type ProjectGrantViewSearchKey int32
|
||||
|
||||
const (
|
||||
GRANTEDPROJECTSEARCHKEY_UNSPECIFIED ProjectGrantViewSearchKey = iota
|
||||
GRANTEDPROJECTSEARCHKEY_NAME
|
||||
GRANTEDPROJECTSEARCHKEY_PROJECTID
|
||||
GRANTEDPROJECTSEARCHKEY_GRANTID
|
||||
GRANTEDPROJECTSEARCHKEY_ORGID
|
||||
GRANTEDPROJECTSEARCHKEY_RESOURCE_OWNER
|
||||
GRANTEDPROJECTSEARCHKEY_ROLE_KEYS
|
||||
GrantedProjectSearchKeyUnspecified ProjectGrantViewSearchKey = iota
|
||||
GrantedProjectSearchKeyName
|
||||
GrantedProjectSearchKeyProjectID
|
||||
GrantedProjectSearchKeyGrantID
|
||||
GrantedProjectSearchKeyOrgID
|
||||
GrantedProjectSearchKeyResourceOwner
|
||||
GrantedProjectSearchKeyRoleKeys
|
||||
)
|
||||
|
||||
type ProjectGrantViewSearchQuery struct {
|
||||
@ -55,15 +55,15 @@ type ProjectGrantViewSearchResponse struct {
|
||||
}
|
||||
|
||||
func (r *ProjectGrantViewSearchRequest) AppendMyOrgQuery(orgID string) {
|
||||
r.Queries = append(r.Queries, &ProjectGrantViewSearchQuery{Key: GRANTEDPROJECTSEARCHKEY_ORGID, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
|
||||
r.Queries = append(r.Queries, &ProjectGrantViewSearchQuery{Key: GrantedProjectSearchKeyOrgID, Method: model.SearchMethodEquals, Value: orgID})
|
||||
}
|
||||
|
||||
func (r *ProjectGrantViewSearchRequest) AppendNotMyOrgQuery(orgID string) {
|
||||
r.Queries = append(r.Queries, &ProjectGrantViewSearchQuery{Key: GRANTEDPROJECTSEARCHKEY_ORGID, Method: model.SEARCHMETHOD_NOT_EQUALS, Value: orgID})
|
||||
r.Queries = append(r.Queries, &ProjectGrantViewSearchQuery{Key: GrantedProjectSearchKeyOrgID, Method: model.SearchMethodNotEquals, Value: orgID})
|
||||
}
|
||||
|
||||
func (r *ProjectGrantViewSearchRequest) AppendMyResourceOwnerQuery(orgID string) {
|
||||
r.Queries = append(r.Queries, &ProjectGrantViewSearchQuery{Key: GRANTEDPROJECTSEARCHKEY_RESOURCE_OWNER, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
|
||||
r.Queries = append(r.Queries, &ProjectGrantViewSearchQuery{Key: GrantedProjectSearchKeyResourceOwner, Method: model.SearchMethodEquals, Value: orgID})
|
||||
}
|
||||
|
||||
func (r *ProjectGrantViewSearchRequest) EnsureLimit(limit uint64) {
|
||||
|
@ -29,13 +29,13 @@ type ProjectMemberSearchRequest struct {
|
||||
type ProjectMemberSearchKey int32
|
||||
|
||||
const (
|
||||
PROJECTMEMBERSEARCHKEY_UNSPECIFIED ProjectMemberSearchKey = iota
|
||||
PROJECTMEMBERSEARCHKEY_USER_NAME
|
||||
PROJECTMEMBERSEARCHKEY_EMAIL
|
||||
PROJECTMEMBERSEARCHKEY_FIRST_NAME
|
||||
PROJECTMEMBERSEARCHKEY_LAST_NAME
|
||||
PROJECTMEMBERSEARCHKEY_PROJECT_ID
|
||||
PROJECTMEMBERSEARCHKEY_USER_ID
|
||||
ProjectMemberSearchKeyUnspecified ProjectMemberSearchKey = iota
|
||||
ProjectMemberSearchKeyUserName
|
||||
ProjectMemberSearchKeyEmail
|
||||
ProjectMemberSearchKeyFirstName
|
||||
ProjectMemberSearchKeyLastName
|
||||
ProjectMemberSearchKeyProjectID
|
||||
ProjectMemberSearchKeyUserID
|
||||
)
|
||||
|
||||
type ProjectMemberSearchQuery struct {
|
||||
@ -57,5 +57,5 @@ func (r *ProjectMemberSearchRequest) EnsureLimit(limit uint64) {
|
||||
}
|
||||
}
|
||||
func (r *ProjectMemberSearchRequest) AppendProjectQuery(projectID string) {
|
||||
r.Queries = append(r.Queries, &ProjectMemberSearchQuery{Key: PROJECTMEMBERSEARCHKEY_PROJECT_ID, Method: model.SEARCHMETHOD_EQUALS, Value: projectID})
|
||||
r.Queries = append(r.Queries, &ProjectMemberSearchQuery{Key: ProjectMemberSearchKeyProjectID, Method: model.SearchMethodEquals, Value: projectID})
|
||||
}
|
||||
|
@ -27,12 +27,12 @@ type ProjectRoleSearchRequest struct {
|
||||
type ProjectRoleSearchKey int32
|
||||
|
||||
const (
|
||||
PROJECTROLESEARCHKEY_UNSPECIFIED ProjectRoleSearchKey = iota
|
||||
PROJECTROLESEARCHKEY_KEY
|
||||
PROJECTROLESEARCHKEY_PROJECTID
|
||||
PROJECTROLESEARCHKEY_ORGID
|
||||
PROJECTROLESEARCHKEY_RESOURCEOWNER
|
||||
PROJECTROLESEARCHKEY_DISPLAY_NAME
|
||||
ProjectRoleSearchKeyUnspecified ProjectRoleSearchKey = iota
|
||||
ProjectRoleSearchKeyKey
|
||||
ProjectRoleSearchKeyProjectID
|
||||
ProjectRoleSearchKeyOrgID
|
||||
ProjectRoleSearchKeyResourceOwner
|
||||
ProjectRoleSearchKeyDisplayName
|
||||
)
|
||||
|
||||
type ProjectRoleSearchQuery struct {
|
||||
@ -49,10 +49,10 @@ type ProjectRoleSearchResponse struct {
|
||||
}
|
||||
|
||||
func (r *ProjectRoleSearchRequest) AppendMyOrgQuery(orgID string) {
|
||||
r.Queries = append(r.Queries, &ProjectRoleSearchQuery{Key: PROJECTROLESEARCHKEY_ORGID, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
|
||||
r.Queries = append(r.Queries, &ProjectRoleSearchQuery{Key: ProjectRoleSearchKeyOrgID, Method: model.SearchMethodEquals, Value: orgID})
|
||||
}
|
||||
func (r *ProjectRoleSearchRequest) AppendProjectQuery(projectID string) {
|
||||
r.Queries = append(r.Queries, &ProjectRoleSearchQuery{Key: PROJECTROLESEARCHKEY_PROJECTID, Method: model.SEARCHMETHOD_EQUALS, Value: projectID})
|
||||
r.Queries = append(r.Queries, &ProjectRoleSearchQuery{Key: ProjectRoleSearchKeyProjectID, Method: model.SearchMethodEquals, Value: projectID})
|
||||
}
|
||||
|
||||
func (r *ProjectRoleSearchRequest) EnsureLimit(limit uint64) {
|
||||
|
@ -26,10 +26,10 @@ type ProjectViewSearchRequest struct {
|
||||
type ProjectViewSearchKey int32
|
||||
|
||||
const (
|
||||
PROJECTSEARCHKEY_UNSPECIFIED ProjectViewSearchKey = iota
|
||||
PROJECTSEARCHKEY_NAME
|
||||
PROJECTSEARCHKEY_PROJECTID
|
||||
PROJECTSEARCHKEY_RESOURCE_OWNER
|
||||
ProjectViewSearchKeyUnspecified ProjectViewSearchKey = iota
|
||||
ProjectViewSearchKeyName
|
||||
ProjectViewSearchKeyProjectID
|
||||
ProjectViewSearchKeyResourceOwner
|
||||
)
|
||||
|
||||
type ProjectViewSearchQuery struct {
|
||||
@ -46,7 +46,7 @@ type ProjectViewSearchResponse struct {
|
||||
}
|
||||
|
||||
func (r *ProjectViewSearchRequest) AppendMyResourceOwnerQuery(orgID string) {
|
||||
r.Queries = append(r.Queries, &ProjectViewSearchQuery{Key: PROJECTSEARCHKEY_RESOURCE_OWNER, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
|
||||
r.Queries = append(r.Queries, &ProjectViewSearchQuery{Key: ProjectViewSearchKeyResourceOwner, Method: model.SearchMethodEquals, Value: orgID})
|
||||
}
|
||||
|
||||
func (r *ProjectViewSearchRequest) EnsureLimit(limit uint64) {
|
||||
|
@ -80,7 +80,7 @@ func (es *ProjectEventstore) CreateProject(ctx context.Context, project *proj_mo
|
||||
return nil, err
|
||||
}
|
||||
project.AggregateID = id
|
||||
project.State = proj_model.PROJECTSTATE_ACTIVE
|
||||
project.State = proj_model.ProjectStateActive
|
||||
repoProject := model.ProjectFromModel(project)
|
||||
member := &model.ProjectMember{
|
||||
UserID: auth.GetCtxData(ctx).UserID,
|
||||
@ -658,7 +658,7 @@ func (es *ProjectEventstore) ChangeOIDCConfig(ctx context.Context, config *proj_
|
||||
if _, app = existing.GetApp(config.AppID); app == nil {
|
||||
return nil, caos_errs.ThrowPreconditionFailed(nil, "EVENT-dkso8", "Errors.Project.AppNoExisting")
|
||||
}
|
||||
if app.Type != proj_model.APPTYPE_OIDC {
|
||||
if app.Type != proj_model.AppTypeOIDC {
|
||||
return nil, caos_errs.ThrowPreconditionFailed(nil, "EVENT-98uje", "Errors.Project.AppIsNotOIDC")
|
||||
}
|
||||
repoProject := model.ProjectFromModel(existing)
|
||||
@ -688,7 +688,7 @@ func (es *ProjectEventstore) ChangeOIDCConfigSecret(ctx context.Context, project
|
||||
if _, app = existing.GetApp(appID); app == nil {
|
||||
return nil, caos_errs.ThrowPreconditionFailed(nil, "EVENT-9odi4", "Errors.Project.AppNotExisting")
|
||||
}
|
||||
if app.Type != proj_model.APPTYPE_OIDC {
|
||||
if app.Type != proj_model.AppTypeOIDC {
|
||||
return nil, caos_errs.ThrowPreconditionFailed(nil, "EVENT-dile4", "Errors.Project.AppIsNotOIDC")
|
||||
}
|
||||
repoProject := model.ProjectFromModel(existing)
|
||||
@ -726,7 +726,7 @@ func (es *ProjectEventstore) VerifyOIDCClientSecret(ctx context.Context, project
|
||||
if _, app = existing.GetApp(appID); app == nil {
|
||||
return caos_errs.ThrowPreconditionFailed(nil, "EVENT-D6hba", "Errors.Project.AppNoExisting")
|
||||
}
|
||||
if app.Type != proj_model.APPTYPE_OIDC {
|
||||
if app.Type != proj_model.AppTypeOIDC {
|
||||
return caos_errs.ThrowPreconditionFailed(nil, "EVENT-huywq", "Errors.Project.AppIsNotOIDC")
|
||||
}
|
||||
|
||||
|
@ -136,8 +136,8 @@ func GetMockManipulateProjectWithOIDCApp(ctrl *gomock.Controller) *ProjectEvents
|
||||
appData, _ := json.Marshal(model.Application{AppID: "AppID", Name: "Name"})
|
||||
oidcData, _ := json.Marshal(model.OIDCConfig{
|
||||
AppID: "AppID",
|
||||
ResponseTypes: []int32{int32(proj_model.OIDCRESPONSETYPE_CODE)},
|
||||
GrantTypes: []int32{int32(proj_model.OIDCGRANTTYPE_AUTHORIZATION_CODE)},
|
||||
ResponseTypes: []int32{int32(proj_model.OIDCResponseTypeCode)},
|
||||
GrantTypes: []int32{int32(proj_model.OIDCGrantTypeAuthorizationCode)},
|
||||
})
|
||||
events := []*es_models.Event{
|
||||
&es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: model.ProjectAdded, Data: data},
|
||||
|
@ -226,10 +226,10 @@ func TestDeactivateProject(t *testing.T) {
|
||||
args: args{
|
||||
es: GetMockManipulateProject(ctrl),
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name", State: model.PROJECTSTATE_ACTIVE},
|
||||
existing: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name", State: model.ProjectStateActive},
|
||||
},
|
||||
res: res{
|
||||
project: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "NameNew", State: model.PROJECTSTATE_INACTIVE},
|
||||
project: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "NameNew", State: model.ProjectStateInactive},
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -237,7 +237,7 @@ func TestDeactivateProject(t *testing.T) {
|
||||
args: args{
|
||||
es: GetMockManipulateInactiveProject(ctrl),
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name", State: model.PROJECTSTATE_INACTIVE},
|
||||
existing: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name", State: model.ProjectStateInactive},
|
||||
},
|
||||
res: res{
|
||||
wantErr: true,
|
||||
@ -249,7 +249,7 @@ func TestDeactivateProject(t *testing.T) {
|
||||
args: args{
|
||||
es: GetMockManipulateProjectNoEvents(ctrl),
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name", State: model.PROJECTSTATE_ACTIVE},
|
||||
existing: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name", State: model.ProjectStateActive},
|
||||
},
|
||||
res: res{
|
||||
wantErr: true,
|
||||
@ -297,10 +297,10 @@ func TestReactivateProject(t *testing.T) {
|
||||
args: args{
|
||||
es: GetMockManipulateInactiveProject(ctrl),
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name", State: model.PROJECTSTATE_INACTIVE},
|
||||
existing: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name", State: model.ProjectStateInactive},
|
||||
},
|
||||
res: res{
|
||||
project: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "NameNew", State: model.PROJECTSTATE_ACTIVE},
|
||||
project: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "NameNew", State: model.ProjectStateActive},
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -308,7 +308,7 @@ func TestReactivateProject(t *testing.T) {
|
||||
args: args{
|
||||
es: GetMockManipulateProject(ctrl),
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name", State: model.PROJECTSTATE_ACTIVE},
|
||||
existing: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name", State: model.ProjectStateActive},
|
||||
},
|
||||
res: res{
|
||||
wantErr: true,
|
||||
@ -320,7 +320,7 @@ func TestReactivateProject(t *testing.T) {
|
||||
args: args{
|
||||
es: GetMockManipulateProjectNoEvents(ctrl),
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name", State: model.PROJECTSTATE_ACTIVE},
|
||||
existing: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name", State: model.ProjectStateActive},
|
||||
},
|
||||
res: res{
|
||||
wantErr: true,
|
||||
@ -1041,8 +1041,8 @@ func TestAddApplication(t *testing.T) {
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
OIDCConfig: &model.OIDCConfig{
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_CODE},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGRANTTYPE_AUTHORIZATION_CODE},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeCode},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGrantTypeAuthorizationCode},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -1050,8 +1050,8 @@ func TestAddApplication(t *testing.T) {
|
||||
result: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
|
||||
Name: "Name",
|
||||
OIDCConfig: &model.OIDCConfig{
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_CODE},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGRANTTYPE_AUTHORIZATION_CODE},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeCode},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGrantTypeAuthorizationCode},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -1077,8 +1077,8 @@ func TestAddApplication(t *testing.T) {
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
OIDCConfig: &model.OIDCConfig{
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_CODE},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGRANTTYPE_AUTHORIZATION_CODE},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeCode},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGrantTypeAuthorizationCode},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -1143,8 +1143,8 @@ func TestChangeApp(t *testing.T) {
|
||||
AppID: "AppID",
|
||||
Name: "NameChanged",
|
||||
OIDCConfig: &model.OIDCConfig{
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_CODE},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGRANTTYPE_AUTHORIZATION_CODE},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeCode},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGrantTypeAuthorizationCode},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -1172,8 +1172,8 @@ func TestChangeApp(t *testing.T) {
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
OIDCConfig: &model.OIDCConfig{
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_CODE},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGRANTTYPE_AUTHORIZATION_CODE},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeCode},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGrantTypeAuthorizationCode},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -1191,8 +1191,8 @@ func TestChangeApp(t *testing.T) {
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
OIDCConfig: &model.OIDCConfig{
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_CODE},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGRANTTYPE_AUTHORIZATION_CODE},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeCode},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGrantTypeAuthorizationCode},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -1334,10 +1334,10 @@ func TestDeactivateApp(t *testing.T) {
|
||||
result: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
State: model.APPSTATE_INACTIVE,
|
||||
State: model.AppStateInactive,
|
||||
OIDCConfig: &model.OIDCConfig{
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_CODE},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGRANTTYPE_AUTHORIZATION_CODE},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeCode},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGrantTypeAuthorizationCode},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -1363,8 +1363,8 @@ func TestDeactivateApp(t *testing.T) {
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
OIDCConfig: &model.OIDCConfig{
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_CODE},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGRANTTYPE_AUTHORIZATION_CODE},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeCode},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGrantTypeAuthorizationCode},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -1382,8 +1382,8 @@ func TestDeactivateApp(t *testing.T) {
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
OIDCConfig: &model.OIDCConfig{
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_CODE},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGRANTTYPE_AUTHORIZATION_CODE},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeCode},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGrantTypeAuthorizationCode},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -1444,10 +1444,10 @@ func TestReactivateApp(t *testing.T) {
|
||||
result: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
State: model.APPSTATE_ACTIVE,
|
||||
State: model.AppStateActive,
|
||||
OIDCConfig: &model.OIDCConfig{
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_CODE},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGRANTTYPE_AUTHORIZATION_CODE},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeCode},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGrantTypeAuthorizationCode},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -1473,8 +1473,8 @@ func TestReactivateApp(t *testing.T) {
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
OIDCConfig: &model.OIDCConfig{
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_CODE},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGRANTTYPE_AUTHORIZATION_CODE},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeCode},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGrantTypeAuthorizationCode},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -1492,8 +1492,8 @@ func TestReactivateApp(t *testing.T) {
|
||||
AppID: "AppID",
|
||||
Name: "Name",
|
||||
OIDCConfig: &model.OIDCConfig{
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_CODE},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGRANTTYPE_AUTHORIZATION_CODE},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeCode},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGrantTypeAuthorizationCode},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -1548,16 +1548,16 @@ func TestChangeOIDCConfig(t *testing.T) {
|
||||
config: &model.OIDCConfig{
|
||||
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
|
||||
AppID: "AppID",
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_ID_TOKEN},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGRANTTYPE_IMPLICIT},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeIDToken},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGrantTypeImplicit},
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
result: &model.OIDCConfig{
|
||||
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
|
||||
AppID: "AppID",
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_ID_TOKEN},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGRANTTYPE_IMPLICIT},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeIDToken},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGrantTypeImplicit},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -1569,7 +1569,7 @@ func TestChangeOIDCConfig(t *testing.T) {
|
||||
config: &model.OIDCConfig{
|
||||
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
|
||||
AppID: "AppID",
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_ID_TOKEN},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeIDToken},
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
@ -1585,8 +1585,8 @@ func TestChangeOIDCConfig(t *testing.T) {
|
||||
config: &model.OIDCConfig{
|
||||
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
|
||||
AppID: "AppID",
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_ID_TOKEN},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGRANTTYPE_IMPLICIT},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeIDToken},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGrantTypeImplicit},
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
@ -1602,8 +1602,8 @@ func TestChangeOIDCConfig(t *testing.T) {
|
||||
config: &model.OIDCConfig{
|
||||
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
|
||||
AppID: "AppID",
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_ID_TOKEN},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGRANTTYPE_IMPLICIT},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeIDToken},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGrantTypeImplicit},
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
@ -1619,8 +1619,8 @@ func TestChangeOIDCConfig(t *testing.T) {
|
||||
config: &model.OIDCConfig{
|
||||
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
|
||||
AppID: "AppID",
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_ID_TOKEN},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGRANTTYPE_IMPLICIT},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeIDToken},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGrantTypeImplicit},
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
@ -1680,8 +1680,8 @@ func TestChangeOIDCConfigSecret(t *testing.T) {
|
||||
result: &model.OIDCConfig{
|
||||
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
|
||||
AppID: "AppID",
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCRESPONSETYPE_ID_TOKEN},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGRANTTYPE_IMPLICIT},
|
||||
ResponseTypes: []model.OIDCResponseType{model.OIDCResponseTypeIDToken},
|
||||
GrantTypes: []model.OIDCGrantType{model.OIDCGrantTypeImplicit},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -2059,7 +2059,7 @@ func TestDeactivateProjectGrant(t *testing.T) {
|
||||
res: res{
|
||||
result: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
|
||||
GrantID: "GrantID",
|
||||
State: model.PROJECTGRANTSTATE_INACTIVE,
|
||||
State: model.ProjectGrantStateInactive,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -2153,7 +2153,7 @@ func TestReactivateProjectGrant(t *testing.T) {
|
||||
res: res{
|
||||
result: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
|
||||
GrantID: "GrantID",
|
||||
State: model.PROJECTGRANTSTATE_ACTIVE,
|
||||
State: model.ProjectGrantStateActive,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -177,22 +177,22 @@ func TestAppendAppStateEvent(t *testing.T) {
|
||||
{
|
||||
name: "append deactivate application event",
|
||||
args: args{
|
||||
project: &Project{Applications: []*Application{&Application{AppID: "AppID", Name: "Application", State: int32(model.APPSTATE_ACTIVE)}}},
|
||||
project: &Project{Applications: []*Application{&Application{AppID: "AppID", Name: "Application", State: int32(model.AppStateActive)}}},
|
||||
app: &ApplicationID{AppID: "AppID"},
|
||||
event: &es_models.Event{},
|
||||
state: model.APPSTATE_INACTIVE,
|
||||
state: model.AppStateInactive,
|
||||
},
|
||||
result: &Project{Applications: []*Application{&Application{AppID: "AppID", Name: "Application", State: int32(model.APPSTATE_INACTIVE)}}},
|
||||
result: &Project{Applications: []*Application{&Application{AppID: "AppID", Name: "Application", State: int32(model.AppStateInactive)}}},
|
||||
},
|
||||
{
|
||||
name: "append reactivate application event",
|
||||
args: args{
|
||||
project: &Project{Applications: []*Application{&Application{AppID: "AppID", Name: "Application", State: int32(model.APPSTATE_INACTIVE)}}},
|
||||
project: &Project{Applications: []*Application{&Application{AppID: "AppID", Name: "Application", State: int32(model.AppStateInactive)}}},
|
||||
app: &ApplicationID{AppID: "AppID"},
|
||||
event: &es_models.Event{},
|
||||
state: model.APPSTATE_ACTIVE,
|
||||
state: model.AppStateActive,
|
||||
},
|
||||
result: &Project{Applications: []*Application{&Application{AppID: "AppID", Name: "Application", State: int32(model.APPSTATE_ACTIVE)}}},
|
||||
result: &Project{Applications: []*Application{&Application{AppID: "AppID", Name: "Application", State: int32(model.AppStateActive)}}},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
@ -100,7 +100,7 @@ func (p *Project) appendAddOIDCConfigEvent(event *es_models.Event) error {
|
||||
}
|
||||
config.ObjectRoot.CreationDate = event.CreationDate
|
||||
if i, a := GetApplication(p.Applications, config.AppID); a != nil {
|
||||
p.Applications[i].Type = int32(model.APPTYPE_OIDC)
|
||||
p.Applications[i].Type = int32(model.AppTypeOIDC)
|
||||
p.Applications[i].OIDCConfig = config
|
||||
}
|
||||
return nil
|
||||
|
@ -118,9 +118,9 @@ func (p *Project) AppendEvent(event *es_models.Event) error {
|
||||
case ApplicationRemoved:
|
||||
return p.appendRemoveAppEvent(event)
|
||||
case ApplicationDeactivated:
|
||||
return p.appendAppStateEvent(event, model.APPSTATE_INACTIVE)
|
||||
return p.appendAppStateEvent(event, model.AppStateInactive)
|
||||
case ApplicationReactivated:
|
||||
return p.appendAppStateEvent(event, model.APPSTATE_ACTIVE)
|
||||
return p.appendAppStateEvent(event, model.AppStateActive)
|
||||
case OIDCConfigAdded:
|
||||
return p.appendAddOIDCConfigEvent(event)
|
||||
case OIDCConfigChanged, OIDCConfigSecretChanged:
|
||||
@ -130,9 +130,9 @@ func (p *Project) AppendEvent(event *es_models.Event) error {
|
||||
case ProjectGrantChanged, ProjectGrantCascadeChanged:
|
||||
return p.appendChangeGrantEvent(event)
|
||||
case ProjectGrantDeactivated:
|
||||
return p.appendGrantStateEvent(event, model.PROJECTGRANTSTATE_INACTIVE)
|
||||
return p.appendGrantStateEvent(event, model.ProjectGrantStateInactive)
|
||||
case ProjectGrantReactivated:
|
||||
return p.appendGrantStateEvent(event, model.PROJECTGRANTSTATE_ACTIVE)
|
||||
return p.appendGrantStateEvent(event, model.ProjectGrantStateActive)
|
||||
case ProjectGrantRemoved:
|
||||
return p.appendRemoveGrantEvent(event)
|
||||
case ProjectGrantMemberAdded:
|
||||
@ -147,22 +147,22 @@ func (p *Project) AppendEvent(event *es_models.Event) error {
|
||||
|
||||
func (p *Project) AppendAddProjectEvent(event *es_models.Event) error {
|
||||
p.setData(event)
|
||||
p.State = int32(model.PROJECTSTATE_ACTIVE)
|
||||
p.State = int32(model.ProjectStateActive)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Project) appendDeactivatedEvent() error {
|
||||
p.State = int32(model.PROJECTSTATE_INACTIVE)
|
||||
p.State = int32(model.ProjectStateInactive)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Project) appendReactivatedEvent() error {
|
||||
p.State = int32(model.PROJECTSTATE_ACTIVE)
|
||||
p.State = int32(model.ProjectStateActive)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Project) appendRemovedEvent() error {
|
||||
p.State = int32(model.PROJECTSTATE_REMOVED)
|
||||
p.State = int32(model.ProjectStateRemoved)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -136,9 +136,9 @@ func TestAppendGrantStateEvent(t *testing.T) {
|
||||
project: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}}}},
|
||||
grant: &ProjectGrantID{GrantID: "GrantID"},
|
||||
event: &es_models.Event{},
|
||||
state: model.PROJECTGRANTSTATE_INACTIVE,
|
||||
state: model.ProjectGrantStateInactive,
|
||||
},
|
||||
result: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}, State: int32(model.PROJECTGRANTSTATE_INACTIVE)}}},
|
||||
result: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}, State: int32(model.ProjectGrantStateInactive)}}},
|
||||
},
|
||||
{
|
||||
name: "append reactivate grant event",
|
||||
@ -146,9 +146,9 @@ func TestAppendGrantStateEvent(t *testing.T) {
|
||||
project: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}}}},
|
||||
grant: &ProjectGrantID{GrantID: "GrantID"},
|
||||
event: &es_models.Event{},
|
||||
state: model.PROJECTGRANTSTATE_ACTIVE,
|
||||
state: model.ProjectGrantStateActive,
|
||||
},
|
||||
result: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}, State: int32(model.PROJECTGRANTSTATE_ACTIVE)}}},
|
||||
result: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}, State: int32(model.ProjectGrantStateActive)}}},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
@ -69,7 +69,7 @@ func TestProjectFromEvents(t *testing.T) {
|
||||
},
|
||||
project: &Project{Name: "ProjectName"},
|
||||
},
|
||||
result: &Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, State: int32(model.PROJECTSTATE_ACTIVE), Name: "ProjectName"},
|
||||
result: &Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, State: int32(model.ProjectStateActive), Name: "ProjectName"},
|
||||
},
|
||||
{
|
||||
name: "project from events, nil project",
|
||||
@ -79,7 +79,7 @@ func TestProjectFromEvents(t *testing.T) {
|
||||
},
|
||||
project: nil,
|
||||
},
|
||||
result: &Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, State: int32(model.PROJECTSTATE_ACTIVE)},
|
||||
result: &Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, State: int32(model.ProjectStateActive)},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
@ -112,7 +112,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: ProjectAdded},
|
||||
project: &Project{Name: "ProjectName"},
|
||||
},
|
||||
result: &Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, State: int32(model.PROJECTSTATE_ACTIVE), Name: "ProjectName"},
|
||||
result: &Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, State: int32(model.ProjectStateActive), Name: "ProjectName"},
|
||||
},
|
||||
{
|
||||
name: "append change event",
|
||||
@ -120,21 +120,21 @@ func TestAppendEvent(t *testing.T) {
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: ProjectChanged},
|
||||
project: &Project{Name: "ProjectName"},
|
||||
},
|
||||
result: &Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, State: int32(model.PROJECTSTATE_ACTIVE), Name: "ProjectName"},
|
||||
result: &Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, State: int32(model.ProjectStateActive), Name: "ProjectName"},
|
||||
},
|
||||
{
|
||||
name: "append deactivate event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: ProjectDeactivated},
|
||||
},
|
||||
result: &Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, State: int32(model.PROJECTSTATE_INACTIVE)},
|
||||
result: &Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, State: int32(model.ProjectStateInactive)},
|
||||
},
|
||||
{
|
||||
name: "append reactivate event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: ProjectReactivated},
|
||||
},
|
||||
result: &Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, State: int32(model.PROJECTSTATE_ACTIVE)},
|
||||
result: &Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, State: int32(model.ProjectStateActive)},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
@ -172,7 +172,7 @@ func TestAppendDeactivatedEvent(t *testing.T) {
|
||||
args: args{
|
||||
project: &Project{},
|
||||
},
|
||||
result: &Project{State: int32(model.PROJECTSTATE_INACTIVE)},
|
||||
result: &Project{State: int32(model.ProjectStateInactive)},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
@ -199,7 +199,7 @@ func TestAppendReactivatedEvent(t *testing.T) {
|
||||
args: args{
|
||||
project: &Project{},
|
||||
},
|
||||
result: &Project{State: int32(model.PROJECTSTATE_ACTIVE)},
|
||||
result: &Project{State: int32(model.ProjectStateActive)},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
@ -182,7 +182,7 @@ func TestProjectCreateAggregate(t *testing.T) {
|
||||
name: "project update aggregate ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
new: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
new: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
member: &model.ProjectMember{UserID: "UserID"},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -208,7 +208,7 @@ func TestProjectCreateAggregate(t *testing.T) {
|
||||
name: "new member nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
new: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
new: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
member: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -266,8 +266,8 @@ func TestProjectUpdateAggregate(t *testing.T) {
|
||||
name: "project update aggregate ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
new: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName_Changed", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName_Changed", State: int32(proj_model.ProjectStateActive)},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
res: res{
|
||||
@ -293,7 +293,7 @@ func TestProjectUpdateAggregate(t *testing.T) {
|
||||
name: "new project nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -346,7 +346,7 @@ func TestProjectDeactivateAggregate(t *testing.T) {
|
||||
name: "project deactivate aggregate ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
res: res{
|
||||
@ -407,7 +407,7 @@ func TestProjectReactivateAggregate(t *testing.T) {
|
||||
name: "project reactivate aggregate ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_INACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateInactive)},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
res: res{
|
||||
@ -469,7 +469,7 @@ func TestProjectMemberAddedAggregate(t *testing.T) {
|
||||
name: "projectmember added ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: &model.ProjectMember{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, UserID: "UserID", Roles: []string{"Roles"}},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -496,7 +496,7 @@ func TestProjectMemberAddedAggregate(t *testing.T) {
|
||||
name: "member nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -550,7 +550,7 @@ func TestProjectMemberChangedAggregate(t *testing.T) {
|
||||
name: "projectmember changed ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: &model.ProjectMember{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, UserID: "UserID", Roles: []string{"Roles"}},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -577,7 +577,7 @@ func TestProjectMemberChangedAggregate(t *testing.T) {
|
||||
name: "member nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -631,7 +631,7 @@ func TestProjectMemberRemovedAggregate(t *testing.T) {
|
||||
name: "projectmember removed ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: &model.ProjectMember{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, UserID: "UserID", Roles: []string{"Roles"}},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -658,7 +658,7 @@ func TestProjectMemberRemovedAggregate(t *testing.T) {
|
||||
name: "member nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -712,7 +712,7 @@ func TestProjectRoleAddedAggregate(t *testing.T) {
|
||||
name: "projectrole added ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: []*model.ProjectRole{&model.ProjectRole{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Key: "Key"}},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -725,7 +725,7 @@ func TestProjectRoleAddedAggregate(t *testing.T) {
|
||||
name: "projectrole multiple added ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: []*model.ProjectRole{
|
||||
&model.ProjectRole{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Key: "Key"},
|
||||
&model.ProjectRole{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Key: "Key2"},
|
||||
@ -755,7 +755,7 @@ func TestProjectRoleAddedAggregate(t *testing.T) {
|
||||
name: "member nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -809,7 +809,7 @@ func TestProjectRoleChangedAggregate(t *testing.T) {
|
||||
name: "projectmember changed ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: &model.ProjectRole{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Key: "Key"},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -836,7 +836,7 @@ func TestProjectRoleChangedAggregate(t *testing.T) {
|
||||
name: "member nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -891,7 +891,7 @@ func TestProjectRoleRemovedAggregate(t *testing.T) {
|
||||
name: "projectrole changed ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: &model.ProjectRole{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Key: "Key"},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -907,7 +907,7 @@ func TestProjectRoleRemovedAggregate(t *testing.T) {
|
||||
existing: &model.Project{
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
|
||||
Name: "ProjectName",
|
||||
State: int32(proj_model.PROJECTSTATE_ACTIVE),
|
||||
State: int32(proj_model.ProjectStateActive),
|
||||
Grants: []*model.ProjectGrant{&model.ProjectGrant{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"ROLE"}}},
|
||||
},
|
||||
new: &model.ProjectRole{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Key: "Key"},
|
||||
@ -935,7 +935,7 @@ func TestProjectRoleRemovedAggregate(t *testing.T) {
|
||||
name: "member nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -992,7 +992,7 @@ func TestProjectAppAddedAggregate(t *testing.T) {
|
||||
name: "add oidc application",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: &model.Application{
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
|
||||
AppID: "AppId",
|
||||
@ -1022,7 +1022,7 @@ func TestProjectAppAddedAggregate(t *testing.T) {
|
||||
name: "app nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -1082,7 +1082,7 @@ func TestProjectAppChangedAggregate(t *testing.T) {
|
||||
existing: &model.Project{
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
|
||||
Name: "ProjectName",
|
||||
State: int32(proj_model.PROJECTSTATE_ACTIVE),
|
||||
State: int32(proj_model.ProjectStateActive),
|
||||
Applications: []*model.Application{
|
||||
&model.Application{AppID: "AppID", Name: "Name"},
|
||||
}},
|
||||
@ -1114,7 +1114,7 @@ func TestProjectAppChangedAggregate(t *testing.T) {
|
||||
name: "app nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -1172,7 +1172,7 @@ func TestProjectAppRemovedAggregate(t *testing.T) {
|
||||
existing: &model.Project{
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
|
||||
Name: "ProjectName",
|
||||
State: int32(proj_model.PROJECTSTATE_ACTIVE),
|
||||
State: int32(proj_model.ProjectStateActive),
|
||||
Applications: []*model.Application{
|
||||
&model.Application{AppID: "AppID", Name: "Name"},
|
||||
}},
|
||||
@ -1204,7 +1204,7 @@ func TestProjectAppRemovedAggregate(t *testing.T) {
|
||||
name: "app nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -1262,7 +1262,7 @@ func TestProjectAppDeactivatedAggregate(t *testing.T) {
|
||||
existing: &model.Project{
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
|
||||
Name: "ProjectName",
|
||||
State: int32(proj_model.PROJECTSTATE_ACTIVE),
|
||||
State: int32(proj_model.ProjectStateActive),
|
||||
Applications: []*model.Application{
|
||||
&model.Application{AppID: "AppID", Name: "Name"},
|
||||
}},
|
||||
@ -1294,7 +1294,7 @@ func TestProjectAppDeactivatedAggregate(t *testing.T) {
|
||||
name: "app nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -1352,7 +1352,7 @@ func TestProjectAppReactivatedAggregate(t *testing.T) {
|
||||
existing: &model.Project{
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
|
||||
Name: "ProjectName",
|
||||
State: int32(proj_model.PROJECTSTATE_ACTIVE),
|
||||
State: int32(proj_model.ProjectStateActive),
|
||||
Applications: []*model.Application{
|
||||
&model.Application{AppID: "AppID", Name: "Name"},
|
||||
}},
|
||||
@ -1384,7 +1384,7 @@ func TestProjectAppReactivatedAggregate(t *testing.T) {
|
||||
name: "app nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -1442,7 +1442,7 @@ func TestOIDCConfigchangAggregate(t *testing.T) {
|
||||
existing: &model.Project{
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
|
||||
Name: "ProjectName",
|
||||
State: int32(proj_model.PROJECTSTATE_ACTIVE),
|
||||
State: int32(proj_model.ProjectStateActive),
|
||||
Applications: []*model.Application{
|
||||
&model.Application{AppID: "AppID", Name: "Name", OIDCConfig: &model.OIDCConfig{AppID: "AppID", AuthMethodType: 1}},
|
||||
}},
|
||||
@ -1474,7 +1474,7 @@ func TestOIDCConfigchangAggregate(t *testing.T) {
|
||||
name: "app nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -1532,7 +1532,7 @@ func TestOIDCConfigSecretChangeAggregate(t *testing.T) {
|
||||
existing: &model.Project{
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
|
||||
Name: "ProjectName",
|
||||
State: int32(proj_model.PROJECTSTATE_ACTIVE),
|
||||
State: int32(proj_model.ProjectStateActive),
|
||||
Applications: []*model.Application{
|
||||
&model.Application{AppID: "AppID", Name: "Name", OIDCConfig: &model.OIDCConfig{AppID: "AppID", AuthMethodType: 1}},
|
||||
}},
|
||||
@ -1610,7 +1610,7 @@ func TestProjectGrantAddedAggregate(t *testing.T) {
|
||||
name: "projectgrant added ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: &model.ProjectGrant{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, GrantID: "GrantID", GrantedOrgID: "OrgID"},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -1637,7 +1637,7 @@ func TestProjectGrantAddedAggregate(t *testing.T) {
|
||||
name: "grant nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -1694,7 +1694,7 @@ func TestProjectGrantChangedAggregate(t *testing.T) {
|
||||
existing: &model.Project{
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "ID"},
|
||||
Name: "ProjectName",
|
||||
State: int32(proj_model.PROJECTSTATE_ACTIVE),
|
||||
State: int32(proj_model.ProjectStateActive),
|
||||
Grants: []*model.ProjectGrant{
|
||||
&model.ProjectGrant{GrantID: "GrantID", GrantedOrgID: "GrantedOrgID", RoleKeys: []string{"Key"}},
|
||||
}},
|
||||
@ -1727,7 +1727,7 @@ func TestProjectGrantChangedAggregate(t *testing.T) {
|
||||
name: "projectgrant nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -1785,7 +1785,7 @@ func TestProjectGrantRemovedAggregate(t *testing.T) {
|
||||
existing: &model.Project{
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "ID"},
|
||||
Name: "ProjectName",
|
||||
State: int32(proj_model.PROJECTSTATE_ACTIVE),
|
||||
State: int32(proj_model.ProjectStateActive),
|
||||
Grants: []*model.ProjectGrant{
|
||||
&model.ProjectGrant{GrantID: "GrantID", GrantedOrgID: "GrantedOrgID"},
|
||||
}},
|
||||
@ -1818,7 +1818,7 @@ func TestProjectGrantRemovedAggregate(t *testing.T) {
|
||||
name: "projectgrant nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -1876,7 +1876,7 @@ func TestProjectGrantDeactivatedAggregate(t *testing.T) {
|
||||
existing: &model.Project{
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "ID"},
|
||||
Name: "ProjectName",
|
||||
State: int32(proj_model.PROJECTSTATE_ACTIVE),
|
||||
State: int32(proj_model.ProjectStateActive),
|
||||
Grants: []*model.ProjectGrant{
|
||||
&model.ProjectGrant{GrantID: "GrantID", GrantedOrgID: "GrantedOrgID"},
|
||||
}},
|
||||
@ -1909,7 +1909,7 @@ func TestProjectGrantDeactivatedAggregate(t *testing.T) {
|
||||
name: "grant nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -1967,7 +1967,7 @@ func TestProjectGrantReactivatedAggregate(t *testing.T) {
|
||||
existing: &model.Project{
|
||||
ObjectRoot: models.ObjectRoot{AggregateID: "ID"},
|
||||
Name: "ProjectName",
|
||||
State: int32(proj_model.PROJECTSTATE_INACTIVE),
|
||||
State: int32(proj_model.ProjectStateInactive),
|
||||
Grants: []*model.ProjectGrant{
|
||||
&model.ProjectGrant{GrantID: "GrantID", GrantedOrgID: "GrantedOrgID"},
|
||||
}},
|
||||
@ -2000,7 +2000,7 @@ func TestProjectGrantReactivatedAggregate(t *testing.T) {
|
||||
name: "grant nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_INACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateInactive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -2055,7 +2055,7 @@ func TestProjectGrantMemberAddedAggregate(t *testing.T) {
|
||||
name: "project grant member added ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: &model.ProjectGrantMember{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, GrantID: "GrantID", UserID: "UserID", Roles: []string{"Roles"}},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -2082,7 +2082,7 @@ func TestProjectGrantMemberAddedAggregate(t *testing.T) {
|
||||
name: "member nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -2136,7 +2136,7 @@ func TestProjectGrantMemberChangedAggregate(t *testing.T) {
|
||||
name: "project grant member changed ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: &model.ProjectGrantMember{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, UserID: "UserID", Roles: []string{"RolesChanged"}},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -2163,7 +2163,7 @@ func TestProjectGrantMemberChangedAggregate(t *testing.T) {
|
||||
name: "member nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -2217,7 +2217,7 @@ func TestProjectGrantMemberRemovedAggregate(t *testing.T) {
|
||||
name: "project grant member removed ok",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: &model.ProjectGrantMember{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, UserID: "UserID", Roles: []string{"Roles"}},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
@ -2244,7 +2244,7 @@ func TestProjectGrantMemberRemovedAggregate(t *testing.T) {
|
||||
name: "member nil",
|
||||
args: args{
|
||||
ctx: auth.NewMockContext("orgID", "userID"),
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.PROJECTSTATE_ACTIVE)},
|
||||
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
|
||||
new: nil,
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
|
@ -10,14 +10,14 @@ import (
|
||||
|
||||
func ApplicationByID(db *gorm.DB, table, appID string) (*model.ApplicationView, error) {
|
||||
app := new(model.ApplicationView)
|
||||
query := view.PrepareGetByKey(table, model.ApplicationSearchKey(proj_model.APPLICATIONSEARCHKEY_APP_ID), appID)
|
||||
query := view.PrepareGetByKey(table, model.ApplicationSearchKey(proj_model.AppSearchKeyAppID), appID)
|
||||
err := query(db, app)
|
||||
return app, err
|
||||
}
|
||||
|
||||
func ApplicationByOIDCClientID(db *gorm.DB, table, clientID string) (*model.ApplicationView, error) {
|
||||
app := new(model.ApplicationView)
|
||||
clientIDQuery := model.ApplicationSearchQuery{Key: proj_model.APPLICATIONSEARCHKEY_OIDC_CLIENT_ID, Value: clientID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
clientIDQuery := model.ApplicationSearchQuery{Key: proj_model.AppSearchKeyOIDCClientID, Value: clientID, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, clientIDQuery)
|
||||
err := query(db, app)
|
||||
return app, err
|
||||
@ -25,8 +25,8 @@ func ApplicationByOIDCClientID(db *gorm.DB, table, clientID string) (*model.Appl
|
||||
|
||||
func ApplicationByProjectIDAndAppName(db *gorm.DB, table, projectID, appName string) (*model.ApplicationView, error) {
|
||||
app := new(model.ApplicationView)
|
||||
projectIDQuery := model.ApplicationSearchQuery{Key: proj_model.APPLICATIONSEARCHKEY_PROJECT_ID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
appNameQuery := model.ApplicationSearchQuery{Key: proj_model.APPLICATIONSEARCHKEY_NAME, Value: appName, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
projectIDQuery := model.ApplicationSearchQuery{Key: proj_model.AppSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
||||
appNameQuery := model.ApplicationSearchQuery{Key: proj_model.AppSearchKeyName, Value: appName, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, projectIDQuery, appNameQuery)
|
||||
err := query(db, app)
|
||||
return app, err
|
||||
@ -45,6 +45,6 @@ func PutApplication(db *gorm.DB, table string, app *model.ApplicationView) error
|
||||
}
|
||||
|
||||
func DeleteApplication(db *gorm.DB, table, appID string) error {
|
||||
delete := view.PrepareDeleteByKey(table, model.ApplicationSearchKey(proj_model.APPLICATIONSEARCHKEY_APP_ID), appID)
|
||||
delete := view.PrepareDeleteByKey(table, model.ApplicationSearchKey(proj_model.AppSearchKeyAppID), appID)
|
||||
return delete(db)
|
||||
}
|
||||
|
@ -136,9 +136,9 @@ func (a *ApplicationView) AppendEvent(event *models.Event) (err error) {
|
||||
es_model.ApplicationChanged:
|
||||
err = a.SetData(event)
|
||||
case es_model.ApplicationDeactivated:
|
||||
a.State = int32(model.APPSTATE_INACTIVE)
|
||||
a.State = int32(model.AppStateInactive)
|
||||
case es_model.ApplicationReactivated:
|
||||
a.State = int32(model.APPSTATE_ACTIVE)
|
||||
a.State = int32(model.AppStateActive)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
|
||||
type ApplicationSearchRequest proj_model.ApplicationSearchRequest
|
||||
type ApplicationSearchQuery proj_model.ApplicationSearchQuery
|
||||
type ApplicationSearchKey proj_model.ApplicationSearchKey
|
||||
type ApplicationSearchKey proj_model.AppSearchKey
|
||||
|
||||
func (req ApplicationSearchRequest) GetLimit() uint64 {
|
||||
return req.Limit
|
||||
@ -19,7 +19,7 @@ func (req ApplicationSearchRequest) GetOffset() uint64 {
|
||||
}
|
||||
|
||||
func (req ApplicationSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
if req.SortingColumn == proj_model.APPLICATIONSEARCHKEY_UNSPECIFIED {
|
||||
if req.SortingColumn == proj_model.AppSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return ApplicationSearchKey(req.SortingColumn)
|
||||
@ -50,14 +50,14 @@ func (req ApplicationSearchQuery) GetValue() interface{} {
|
||||
}
|
||||
|
||||
func (key ApplicationSearchKey) ToColumnName() string {
|
||||
switch proj_model.ApplicationSearchKey(key) {
|
||||
case proj_model.APPLICATIONSEARCHKEY_APP_ID:
|
||||
switch proj_model.AppSearchKey(key) {
|
||||
case proj_model.AppSearchKeyAppID:
|
||||
return ApplicationKeyID
|
||||
case proj_model.APPLICATIONSEARCHKEY_NAME:
|
||||
case proj_model.AppSearchKeyName:
|
||||
return ApplicationKeyName
|
||||
case proj_model.APPLICATIONSEARCHKEY_PROJECT_ID:
|
||||
case proj_model.AppSearchKeyProjectID:
|
||||
return ApplicationKeyProjectID
|
||||
case proj_model.APPLICATIONSEARCHKEY_OIDC_CLIENT_ID:
|
||||
case proj_model.AppSearchKeyOIDCClientID:
|
||||
return ApplicationKeyOIDCClientID
|
||||
default:
|
||||
return ""
|
||||
|
@ -34,47 +34,47 @@ func TestApplicationAppendEvent(t *testing.T) {
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ApplicationAdded, Data: mockAppData(&es_model.Application{Name: "AppName"})},
|
||||
app: &ApplicationView{},
|
||||
},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.APPSTATE_ACTIVE)},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.AppStateActive)},
|
||||
},
|
||||
{
|
||||
name: "append changed app event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ApplicationChanged, Data: mockAppData(&es_model.Application{Name: "AppNameChanged"})},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.APPSTATE_ACTIVE)},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.AppStateActive)},
|
||||
},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppNameChanged", State: int32(model.APPSTATE_ACTIVE)},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppNameChanged", State: int32(model.AppStateActive)},
|
||||
},
|
||||
{
|
||||
name: "append deactivate app event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ApplicationDeactivated},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.APPSTATE_ACTIVE)},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.AppStateActive)},
|
||||
},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.APPSTATE_INACTIVE)},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.AppStateInactive)},
|
||||
},
|
||||
{
|
||||
name: "append reactivate app event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ApplicationReactivated},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.APPSTATE_INACTIVE)},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.AppStateInactive)},
|
||||
},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.APPSTATE_ACTIVE)},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.AppStateActive)},
|
||||
},
|
||||
{
|
||||
name: "append added oidc config event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.OIDCConfigAdded, Data: mockOIDCConfigData(&es_model.OIDCConfig{ClientID: "clientID"})},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.APPSTATE_ACTIVE)},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", State: int32(model.AppStateActive)},
|
||||
},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", IsOIDC: true, OIDCClientID: "clientID", State: int32(model.APPSTATE_ACTIVE)},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", IsOIDC: true, OIDCClientID: "clientID", State: int32(model.AppStateActive)},
|
||||
},
|
||||
{
|
||||
name: "append changed oidc config event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.OIDCConfigAdded, Data: mockOIDCConfigData(&es_model.OIDCConfig{ClientID: "clientIDChanged"})},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", OIDCClientID: "clientID", State: int32(model.APPSTATE_ACTIVE)},
|
||||
app: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", OIDCClientID: "clientID", State: int32(model.AppStateActive)},
|
||||
},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", IsOIDC: true, OIDCClientID: "clientIDChanged", State: int32(model.APPSTATE_ACTIVE)},
|
||||
result: &ApplicationView{ProjectID: "AggregateID", Name: "AppName", IsOIDC: true, OIDCClientID: "clientIDChanged", State: int32(model.AppStateActive)},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
@ -63,16 +63,16 @@ func (p *ProjectView) AppendEvent(event *models.Event) (err error) {
|
||||
p.Sequence = event.Sequence
|
||||
switch event.Type {
|
||||
case es_model.ProjectAdded:
|
||||
p.State = int32(model.PROJECTSTATE_ACTIVE)
|
||||
p.State = int32(model.ProjectStateActive)
|
||||
p.CreationDate = event.CreationDate
|
||||
p.setRootData(event)
|
||||
err = p.setData(event)
|
||||
case es_model.ProjectChanged:
|
||||
err = p.setData(event)
|
||||
case es_model.ProjectDeactivated:
|
||||
p.State = int32(model.PROJECTSTATE_INACTIVE)
|
||||
p.State = int32(model.ProjectStateInactive)
|
||||
case es_model.ProjectReactivated:
|
||||
p.State = int32(model.PROJECTSTATE_ACTIVE)
|
||||
p.State = int32(model.ProjectStateActive)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@ -88,16 +88,16 @@ func (p *ProjectGrantView) AppendEvent(event *models.Event) (err error) {
|
||||
p.Sequence = event.Sequence
|
||||
switch event.Type {
|
||||
case es_model.ProjectGrantAdded:
|
||||
p.State = int32(model.PROJECTSTATE_ACTIVE)
|
||||
p.State = int32(model.ProjectStateActive)
|
||||
p.CreationDate = event.CreationDate
|
||||
p.setRootData(event)
|
||||
err = p.setProjectGrantData(event)
|
||||
case es_model.ProjectGrantChanged, es_model.ProjectGrantCascadeChanged:
|
||||
err = p.setProjectGrantData(event)
|
||||
case es_model.ProjectGrantDeactivated:
|
||||
p.State = int32(model.PROJECTSTATE_INACTIVE)
|
||||
p.State = int32(model.ProjectStateInactive)
|
||||
case es_model.ProjectGrantReactivated:
|
||||
p.State = int32(model.PROJECTSTATE_ACTIVE)
|
||||
p.State = int32(model.ProjectStateActive)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ func (req ProjectGrantMemberSearchRequest) GetOffset() uint64 {
|
||||
}
|
||||
|
||||
func (req ProjectGrantMemberSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
if req.SortingColumn == proj_model.PROJECTGRANTMEMBERSEARCHKEY_UNSPECIFIED {
|
||||
if req.SortingColumn == proj_model.ProjectGrantMemberSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return ProjectGrantMemberSearchKey(req.SortingColumn)
|
||||
@ -51,17 +51,17 @@ func (req ProjectGrantMemberSearchQuery) GetValue() interface{} {
|
||||
|
||||
func (key ProjectGrantMemberSearchKey) ToColumnName() string {
|
||||
switch proj_model.ProjectGrantMemberSearchKey(key) {
|
||||
case proj_model.PROJECTGRANTMEMBERSEARCHKEY_EMAIL:
|
||||
case proj_model.ProjectGrantMemberSearchKeyEmail:
|
||||
return ProjectGrantMemberKeyEmail
|
||||
case proj_model.PROJECTGRANTMEMBERSEARCHKEY_FIRST_NAME:
|
||||
case proj_model.ProjectGrantMemberSearchKeyFirstName:
|
||||
return ProjectGrantMemberKeyFirstName
|
||||
case proj_model.PROJECTGRANTMEMBERSEARCHKEY_LAST_NAME:
|
||||
case proj_model.ProjectGrantMemberSearchKeyLastName:
|
||||
return ProjectGrantMemberKeyLastName
|
||||
case proj_model.PROJECTGRANTMEMBERSEARCHKEY_USER_NAME:
|
||||
case proj_model.ProjectGrantMemberSearchKeyUserName:
|
||||
return ProjectGrantMemberKeyUserName
|
||||
case proj_model.PROJECTGRANTMEMBERSEARCHKEY_USER_ID:
|
||||
case proj_model.ProjectGrantMemberSearchKeyUserID:
|
||||
return ProjectGrantMemberKeyUserID
|
||||
case proj_model.PROJECTGRANTMEMBERSEARCHKEY_GRANT_ID:
|
||||
case proj_model.ProjectGrantMemberSearchKeyGrantID:
|
||||
return ProjectGrantMemberKeyGrantID
|
||||
default:
|
||||
return ""
|
||||
|
@ -19,7 +19,7 @@ func (req ProjectGrantSearchRequest) GetOffset() uint64 {
|
||||
}
|
||||
|
||||
func (req ProjectGrantSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
if req.SortingColumn == proj_model.GRANTEDPROJECTSEARCHKEY_UNSPECIFIED {
|
||||
if req.SortingColumn == proj_model.GrantedProjectSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return ProjectGrantSearchKey(req.SortingColumn)
|
||||
@ -51,17 +51,17 @@ func (req ProjectGrantSearchQuery) GetValue() interface{} {
|
||||
|
||||
func (key ProjectGrantSearchKey) ToColumnName() string {
|
||||
switch proj_model.ProjectGrantViewSearchKey(key) {
|
||||
case proj_model.GRANTEDPROJECTSEARCHKEY_NAME:
|
||||
case proj_model.GrantedProjectSearchKeyName:
|
||||
return ProjectGrantKeyName
|
||||
case proj_model.GRANTEDPROJECTSEARCHKEY_GRANTID:
|
||||
case proj_model.GrantedProjectSearchKeyGrantID:
|
||||
return ProjectGrantKeyGrantID
|
||||
case proj_model.GRANTEDPROJECTSEARCHKEY_ORGID:
|
||||
case proj_model.GrantedProjectSearchKeyOrgID:
|
||||
return ProjectGrantKeyOrgID
|
||||
case proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID:
|
||||
case proj_model.GrantedProjectSearchKeyProjectID:
|
||||
return ProjectGrantKeyProjectID
|
||||
case proj_model.GRANTEDPROJECTSEARCHKEY_RESOURCE_OWNER:
|
||||
case proj_model.GrantedProjectSearchKeyResourceOwner:
|
||||
return ProjectGrantKeyResourceOwner
|
||||
case proj_model.GRANTEDPROJECTSEARCHKEY_ROLE_KEYS:
|
||||
case proj_model.GrantedProjectSearchKeyRoleKeys:
|
||||
return ProjectGrantKeyRoleKeys
|
||||
default:
|
||||
return ""
|
||||
|
@ -36,31 +36,31 @@ func TestProjectGrantAppendEvent(t *testing.T) {
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectGrantAdded, ResourceOwner: "OrgID", Data: mockProjectGrantData(&es_model.ProjectGrant{GrantID: "GrantID", GrantedOrgID: "GrantedOrgID", RoleKeys: pq.StringArray{"Role"}})},
|
||||
project: &ProjectGrantView{},
|
||||
},
|
||||
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.ProjectStateActive), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
},
|
||||
{
|
||||
name: "append change project grant event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectGrantChanged, ResourceOwner: "OrgID", Data: mockProjectGrantData(&es_model.ProjectGrant{GrantID: "GrantID", RoleKeys: pq.StringArray{"RoleChanged"}})},
|
||||
project: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
project: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.ProjectStateActive), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
},
|
||||
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"RoleChanged"}},
|
||||
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.ProjectStateActive), GrantedRoleKeys: pq.StringArray{"RoleChanged"}},
|
||||
},
|
||||
{
|
||||
name: "append deactivate project grant event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectGrantDeactivated, ResourceOwner: "OrgID", Data: mockProjectGrantData(&es_model.ProjectGrant{GrantID: "GrantID"})},
|
||||
project: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
project: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.ProjectStateActive), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
},
|
||||
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_INACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.ProjectStateInactive), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
},
|
||||
{
|
||||
name: "append reactivate project grant event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectGrantReactivated, ResourceOwner: "OrgID", Data: mockProjectGrantData(&es_model.ProjectGrant{GrantID: "GrantID"})},
|
||||
project: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_INACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
project: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.ProjectStateInactive), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
},
|
||||
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.ProjectStateActive), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
@ -19,7 +19,7 @@ func (req ProjectMemberSearchRequest) GetOffset() uint64 {
|
||||
}
|
||||
|
||||
func (req ProjectMemberSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
if req.SortingColumn == proj_model.PROJECTMEMBERSEARCHKEY_UNSPECIFIED {
|
||||
if req.SortingColumn == proj_model.ProjectMemberSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return ProjectMemberSearchKey(req.SortingColumn)
|
||||
@ -51,17 +51,17 @@ func (req ProjectMemberSearchQuery) GetValue() interface{} {
|
||||
|
||||
func (key ProjectMemberSearchKey) ToColumnName() string {
|
||||
switch proj_model.ProjectMemberSearchKey(key) {
|
||||
case proj_model.PROJECTMEMBERSEARCHKEY_EMAIL:
|
||||
case proj_model.ProjectMemberSearchKeyEmail:
|
||||
return ProjectMemberKeyEmail
|
||||
case proj_model.PROJECTMEMBERSEARCHKEY_FIRST_NAME:
|
||||
case proj_model.ProjectMemberSearchKeyFirstName:
|
||||
return ProjectMemberKeyFirstName
|
||||
case proj_model.PROJECTMEMBERSEARCHKEY_LAST_NAME:
|
||||
case proj_model.ProjectMemberSearchKeyLastName:
|
||||
return ProjectMemberKeyLastName
|
||||
case proj_model.PROJECTMEMBERSEARCHKEY_USER_NAME:
|
||||
case proj_model.ProjectMemberSearchKeyUserName:
|
||||
return ProjectMemberKeyUserName
|
||||
case proj_model.PROJECTMEMBERSEARCHKEY_USER_ID:
|
||||
case proj_model.ProjectMemberSearchKeyUserID:
|
||||
return ProjectMemberKeyUserID
|
||||
case proj_model.PROJECTMEMBERSEARCHKEY_PROJECT_ID:
|
||||
case proj_model.ProjectMemberSearchKeyProjectID:
|
||||
return ProjectMemberKeyProjectID
|
||||
default:
|
||||
return ""
|
||||
|
@ -19,7 +19,7 @@ func (req ProjectSearchRequest) GetOffset() uint64 {
|
||||
}
|
||||
|
||||
func (req ProjectSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
if req.SortingColumn == proj_model.PROJECTSEARCHKEY_UNSPECIFIED {
|
||||
if req.SortingColumn == proj_model.ProjectViewSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return ProjectSearchKey(req.SortingColumn)
|
||||
@ -51,11 +51,11 @@ func (req ProjectSearchQuery) GetValue() interface{} {
|
||||
|
||||
func (key ProjectSearchKey) ToColumnName() string {
|
||||
switch proj_model.ProjectViewSearchKey(key) {
|
||||
case proj_model.PROJECTSEARCHKEY_NAME:
|
||||
case proj_model.ProjectViewSearchKeyName:
|
||||
return ProjectKeyName
|
||||
case proj_model.PROJECTSEARCHKEY_PROJECTID:
|
||||
case proj_model.ProjectViewSearchKeyProjectID:
|
||||
return ProjectKeyProjectID
|
||||
case proj_model.PROJECTSEARCHKEY_RESOURCE_OWNER:
|
||||
case proj_model.ProjectViewSearchKeyResourceOwner:
|
||||
return ProjectKeyResourceOwner
|
||||
default:
|
||||
return ""
|
||||
|
@ -19,7 +19,7 @@ func (req ProjectRoleSearchRequest) GetOffset() uint64 {
|
||||
}
|
||||
|
||||
func (req ProjectRoleSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
if req.SortingColumn == proj_model.PROJECTROLESEARCHKEY_UNSPECIFIED {
|
||||
if req.SortingColumn == proj_model.ProjectRoleSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return ProjectRoleSearchKey(req.SortingColumn)
|
||||
@ -51,13 +51,13 @@ func (req ProjectRoleSearchQuery) GetValue() interface{} {
|
||||
|
||||
func (key ProjectRoleSearchKey) ToColumnName() string {
|
||||
switch proj_model.ProjectRoleSearchKey(key) {
|
||||
case proj_model.PROJECTROLESEARCHKEY_KEY:
|
||||
case proj_model.ProjectRoleSearchKeyKey:
|
||||
return ProjectRoleKeyKey
|
||||
case proj_model.PROJECTROLESEARCHKEY_ORGID:
|
||||
case proj_model.ProjectRoleSearchKeyOrgID:
|
||||
return ProjectRoleKeyOrgID
|
||||
case proj_model.PROJECTROLESEARCHKEY_PROJECTID:
|
||||
case proj_model.ProjectRoleSearchKeyProjectID:
|
||||
return ProjectRoleKeyProjectID
|
||||
case proj_model.PROJECTROLESEARCHKEY_RESOURCEOWNER:
|
||||
case proj_model.ProjectRoleSearchKeyResourceOwner:
|
||||
return ProjectRoleKeyResourceOwner
|
||||
default:
|
||||
return ""
|
||||
|
@ -23,31 +23,31 @@ func TestProjectAppendEvent(t *testing.T) {
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectAdded, ResourceOwner: "OrgID", Data: mockProjectData(&es_model.Project{Name: "ProjectName"})},
|
||||
project: &ProjectView{},
|
||||
},
|
||||
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_ACTIVE)},
|
||||
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.ProjectStateActive)},
|
||||
},
|
||||
{
|
||||
name: "append change project event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectChanged, ResourceOwner: "OrgID", Data: mockProjectData(&es_model.Project{Name: "ProjectNameChanged"})},
|
||||
project: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_ACTIVE)},
|
||||
project: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.ProjectStateActive)},
|
||||
},
|
||||
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectNameChanged", State: int32(model.PROJECTSTATE_ACTIVE)},
|
||||
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectNameChanged", State: int32(model.ProjectStateActive)},
|
||||
},
|
||||
{
|
||||
name: "append project deactivate event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectDeactivated, ResourceOwner: "OrgID"},
|
||||
project: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_ACTIVE)},
|
||||
project: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.ProjectStateActive)},
|
||||
},
|
||||
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_INACTIVE)},
|
||||
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.ProjectStateInactive)},
|
||||
},
|
||||
{
|
||||
name: "append project reactivate event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectReactivated, ResourceOwner: "OrgID"},
|
||||
project: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_INACTIVE)},
|
||||
project: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.ProjectStateInactive)},
|
||||
},
|
||||
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_ACTIVE)},
|
||||
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.ProjectStateActive)},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
@ -11,8 +11,8 @@ import (
|
||||
func ProjectGrantMemberByIDs(db *gorm.DB, table, grantID, userID string) (*model.ProjectGrantMemberView, error) {
|
||||
role := new(model.ProjectGrantMemberView)
|
||||
|
||||
grantIDQuery := model.ProjectGrantMemberSearchQuery{Key: proj_model.PROJECTGRANTMEMBERSEARCHKEY_GRANT_ID, Value: grantID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
userIDQuery := model.ProjectGrantMemberSearchQuery{Key: proj_model.PROJECTGRANTMEMBERSEARCHKEY_USER_ID, Value: userID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
grantIDQuery := model.ProjectGrantMemberSearchQuery{Key: proj_model.ProjectGrantMemberSearchKeyGrantID, Value: grantID, Method: global_model.SearchMethodEquals}
|
||||
userIDQuery := model.ProjectGrantMemberSearchQuery{Key: proj_model.ProjectGrantMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, grantIDQuery, userIDQuery)
|
||||
err := query(db, role)
|
||||
return role, err
|
||||
@ -31,7 +31,7 @@ func SearchProjectGrantMembers(db *gorm.DB, table string, req *proj_model.Projec
|
||||
func ProjectGrantMembersByUserID(db *gorm.DB, table, userID string) ([]*model.ProjectGrantMemberView, error) {
|
||||
members := make([]*model.ProjectGrantMemberView, 0)
|
||||
queries := []*proj_model.ProjectGrantMemberSearchQuery{
|
||||
&proj_model.ProjectGrantMemberSearchQuery{Key: proj_model.PROJECTGRANTMEMBERSEARCHKEY_USER_ID, Value: userID, Method: global_model.SEARCHMETHOD_EQUALS},
|
||||
&proj_model.ProjectGrantMemberSearchQuery{Key: proj_model.ProjectGrantMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.ProjectGrantMemberSearchRequest{Queries: queries})
|
||||
_, err := query(db, &members)
|
||||
|
@ -11,8 +11,8 @@ import (
|
||||
func ProjectGrantByProjectAndOrg(db *gorm.DB, table, projectID, orgID string) (*model.ProjectGrantView, error) {
|
||||
project := new(model.ProjectGrantView)
|
||||
|
||||
projectIDQuery := model.ProjectGrantSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
orgIDQuery := model.ProjectGrantSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_ORGID, Value: orgID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
projectIDQuery := model.ProjectGrantSearchQuery{Key: proj_model.GrantedProjectSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
||||
orgIDQuery := model.ProjectGrantSearchQuery{Key: proj_model.GrantedProjectSearchKeyOrgID, Value: orgID, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, projectIDQuery, orgIDQuery)
|
||||
err := query(db, project)
|
||||
return project, err
|
||||
@ -20,7 +20,7 @@ func ProjectGrantByProjectAndOrg(db *gorm.DB, table, projectID, orgID string) (*
|
||||
|
||||
func ProjectGrantByID(db *gorm.DB, table, grantID string) (*model.ProjectGrantView, error) {
|
||||
project := new(model.ProjectGrantView)
|
||||
grantIDQuery := model.ProjectGrantSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_GRANTID, Value: grantID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
grantIDQuery := model.ProjectGrantSearchQuery{Key: proj_model.GrantedProjectSearchKeyGrantID, Value: grantID, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, grantIDQuery)
|
||||
err := query(db, project)
|
||||
return project, err
|
||||
@ -29,7 +29,7 @@ func ProjectGrantByID(db *gorm.DB, table, grantID string) (*model.ProjectGrantVi
|
||||
func ProjectGrantsByProjectID(db *gorm.DB, table, projectID string) ([]*model.ProjectGrantView, error) {
|
||||
projects := make([]*model.ProjectGrantView, 0)
|
||||
queries := []*proj_model.ProjectGrantViewSearchQuery{
|
||||
&proj_model.ProjectGrantViewSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS},
|
||||
&proj_model.ProjectGrantViewSearchQuery{Key: proj_model.GrantedProjectSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.ProjectGrantSearchRequest{Queries: queries})
|
||||
_, err := query(db, &projects)
|
||||
@ -42,8 +42,8 @@ func ProjectGrantsByProjectID(db *gorm.DB, table, projectID string) ([]*model.Pr
|
||||
func ProjectGrantsByProjectIDAndRoleKey(db *gorm.DB, table, projectID, roleKey string) ([]*model.ProjectGrantView, error) {
|
||||
projects := make([]*model.ProjectGrantView, 0)
|
||||
queries := []*proj_model.ProjectGrantViewSearchQuery{
|
||||
&proj_model.ProjectGrantViewSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS},
|
||||
&proj_model.ProjectGrantViewSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_ROLE_KEYS, Value: roleKey, Method: global_model.SEARCHMETHOD_LIST_CONTAINS},
|
||||
&proj_model.ProjectGrantViewSearchQuery{Key: proj_model.GrantedProjectSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
||||
&proj_model.ProjectGrantViewSearchQuery{Key: proj_model.GrantedProjectSearchKeyRoleKeys, Value: roleKey, Method: global_model.SearchMethodListContains},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.ProjectGrantSearchRequest{Queries: queries})
|
||||
_, err := query(db, &projects)
|
||||
@ -69,6 +69,6 @@ func PutProjectGrant(db *gorm.DB, table string, project *model.ProjectGrantView)
|
||||
}
|
||||
|
||||
func DeleteProjectGrant(db *gorm.DB, table, grantID string) error {
|
||||
delete := view.PrepareDeleteByKey(table, model.ProjectSearchKey(proj_model.GRANTEDPROJECTSEARCHKEY_GRANTID), grantID)
|
||||
delete := view.PrepareDeleteByKey(table, model.ProjectSearchKey(proj_model.GrantedProjectSearchKeyGrantID), grantID)
|
||||
return delete(db)
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ import (
|
||||
func ProjectMemberByIDs(db *gorm.DB, table, projectID, userID string) (*model.ProjectMemberView, error) {
|
||||
role := new(model.ProjectMemberView)
|
||||
|
||||
projectIDQuery := model.ProjectMemberSearchQuery{Key: proj_model.PROJECTMEMBERSEARCHKEY_PROJECT_ID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
userIDQuery := model.ProjectMemberSearchQuery{Key: proj_model.PROJECTMEMBERSEARCHKEY_USER_ID, Value: userID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
projectIDQuery := model.ProjectMemberSearchQuery{Key: proj_model.ProjectMemberSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
||||
userIDQuery := model.ProjectMemberSearchQuery{Key: proj_model.ProjectMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, projectIDQuery, userIDQuery)
|
||||
err := query(db, role)
|
||||
return role, err
|
||||
@ -30,7 +30,7 @@ func SearchProjectMembers(db *gorm.DB, table string, req *proj_model.ProjectMemb
|
||||
func ProjectMembersByUserID(db *gorm.DB, table string, userID string) ([]*model.ProjectMemberView, error) {
|
||||
members := make([]*model.ProjectMemberView, 0)
|
||||
queries := []*proj_model.ProjectMemberSearchQuery{
|
||||
&proj_model.ProjectMemberSearchQuery{Key: proj_model.PROJECTMEMBERSEARCHKEY_USER_ID, Value: userID, Method: global_model.SEARCHMETHOD_EQUALS},
|
||||
&proj_model.ProjectMemberSearchQuery{Key: proj_model.ProjectMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.ProjectMemberSearchRequest{Queries: queries})
|
||||
_, err := query(db, &members)
|
||||
|
@ -11,9 +11,9 @@ import (
|
||||
func ProjectRoleByIDs(db *gorm.DB, table, projectID, orgID, key string) (*model.ProjectRoleView, error) {
|
||||
role := new(model.ProjectRoleView)
|
||||
|
||||
projectIDQuery := model.ProjectRoleSearchQuery{Key: proj_model.PROJECTROLESEARCHKEY_PROJECTID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
grantIDQuery := model.ProjectRoleSearchQuery{Key: proj_model.PROJECTROLESEARCHKEY_ORGID, Value: orgID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
keyQuery := model.ProjectRoleSearchQuery{Key: proj_model.PROJECTROLESEARCHKEY_KEY, Value: orgID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
projectIDQuery := model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
||||
grantIDQuery := model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyOrgID, Value: orgID, Method: global_model.SearchMethodEquals}
|
||||
keyQuery := model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyKey, Value: orgID, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, projectIDQuery, grantIDQuery, keyQuery)
|
||||
err := query(db, role)
|
||||
return role, err
|
||||
@ -22,9 +22,9 @@ func ProjectRoleByIDs(db *gorm.DB, table, projectID, orgID, key string) (*model.
|
||||
func ResourceOwnerProjectRolesByKey(db *gorm.DB, table, projectID, resourceOwner, key string) ([]*model.ProjectRoleView, error) {
|
||||
roles := make([]*model.ProjectRoleView, 0)
|
||||
queries := []*proj_model.ProjectRoleSearchQuery{
|
||||
&proj_model.ProjectRoleSearchQuery{Key: proj_model.PROJECTROLESEARCHKEY_PROJECTID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS},
|
||||
&proj_model.ProjectRoleSearchQuery{Key: proj_model.PROJECTROLESEARCHKEY_RESOURCEOWNER, Value: resourceOwner, Method: global_model.SEARCHMETHOD_EQUALS},
|
||||
&proj_model.ProjectRoleSearchQuery{Key: proj_model.PROJECTROLESEARCHKEY_KEY, Value: key, Method: global_model.SEARCHMETHOD_EQUALS},
|
||||
&proj_model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
||||
&proj_model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyResourceOwner, Value: resourceOwner, Method: global_model.SearchMethodEquals},
|
||||
&proj_model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyKey, Value: key, Method: global_model.SearchMethodEquals},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.ProjectRoleSearchRequest{Queries: queries})
|
||||
_, err := query(db, &roles)
|
||||
@ -37,8 +37,8 @@ func ResourceOwnerProjectRolesByKey(db *gorm.DB, table, projectID, resourceOwner
|
||||
func ResourceOwnerProjectRoles(db *gorm.DB, table, projectID, resourceOwner string) ([]*model.ProjectRoleView, error) {
|
||||
roles := make([]*model.ProjectRoleView, 0)
|
||||
queries := []*proj_model.ProjectRoleSearchQuery{
|
||||
&proj_model.ProjectRoleSearchQuery{Key: proj_model.PROJECTROLESEARCHKEY_PROJECTID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS},
|
||||
&proj_model.ProjectRoleSearchQuery{Key: proj_model.PROJECTROLESEARCHKEY_RESOURCEOWNER, Value: resourceOwner, Method: global_model.SEARCHMETHOD_EQUALS},
|
||||
&proj_model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
||||
&proj_model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyResourceOwner, Value: resourceOwner, Method: global_model.SearchMethodEquals},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.ProjectRoleSearchRequest{Queries: queries})
|
||||
_, err := query(db, &roles)
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
func ProjectByID(db *gorm.DB, table, projectID string) (*model.ProjectView, error) {
|
||||
project := new(model.ProjectView)
|
||||
|
||||
projectIDQuery := model.ProjectSearchQuery{Key: proj_model.PROJECTSEARCHKEY_PROJECTID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
projectIDQuery := model.ProjectSearchQuery{Key: proj_model.ProjectViewSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, projectIDQuery)
|
||||
err := query(db, project)
|
||||
return project, err
|
||||
@ -20,7 +20,7 @@ func ProjectByID(db *gorm.DB, table, projectID string) (*model.ProjectView, erro
|
||||
func ProjectsByResourceOwner(db *gorm.DB, table, orgID string) ([]*model.ProjectView, error) {
|
||||
projects := make([]*model.ProjectView, 0)
|
||||
queries := []*proj_model.ProjectViewSearchQuery{
|
||||
&proj_model.ProjectViewSearchQuery{Key: proj_model.PROJECTSEARCHKEY_RESOURCE_OWNER, Value: orgID, Method: global_model.SEARCHMETHOD_EQUALS},
|
||||
&proj_model.ProjectViewSearchQuery{Key: proj_model.ProjectViewSearchKeyResourceOwner, Value: orgID, Method: global_model.SearchMethodEquals},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.ProjectSearchRequest{Queries: queries})
|
||||
_, err := query(db, &projects)
|
||||
@ -46,6 +46,6 @@ func PutProject(db *gorm.DB, table string, project *model.ProjectView) error {
|
||||
}
|
||||
|
||||
func DeleteProject(db *gorm.DB, table, projectID string) error {
|
||||
delete := view.PrepareDeleteByKey(table, model.ProjectSearchKey(proj_model.PROJECTSEARCHKEY_PROJECTID), projectID)
|
||||
delete := view.PrepareDeleteByKey(table, model.ProjectSearchKey(proj_model.ProjectViewSearchKeyProjectID), projectID)
|
||||
return delete(db)
|
||||
}
|
||||
|
@ -31,13 +31,13 @@ type TokenSearchRequest struct {
|
||||
type TokenSearchKey int32
|
||||
|
||||
const (
|
||||
TOKENSEARCHKEY_UNSPECIFIED TokenSearchKey = iota
|
||||
TOKENSEARCHKEY_TOKEN_ID
|
||||
TOKENSEARCHKEY_USER_ID
|
||||
TOKENSEARCHKEY_APPLICATION_ID
|
||||
TOKENSEARCHKEY_USER_AGENT_ID
|
||||
TOKENSEARCHKEY_EXPIRATION
|
||||
TOKENSEARCHKEY_RESOURCEOWNER
|
||||
TokenSearchKeyUnspecified TokenSearchKey = iota
|
||||
TokenSearchKeyTokenID
|
||||
TokenSearchKeyUserID
|
||||
TokenSearchKeyApplicationID
|
||||
TokenSearchKeyUserAgentID
|
||||
TokenSearchKeyExpiration
|
||||
TokenSearchKeyResourceOwner
|
||||
)
|
||||
|
||||
type TokenSearchQuery struct {
|
||||
|
@ -19,7 +19,7 @@ func (req TokenSearchRequest) GetOffset() uint64 {
|
||||
}
|
||||
|
||||
func (req TokenSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
if req.SortingColumn == token_model.TOKENSEARCHKEY_UNSPECIFIED {
|
||||
if req.SortingColumn == token_model.TokenSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return TokenSearchKey(req.SortingColumn)
|
||||
@ -51,17 +51,17 @@ func (req TokenSearchQuery) GetValue() interface{} {
|
||||
|
||||
func (key TokenSearchKey) ToColumnName() string {
|
||||
switch token_model.TokenSearchKey(key) {
|
||||
case token_model.TOKENSEARCHKEY_TOKEN_ID:
|
||||
case token_model.TokenSearchKeyTokenID:
|
||||
return TokenKeyTokenID
|
||||
case token_model.TOKENSEARCHKEY_USER_AGENT_ID:
|
||||
case token_model.TokenSearchKeyUserAgentID:
|
||||
return TokenKeyUserAgentID
|
||||
case token_model.TOKENSEARCHKEY_USER_ID:
|
||||
case token_model.TokenSearchKeyUserID:
|
||||
return TokenKeyUserID
|
||||
case token_model.TOKENSEARCHKEY_APPLICATION_ID:
|
||||
case token_model.TokenSearchKeyApplicationID:
|
||||
return TokenKeyApplicationID
|
||||
case token_model.TOKENSEARCHKEY_EXPIRATION:
|
||||
case token_model.TokenSearchKeyExpiration:
|
||||
return TokenKeyExpiration
|
||||
case token_model.TOKENSEARCHKEY_RESOURCEOWNER:
|
||||
case token_model.TokenSearchKeyResourceOwner:
|
||||
return TokenKeyResourceOwner
|
||||
default:
|
||||
return ""
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user