feat: port reduction (#323)

* move mgmt pkg

* begin package restructure

* rename auth package to authz

* begin start api

* move auth

* move admin

* fix merge

* configs and interceptors

* interceptor

* revert generate-grpc.sh

* some cleanups

* console

* move console

* fix tests and merging

* js linting

* merge

* merging and configs

* change k8s base to current ports

* fixes

* cleanup

* regenerate proto

* remove unnecessary whitespace

* missing param

* go mod tidy

* fix merging

* move login pkg

* cleanup

* move api pkgs again

* fix pkg naming

* fix generate-static.sh for login

* update workflow

* fixes

* logging

* remove duplicate

* comment for optional gateway interfaces

* regenerate protos

* fix proto imports for grpc web

* protos

* grpc web generate

* grpc web generate

* fix changes

* add translation interceptor

* fix merging

* regenerate mgmt proto
This commit is contained in:
Livio Amstutz
2020-07-08 13:56:37 +02:00
committed by GitHub
parent 708652a655
commit 3549a8b64e
330 changed files with 30495 additions and 30809 deletions

View File

@@ -7,20 +7,20 @@ import (
"strings"
"github.com/caos/logging"
"github.com/caos/zitadel/internal/api/auth"
"github.com/caos/zitadel/internal/cache/config"
sd "github.com/caos/zitadel/internal/config/systemdefaults"
"github.com/caos/zitadel/internal/errors"
es_models "github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/project/repository/eventsourcing/model"
"github.com/golang/protobuf/ptypes"
"github.com/caos/zitadel/internal/api/authz"
"github.com/caos/zitadel/internal/cache/config"
sd "github.com/caos/zitadel/internal/config/systemdefaults"
"github.com/caos/zitadel/internal/crypto"
"github.com/caos/zitadel/internal/errors"
caos_errs "github.com/caos/zitadel/internal/errors"
es_int "github.com/caos/zitadel/internal/eventstore"
es_models "github.com/caos/zitadel/internal/eventstore/models"
es_sdk "github.com/caos/zitadel/internal/eventstore/sdk"
"github.com/caos/zitadel/internal/id"
proj_model "github.com/caos/zitadel/internal/project/model"
"github.com/caos/zitadel/internal/project/repository/eventsourcing/model"
)
const (
@@ -91,7 +91,7 @@ func (es *ProjectEventstore) CreateProject(ctx context.Context, project *proj_mo
project.State = proj_model.ProjectStateActive
repoProject := model.ProjectFromModel(project)
member := &model.ProjectMember{
UserID: auth.GetCtxData(ctx).UserID,
UserID: authz.GetCtxData(ctx).UserID,
Roles: []string{projectOwnerRole},
}

View File

@@ -5,7 +5,7 @@ import (
"encoding/json"
"testing"
"github.com/caos/zitadel/internal/api/auth"
"github.com/caos/zitadel/internal/api/authz"
caos_errs "github.com/caos/zitadel/internal/errors"
es_models "github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/project/model"
@@ -96,7 +96,7 @@ func TestCreateProject(t *testing.T) {
name: "create project, ok",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
project: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name"},
},
res: res{
@@ -107,7 +107,7 @@ func TestCreateProject(t *testing.T) {
name: "create project no name",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
project: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}},
},
res: res{
@@ -154,7 +154,7 @@ func TestUpdateProject(t *testing.T) {
name: "update project, ok",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
new: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "NameNew"},
},
res: res{
@@ -165,7 +165,7 @@ func TestUpdateProject(t *testing.T) {
name: "update project no name",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
new: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: ""},
},
res: res{
@@ -177,7 +177,7 @@ func TestUpdateProject(t *testing.T) {
name: "existing project not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
new: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "NameNew"},
},
res: res{
@@ -225,7 +225,7 @@ func TestDeactivateProject(t *testing.T) {
name: "deactivate project, ok",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name", State: model.ProjectStateActive},
},
res: res{
@@ -236,7 +236,7 @@ func TestDeactivateProject(t *testing.T) {
name: "deactivate project with inactive state",
args: args{
es: GetMockManipulateInactiveProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name", State: model.ProjectStateInactive},
},
res: res{
@@ -248,7 +248,7 @@ func TestDeactivateProject(t *testing.T) {
name: "existing not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name", State: model.ProjectStateActive},
},
res: res{
@@ -296,7 +296,7 @@ func TestReactivateProject(t *testing.T) {
name: "reactivate project, ok",
args: args{
es: GetMockManipulateInactiveProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name", State: model.ProjectStateInactive},
},
res: res{
@@ -307,7 +307,7 @@ func TestReactivateProject(t *testing.T) {
name: "reactivate project with inactive state",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name", State: model.ProjectStateActive},
},
res: res{
@@ -319,7 +319,7 @@ func TestReactivateProject(t *testing.T) {
name: "existing not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Name: "Name", State: model.ProjectStateActive},
},
res: res{
@@ -436,7 +436,7 @@ func TestAddProjectMember(t *testing.T) {
name: "add project member, ok",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, UserID: "UserID", Roles: []string{"Roles"}},
},
res: res{
@@ -447,7 +447,7 @@ func TestAddProjectMember(t *testing.T) {
name: "no userid",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Roles: []string{"Roles"}},
},
res: res{
@@ -459,7 +459,7 @@ func TestAddProjectMember(t *testing.T) {
name: "no roles",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, UserID: "UserID"},
},
res: res{
@@ -471,7 +471,7 @@ func TestAddProjectMember(t *testing.T) {
name: "member already existing",
args: args{
es: GetMockManipulateProjectWithMember(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, UserID: "UserID", Roles: []string{"Roles"}},
},
res: res{
@@ -483,7 +483,7 @@ func TestAddProjectMember(t *testing.T) {
name: "existing project not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, UserID: "UserID", Roles: []string{"Roles"}},
},
res: res{
@@ -533,7 +533,7 @@ func TestChangeProjectMember(t *testing.T) {
name: "add project member, ok",
args: args{
es: GetMockManipulateProjectWithMember(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, UserID: "UserID", Roles: []string{"ChangeRoles"}},
},
res: res{
@@ -544,7 +544,7 @@ func TestChangeProjectMember(t *testing.T) {
name: "no userid",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Roles: []string{"ChangeRoles"}},
},
res: res{
@@ -556,7 +556,7 @@ func TestChangeProjectMember(t *testing.T) {
name: "no roles",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, UserID: "UserID"},
},
res: res{
@@ -568,7 +568,7 @@ func TestChangeProjectMember(t *testing.T) {
name: "member not existing",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, UserID: "UserID", Roles: []string{"Roles"}},
},
res: res{
@@ -580,7 +580,7 @@ func TestChangeProjectMember(t *testing.T) {
name: "existing not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, UserID: "UserID", Roles: []string{"ChangeRoles"}},
},
res: res{
@@ -631,7 +631,7 @@ func TestRemoveProjectMember(t *testing.T) {
name: "remove project member, ok",
args: args{
es: GetMockManipulateProjectWithMember(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
Name: "Name",
@@ -647,7 +647,7 @@ func TestRemoveProjectMember(t *testing.T) {
name: "no userid",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
Name: "Name",
@@ -664,7 +664,7 @@ func TestRemoveProjectMember(t *testing.T) {
name: "member not existing",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
Name: "Name",
@@ -680,7 +680,7 @@ func TestRemoveProjectMember(t *testing.T) {
name: "existing not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, UserID: "UserID", Roles: []string{"ChangeRoles"}},
},
res: res{
@@ -724,7 +724,7 @@ func TestAddProjectRole(t *testing.T) {
name: "add project role, ok",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
roles: []*model.ProjectRole{&model.ProjectRole{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Key: "Key", DisplayName: "DisplayName", Group: "Group"}},
},
res: res{
@@ -735,7 +735,7 @@ func TestAddProjectRole(t *testing.T) {
name: "no key",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
roles: []*model.ProjectRole{&model.ProjectRole{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, DisplayName: "DisplayName", Group: "Group"}},
},
res: res{
@@ -747,7 +747,7 @@ func TestAddProjectRole(t *testing.T) {
name: "role already existing",
args: args{
es: GetMockManipulateProjectWithRole(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
roles: []*model.ProjectRole{&model.ProjectRole{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Key: "Key", DisplayName: "DisplayName", Group: "Group"}},
},
res: res{
@@ -759,7 +759,7 @@ func TestAddProjectRole(t *testing.T) {
name: "existing project not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
roles: []*model.ProjectRole{&model.ProjectRole{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Key: "Key", DisplayName: "DisplayName", Group: "Group"}},
},
res: res{
@@ -806,7 +806,7 @@ func TestChangeProjectRole(t *testing.T) {
name: "change project role, ok",
args: args{
es: GetMockManipulateProjectWithRole(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
role: &model.ProjectRole{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Key: "Key", DisplayName: "DisplayNameChanged", Group: "Group"},
},
res: res{
@@ -817,7 +817,7 @@ func TestChangeProjectRole(t *testing.T) {
name: "no key",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
role: &model.ProjectRole{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, DisplayName: "DisplayName", Group: "Group"},
},
res: res{
@@ -829,7 +829,7 @@ func TestChangeProjectRole(t *testing.T) {
name: "role not existing",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
role: &model.ProjectRole{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Key: "Key", DisplayName: "DisplayName", Group: "Group"},
},
res: res{
@@ -841,7 +841,7 @@ func TestChangeProjectRole(t *testing.T) {
name: "existing not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
role: &model.ProjectRole{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Key: "Key", DisplayName: "DisplayName", Group: "Group"},
},
res: res{
@@ -890,7 +890,7 @@ func TestRemoveProjectRole(t *testing.T) {
name: "remove project role, ok",
args: args{
es: GetMockManipulateProjectWithRole(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
role: &model.ProjectRole{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Key: "Key"},
},
},
@@ -898,7 +898,7 @@ func TestRemoveProjectRole(t *testing.T) {
name: "no key",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
role: &model.ProjectRole{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, DisplayName: "DisplayName", Group: "Group"},
},
res: res{
@@ -910,7 +910,7 @@ func TestRemoveProjectRole(t *testing.T) {
name: "role not existing",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
role: &model.ProjectRole{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Key: "Key", DisplayName: "DisplayName", Group: "Group"},
},
res: res{
@@ -922,7 +922,7 @@ func TestRemoveProjectRole(t *testing.T) {
name: "existing not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
role: &model.ProjectRole{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Key: "Key", DisplayName: "DisplayName", Group: "Group"},
},
res: res{
@@ -1036,7 +1036,7 @@ func TestAddApplication(t *testing.T) {
name: "add app, ok",
args: args{
es: GetMockManipulateProjectWithPw(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
AppID: "AppID",
Name: "Name",
@@ -1060,7 +1060,7 @@ func TestAddApplication(t *testing.T) {
name: "invalid app",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}},
},
res: res{
@@ -1072,7 +1072,7 @@ func TestAddApplication(t *testing.T) {
name: "existing project not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
AppID: "AppID",
Name: "Name",
@@ -1132,7 +1132,7 @@ func TestChangeApp(t *testing.T) {
name: "change app, ok",
args: args{
es: GetMockManipulateProjectWithOIDCApp(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
AppID: "AppID",
Name: "NameChanged",
@@ -1153,7 +1153,7 @@ func TestChangeApp(t *testing.T) {
name: "invalid app",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
AppID: "AppID",
},
@@ -1167,7 +1167,7 @@ func TestChangeApp(t *testing.T) {
name: "app not existing",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
AppID: "AppID",
Name: "Name",
@@ -1186,7 +1186,7 @@ func TestChangeApp(t *testing.T) {
name: "existing project not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
AppID: "AppID",
Name: "Name",
@@ -1242,7 +1242,7 @@ func TestRemoveApp(t *testing.T) {
name: "remove app, ok",
args: args{
es: GetMockManipulateProjectWithOIDCApp(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
AppID: "AppID",
},
@@ -1252,7 +1252,7 @@ func TestRemoveApp(t *testing.T) {
name: "no appID",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}},
},
res: res{
@@ -1264,7 +1264,7 @@ func TestRemoveApp(t *testing.T) {
name: "app not existing",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
AppID: "AppID",
},
@@ -1278,7 +1278,7 @@ func TestRemoveApp(t *testing.T) {
name: "existing project not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
AppID: "AppID",
},
@@ -1324,7 +1324,7 @@ func TestDeactivateApp(t *testing.T) {
name: "deactivate, ok",
args: args{
es: GetMockManipulateProjectWithOIDCApp(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
AppID: "AppID",
Name: "Name",
@@ -1346,7 +1346,7 @@ func TestDeactivateApp(t *testing.T) {
name: "no app id",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}},
},
res: res{
@@ -1358,7 +1358,7 @@ func TestDeactivateApp(t *testing.T) {
name: "app not existing",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
AppID: "AppID",
Name: "Name",
@@ -1377,7 +1377,7 @@ func TestDeactivateApp(t *testing.T) {
name: "existing project not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
AppID: "AppID",
Name: "Name",
@@ -1434,7 +1434,7 @@ func TestReactivateApp(t *testing.T) {
name: "reactivate, ok",
args: args{
es: GetMockManipulateProjectWithOIDCApp(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
AppID: "AppID",
Name: "Name",
@@ -1456,7 +1456,7 @@ func TestReactivateApp(t *testing.T) {
name: "no app id",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}},
},
res: res{
@@ -1468,7 +1468,7 @@ func TestReactivateApp(t *testing.T) {
name: "app not existing",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
AppID: "AppID",
Name: "Name",
@@ -1487,7 +1487,7 @@ func TestReactivateApp(t *testing.T) {
name: "existing project not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
app: &model.Application{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
AppID: "AppID",
Name: "Name",
@@ -1544,7 +1544,7 @@ func TestChangeOIDCConfig(t *testing.T) {
name: "change oidc config, ok",
args: args{
es: GetMockManipulateProjectWithOIDCApp(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
config: &model.OIDCConfig{
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
AppID: "AppID",
@@ -1565,7 +1565,7 @@ func TestChangeOIDCConfig(t *testing.T) {
name: "invalid config",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
config: &model.OIDCConfig{
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
AppID: "AppID",
@@ -1581,7 +1581,7 @@ func TestChangeOIDCConfig(t *testing.T) {
name: "app is not oidc",
args: args{
es: GetMockManipulateProjectWithSAMLApp(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
config: &model.OIDCConfig{
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
AppID: "AppID",
@@ -1598,7 +1598,7 @@ func TestChangeOIDCConfig(t *testing.T) {
name: "app not existing",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
config: &model.OIDCConfig{
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
AppID: "AppID",
@@ -1615,7 +1615,7 @@ func TestChangeOIDCConfig(t *testing.T) {
name: "existing project not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
config: &model.OIDCConfig{
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
AppID: "AppID",
@@ -1670,7 +1670,7 @@ func TestChangeOIDCConfigSecret(t *testing.T) {
name: "change oidc config secret, ok",
args: args{
es: GetMockManipulateProjectWithOIDCApp(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
config: &model.OIDCConfig{
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
AppID: "AppID",
@@ -1689,7 +1689,7 @@ func TestChangeOIDCConfigSecret(t *testing.T) {
name: "no appID",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
config: &model.OIDCConfig{
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
AppID: "AppID",
@@ -1704,7 +1704,7 @@ func TestChangeOIDCConfigSecret(t *testing.T) {
name: "app is not oidc",
args: args{
es: GetMockManipulateProjectWithSAMLApp(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
config: &model.OIDCConfig{
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
AppID: "AppID",
@@ -1719,7 +1719,7 @@ func TestChangeOIDCConfigSecret(t *testing.T) {
name: "app not existing",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
config: &model.OIDCConfig{
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
AppID: "AppID",
@@ -1734,7 +1734,7 @@ func TestChangeOIDCConfigSecret(t *testing.T) {
name: "existing project not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
config: &model.OIDCConfig{
ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 0},
AppID: "AppID",
@@ -1858,7 +1858,7 @@ func TestAddProjectGrant(t *testing.T) {
name: "add grant, ok",
args: args{
es: GetMockManipulateProjectWithRole(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
grant: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
GrantedOrgID: "GrantedOrgID",
@@ -1877,7 +1877,7 @@ func TestAddProjectGrant(t *testing.T) {
name: "invalid grant",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
grant: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
},
@@ -1891,7 +1891,7 @@ func TestAddProjectGrant(t *testing.T) {
name: "grant for org already exists",
args: args{
es: GetMockManipulateProjectWithGrant(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
grant: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
GrantedOrgID: "GrantedOrgID",
@@ -1906,7 +1906,7 @@ func TestAddProjectGrant(t *testing.T) {
name: "role not existing on project",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
grant: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
GrantedOrgID: "GrantedOrgID",
@@ -1922,7 +1922,7 @@ func TestAddProjectGrant(t *testing.T) {
name: "existing project not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
grant: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
GrantedOrgID: "GrantedOrgID",
@@ -1969,7 +1969,7 @@ func TestRemoveProjectGrant(t *testing.T) {
name: "remove app, ok",
args: args{
es: GetMockManipulateProjectWithGrant(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
grant: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
},
@@ -1979,7 +1979,7 @@ func TestRemoveProjectGrant(t *testing.T) {
name: "no grantID",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
grant: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1}},
},
res: res{
@@ -1991,7 +1991,7 @@ func TestRemoveProjectGrant(t *testing.T) {
name: "grant not existing",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
grant: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
},
@@ -2005,7 +2005,7 @@ func TestRemoveProjectGrant(t *testing.T) {
name: "existing project not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
grant: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
},
@@ -2051,7 +2051,7 @@ func TestDeactivateProjectGrant(t *testing.T) {
name: "deactivate, ok",
args: args{
es: GetMockManipulateProjectWithGrant(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
grant: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
},
@@ -2067,7 +2067,7 @@ func TestDeactivateProjectGrant(t *testing.T) {
name: "no grant id",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
grant: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1}},
},
res: res{
@@ -2079,7 +2079,7 @@ func TestDeactivateProjectGrant(t *testing.T) {
name: "grant not existing",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
grant: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
},
@@ -2093,7 +2093,7 @@ func TestDeactivateProjectGrant(t *testing.T) {
name: "existing project not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
grant: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
},
@@ -2145,7 +2145,7 @@ func TestReactivateProjectGrant(t *testing.T) {
name: "reactivate, ok",
args: args{
es: GetMockManipulateProjectWithGrant(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
grant: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
},
@@ -2161,7 +2161,7 @@ func TestReactivateProjectGrant(t *testing.T) {
name: "no grant id",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
grant: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1}},
},
res: res{
@@ -2173,7 +2173,7 @@ func TestReactivateProjectGrant(t *testing.T) {
name: "grant not existing",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
grant: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
},
@@ -2187,7 +2187,7 @@ func TestReactivateProjectGrant(t *testing.T) {
name: "existing project not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
grant: &model.ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
},
@@ -2309,7 +2309,7 @@ func TestAddProjectGrantMember(t *testing.T) {
name: "add project grant member",
args: args{
es: GetMockManipulateProjectWithGrantExistingRole(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectGrantMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
UserID: "UserID",
@@ -2328,7 +2328,7 @@ func TestAddProjectGrantMember(t *testing.T) {
name: "invalid member",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectGrantMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
Roles: []string{"Role"},
},
@@ -2342,7 +2342,7 @@ func TestAddProjectGrantMember(t *testing.T) {
name: "existing project not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectGrantMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
UserID: "UserID",
@@ -2358,7 +2358,7 @@ func TestAddProjectGrantMember(t *testing.T) {
name: "member already existing",
args: args{
es: GetMockManipulateProjectWithGrantMember(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectGrantMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
UserID: "UserID",
@@ -2409,7 +2409,7 @@ func TestChangeProjectGrantMember(t *testing.T) {
name: "change project grant member",
args: args{
es: GetMockManipulateProjectWithGrantMember(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectGrantMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
UserID: "UserID",
@@ -2428,7 +2428,7 @@ func TestChangeProjectGrantMember(t *testing.T) {
name: "invalid member",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectGrantMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
Roles: []string{"Role"},
},
@@ -2442,7 +2442,7 @@ func TestChangeProjectGrantMember(t *testing.T) {
name: "existing project not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectGrantMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
UserID: "UserID",
@@ -2458,7 +2458,7 @@ func TestChangeProjectGrantMember(t *testing.T) {
name: "user not member of grant",
args: args{
es: GetMockManipulateProjectWithGrant(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectGrantMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
UserID: "UserID",
@@ -2508,7 +2508,7 @@ func TestRemoveProjectGrantMember(t *testing.T) {
name: "remove project grant member",
args: args{
es: GetMockManipulateProjectWithGrantMember(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectGrantMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
UserID: "UserID",
@@ -2520,7 +2520,7 @@ func TestRemoveProjectGrantMember(t *testing.T) {
name: "invalid member",
args: args{
es: GetMockManipulateProject(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectGrantMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
Roles: []string{"Role"},
},
@@ -2534,7 +2534,7 @@ func TestRemoveProjectGrantMember(t *testing.T) {
name: "existing project not found",
args: args{
es: GetMockManipulateProjectNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectGrantMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
UserID: "UserID",
@@ -2550,7 +2550,7 @@ func TestRemoveProjectGrantMember(t *testing.T) {
name: "user not member of grant",
args: args{
es: GetMockManipulateProjectWithGrant(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
member: &model.ProjectGrantMember{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID", Sequence: 1},
GrantID: "GrantID",
UserID: "UserID",

View File

@@ -2,14 +2,14 @@ package eventsourcing
import (
"context"
"github.com/caos/zitadel/internal/crypto"
"github.com/caos/zitadel/internal/project/repository/eventsourcing/model"
"testing"
"github.com/caos/zitadel/internal/api/auth"
"github.com/caos/zitadel/internal/api/authz"
"github.com/caos/zitadel/internal/crypto"
caos_errs "github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/models"
proj_model "github.com/caos/zitadel/internal/project/model"
"github.com/caos/zitadel/internal/project/repository/eventsourcing/model"
)
func TestProjectByIDQuery(t *testing.T) {
@@ -120,7 +120,7 @@ func TestProjectAggregate(t *testing.T) {
{
name: "create aggregate",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
aggCreator: models.NewAggregateCreator("Test"),
project: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}},
},
@@ -132,7 +132,7 @@ func TestProjectAggregate(t *testing.T) {
{
name: "project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
aggCreator: models.NewAggregateCreator("Test"),
},
res: res{
@@ -181,7 +181,7 @@ func TestProjectCreateAggregate(t *testing.T) {
{
name: "project update aggregate ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
new: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
member: &model.ProjectMember{UserID: "UserID"},
aggCreator: models.NewAggregateCreator("Test"),
@@ -194,7 +194,7 @@ func TestProjectCreateAggregate(t *testing.T) {
{
name: "new project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
new: nil,
member: &model.ProjectMember{UserID: "UserID"},
aggCreator: models.NewAggregateCreator("Test"),
@@ -207,7 +207,7 @@ func TestProjectCreateAggregate(t *testing.T) {
{
name: "new member nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
new: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
member: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -227,7 +227,7 @@ func TestProjectCreateAggregate(t *testing.T) {
}
if !tt.res.wantErr {
for i, _ := range agg.Events {
for i := range agg.Events {
if !tt.res.wantErr && agg.Events[i].Type != tt.res.eventType[i] {
t.Errorf("got wrong event type: expected: %v, actual: %v ", tt.res.eventType, agg.Events[i].Type.String())
}
@@ -265,7 +265,7 @@ func TestProjectUpdateAggregate(t *testing.T) {
{
name: "project update aggregate ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
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"),
@@ -278,7 +278,7 @@ func TestProjectUpdateAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -292,7 +292,7 @@ func TestProjectUpdateAggregate(t *testing.T) {
{
name: "new project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -345,7 +345,7 @@ func TestProjectDeactivateAggregate(t *testing.T) {
{
name: "project deactivate aggregate ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -357,7 +357,7 @@ func TestProjectDeactivateAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -406,7 +406,7 @@ func TestProjectReactivateAggregate(t *testing.T) {
{
name: "project reactivate aggregate ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateInactive)},
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -418,7 +418,7 @@ func TestProjectReactivateAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -468,7 +468,7 @@ func TestProjectMemberAddedAggregate(t *testing.T) {
{
name: "projectmember added ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
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"),
@@ -481,7 +481,7 @@ func TestProjectMemberAddedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -495,7 +495,7 @@ func TestProjectMemberAddedAggregate(t *testing.T) {
{
name: "member nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -549,7 +549,7 @@ func TestProjectMemberChangedAggregate(t *testing.T) {
{
name: "projectmember changed ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
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"),
@@ -562,7 +562,7 @@ func TestProjectMemberChangedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -576,7 +576,7 @@ func TestProjectMemberChangedAggregate(t *testing.T) {
{
name: "member nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -630,7 +630,7 @@ func TestProjectMemberRemovedAggregate(t *testing.T) {
{
name: "projectmember removed ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
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"),
@@ -643,7 +643,7 @@ func TestProjectMemberRemovedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -657,7 +657,7 @@ func TestProjectMemberRemovedAggregate(t *testing.T) {
{
name: "member nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -711,9 +711,9 @@ func TestProjectRoleAddedAggregate(t *testing.T) {
{
name: "projectrole added ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
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"}},
new: []*model.ProjectRole{{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Key: "Key"}},
aggCreator: models.NewAggregateCreator("Test"),
},
res: res{
@@ -724,11 +724,11 @@ func TestProjectRoleAddedAggregate(t *testing.T) {
{
name: "projectrole multiple added ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
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"},
{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Key: "Key"},
{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Key: "Key2"},
},
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -740,7 +740,7 @@ func TestProjectRoleAddedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -754,7 +754,7 @@ func TestProjectRoleAddedAggregate(t *testing.T) {
{
name: "member nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -808,7 +808,7 @@ func TestProjectRoleChangedAggregate(t *testing.T) {
{
name: "projectmember changed ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
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"),
@@ -821,7 +821,7 @@ func TestProjectRoleChangedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -835,7 +835,7 @@ func TestProjectRoleChangedAggregate(t *testing.T) {
{
name: "member nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -890,7 +890,7 @@ func TestProjectRoleRemovedAggregate(t *testing.T) {
{
name: "projectrole changed ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
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"),
@@ -903,15 +903,15 @@ func TestProjectRoleRemovedAggregate(t *testing.T) {
{
name: "projectrole changed with grant",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
Name: "ProjectName",
State: int32(proj_model.ProjectStateActive),
Grants: []*model.ProjectGrant{&model.ProjectGrant{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"ROLE"}}},
Grants: []*model.ProjectGrant{{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"ROLE"}}},
},
new: &model.ProjectRole{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Key: "Key"},
grants: []*model.ProjectGrant{&model.ProjectGrant{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{}}},
grants: []*model.ProjectGrant{{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{}}},
aggCreator: models.NewAggregateCreator("Test"),
},
res: res{
@@ -922,7 +922,7 @@ func TestProjectRoleRemovedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -934,7 +934,7 @@ func TestProjectRoleRemovedAggregate(t *testing.T) {
{
name: "member nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -953,7 +953,7 @@ func TestProjectRoleRemovedAggregate(t *testing.T) {
t.Errorf("got wrong event len: expected: %v, actual: %v ", tt.res.eventLen, len(agg.Events))
}
if agg != nil {
for i, _ := range agg.Events {
for i := range agg.Events {
if !tt.res.wantErr && agg.Events[i].Type != tt.res.eventTypes[i] {
t.Errorf("got wrong event type: expected: %v, actual: %v ", tt.res.eventTypes[i], agg.Events[i].Type.String())
}
@@ -991,7 +991,7 @@ func TestProjectAppAddedAggregate(t *testing.T) {
{
name: "add oidc application",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: &model.Application{
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
@@ -1009,7 +1009,7 @@ func TestProjectAppAddedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -1021,7 +1021,7 @@ func TestProjectAppAddedAggregate(t *testing.T) {
{
name: "app nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -1078,13 +1078,13 @@ func TestProjectAppChangedAggregate(t *testing.T) {
{
name: "change app",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
Name: "ProjectName",
State: int32(proj_model.ProjectStateActive),
Applications: []*model.Application{
&model.Application{AppID: "AppID", Name: "Name"},
{AppID: "AppID", Name: "Name"},
}},
new: &model.Application{
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
@@ -1101,7 +1101,7 @@ func TestProjectAppChangedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -1113,7 +1113,7 @@ func TestProjectAppChangedAggregate(t *testing.T) {
{
name: "app nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -1168,13 +1168,13 @@ func TestProjectAppRemovedAggregate(t *testing.T) {
{
name: "remove app",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
Name: "ProjectName",
State: int32(proj_model.ProjectStateActive),
Applications: []*model.Application{
&model.Application{AppID: "AppID", Name: "Name"},
{AppID: "AppID", Name: "Name"},
}},
new: &model.Application{
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
@@ -1191,7 +1191,7 @@ func TestProjectAppRemovedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -1203,7 +1203,7 @@ func TestProjectAppRemovedAggregate(t *testing.T) {
{
name: "app nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -1258,13 +1258,13 @@ func TestProjectAppDeactivatedAggregate(t *testing.T) {
{
name: "deactivate app",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
Name: "ProjectName",
State: int32(proj_model.ProjectStateActive),
Applications: []*model.Application{
&model.Application{AppID: "AppID", Name: "Name"},
{AppID: "AppID", Name: "Name"},
}},
new: &model.Application{
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
@@ -1281,7 +1281,7 @@ func TestProjectAppDeactivatedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -1293,7 +1293,7 @@ func TestProjectAppDeactivatedAggregate(t *testing.T) {
{
name: "app nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -1348,13 +1348,13 @@ func TestProjectAppReactivatedAggregate(t *testing.T) {
{
name: "deactivate app",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
Name: "ProjectName",
State: int32(proj_model.ProjectStateActive),
Applications: []*model.Application{
&model.Application{AppID: "AppID", Name: "Name"},
{AppID: "AppID", Name: "Name"},
}},
new: &model.Application{
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
@@ -1371,7 +1371,7 @@ func TestProjectAppReactivatedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -1383,7 +1383,7 @@ func TestProjectAppReactivatedAggregate(t *testing.T) {
{
name: "app nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -1438,13 +1438,13 @@ func TestOIDCConfigchangAggregate(t *testing.T) {
{
name: "deactivate app",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
Name: "ProjectName",
State: int32(proj_model.ProjectStateActive),
Applications: []*model.Application{
&model.Application{AppID: "AppID", Name: "Name", OIDCConfig: &model.OIDCConfig{AppID: "AppID", AuthMethodType: 1}},
{AppID: "AppID", Name: "Name", OIDCConfig: &model.OIDCConfig{AppID: "AppID", AuthMethodType: 1}},
}},
new: &model.OIDCConfig{
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
@@ -1461,7 +1461,7 @@ func TestOIDCConfigchangAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -1473,7 +1473,7 @@ func TestOIDCConfigchangAggregate(t *testing.T) {
{
name: "app nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -1528,13 +1528,13 @@ func TestOIDCConfigSecretChangeAggregate(t *testing.T) {
{
name: "change client secret",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
Name: "ProjectName",
State: int32(proj_model.ProjectStateActive),
Applications: []*model.Application{
&model.Application{AppID: "AppID", Name: "Name", OIDCConfig: &model.OIDCConfig{AppID: "AppID", AuthMethodType: 1}},
{AppID: "AppID", Name: "Name", OIDCConfig: &model.OIDCConfig{AppID: "AppID", AuthMethodType: 1}},
}},
new: &model.OIDCConfig{
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
@@ -1551,7 +1551,7 @@ func TestOIDCConfigSecretChangeAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
new: &model.OIDCConfig{
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
@@ -1609,7 +1609,7 @@ func TestProjectGrantAddedAggregate(t *testing.T) {
{
name: "projectgrant added ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
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"),
@@ -1622,7 +1622,7 @@ func TestProjectGrantAddedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -1636,7 +1636,7 @@ func TestProjectGrantAddedAggregate(t *testing.T) {
{
name: "grant nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -1690,13 +1690,13 @@ func TestProjectGrantChangedAggregate(t *testing.T) {
{
name: "change project grant",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{
ObjectRoot: models.ObjectRoot{AggregateID: "ID"},
Name: "ProjectName",
State: int32(proj_model.ProjectStateActive),
Grants: []*model.ProjectGrant{
&model.ProjectGrant{GrantID: "GrantID", GrantedOrgID: "GrantedOrgID", RoleKeys: []string{"Key"}},
{GrantID: "GrantID", GrantedOrgID: "GrantedOrgID", RoleKeys: []string{"Key"}},
}},
new: &model.ProjectGrant{
ObjectRoot: models.ObjectRoot{AggregateID: "ID"},
@@ -1714,7 +1714,7 @@ func TestProjectGrantChangedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -1726,7 +1726,7 @@ func TestProjectGrantChangedAggregate(t *testing.T) {
{
name: "projectgrant nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -1781,13 +1781,13 @@ func TestProjectGrantRemovedAggregate(t *testing.T) {
{
name: "remove app",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{
ObjectRoot: models.ObjectRoot{AggregateID: "ID"},
Name: "ProjectName",
State: int32(proj_model.ProjectStateActive),
Grants: []*model.ProjectGrant{
&model.ProjectGrant{GrantID: "GrantID", GrantedOrgID: "GrantedOrgID"},
{GrantID: "GrantID", GrantedOrgID: "GrantedOrgID"},
}},
new: &model.ProjectGrant{
ObjectRoot: models.ObjectRoot{AggregateID: "ID"},
@@ -1805,7 +1805,7 @@ func TestProjectGrantRemovedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -1817,7 +1817,7 @@ func TestProjectGrantRemovedAggregate(t *testing.T) {
{
name: "projectgrant nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -1872,13 +1872,13 @@ func TestProjectGrantDeactivatedAggregate(t *testing.T) {
{
name: "deactivate project grant",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{
ObjectRoot: models.ObjectRoot{AggregateID: "ID"},
Name: "ProjectName",
State: int32(proj_model.ProjectStateActive),
Grants: []*model.ProjectGrant{
&model.ProjectGrant{GrantID: "GrantID", GrantedOrgID: "GrantedOrgID"},
{GrantID: "GrantID", GrantedOrgID: "GrantedOrgID"},
}},
new: &model.ProjectGrant{
ObjectRoot: models.ObjectRoot{AggregateID: "ID"},
@@ -1896,7 +1896,7 @@ func TestProjectGrantDeactivatedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -1908,7 +1908,7 @@ func TestProjectGrantDeactivatedAggregate(t *testing.T) {
{
name: "grant nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -1963,13 +1963,13 @@ func TestProjectGrantReactivatedAggregate(t *testing.T) {
{
name: "reactivate project grant",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{
ObjectRoot: models.ObjectRoot{AggregateID: "ID"},
Name: "ProjectName",
State: int32(proj_model.ProjectStateInactive),
Grants: []*model.ProjectGrant{
&model.ProjectGrant{GrantID: "GrantID", GrantedOrgID: "GrantedOrgID"},
{GrantID: "GrantID", GrantedOrgID: "GrantedOrgID"},
}},
new: &model.ProjectGrant{
ObjectRoot: models.ObjectRoot{AggregateID: "ID"},
@@ -1987,7 +1987,7 @@ func TestProjectGrantReactivatedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -1999,7 +1999,7 @@ func TestProjectGrantReactivatedAggregate(t *testing.T) {
{
name: "grant nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateInactive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -2054,7 +2054,7 @@ func TestProjectGrantMemberAddedAggregate(t *testing.T) {
{
name: "project grant member added ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
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"),
@@ -2067,7 +2067,7 @@ func TestProjectGrantMemberAddedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -2081,7 +2081,7 @@ func TestProjectGrantMemberAddedAggregate(t *testing.T) {
{
name: "member nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -2135,7 +2135,7 @@ func TestProjectGrantMemberChangedAggregate(t *testing.T) {
{
name: "project grant member changed ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
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"),
@@ -2148,7 +2148,7 @@ func TestProjectGrantMemberChangedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -2162,7 +2162,7 @@ func TestProjectGrantMemberChangedAggregate(t *testing.T) {
{
name: "member nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
@@ -2216,7 +2216,7 @@ func TestProjectGrantMemberRemovedAggregate(t *testing.T) {
{
name: "project grant member removed ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
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"),
@@ -2229,7 +2229,7 @@ func TestProjectGrantMemberRemovedAggregate(t *testing.T) {
{
name: "existing project nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -2243,7 +2243,7 @@ func TestProjectGrantMemberRemovedAggregate(t *testing.T) {
{
name: "member nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &model.Project{ObjectRoot: models.ObjectRoot{AggregateID: "ID"}, Name: "ProjectName", State: int32(proj_model.ProjectStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),