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:
Fabi
2020-06-23 14:47:47 +02:00
committed by GitHub
parent c376b92315
commit 3cd3a238c2
152 changed files with 1026 additions and 1024 deletions

View File

@@ -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

View File

@@ -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},
},
},
},

View File

@@ -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{}
}

View File

@@ -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)
}
}
}

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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) {

View File

@@ -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})
}

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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")
}

View File

@@ -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},

View File

@@ -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,
},
},
},

View File

@@ -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 {

View File

@@ -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

View File

@@ -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
}

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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"),
},

View File

@@ -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)
}

View File

@@ -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
}

View File

@@ -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 ""

View File

@@ -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 {

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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 ""

View File

@@ -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 ""

View File

@@ -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 {

View File

@@ -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 ""

View File

@@ -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 ""

View File

@@ -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 ""

View File

@@ -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 {

View File

@@ -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)

View File

@@ -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)
}

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)
}