mirror of
https://github.com/zitadel/zitadel.git
synced 2025-11-15 14:43:12 +00:00
feat: user grants command side (#1191)
* fix: user grant command side * fix: user grant command side * fix: user grant command side check permissions * fix: unique constraint on user grants * fix: add usergrant * fix: add usergrant * fix: add usergrant * fix: user grant remove * Update internal/v2/command/auth_checks.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/v2/command/auth_checks.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/v2/command/project.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/v2/command/user_grant.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix: project events Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
@@ -22,10 +22,10 @@ func TestAppendAddGrantEvent(t *testing.T) {
|
||||
name: "append add grant event",
|
||||
args: args{
|
||||
project: &Project{},
|
||||
role: &ProjectGrant{GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}},
|
||||
role: &ProjectGrant{GrantID: "ProjectGrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}},
|
||||
event: &es_models.Event{},
|
||||
},
|
||||
result: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}}}},
|
||||
result: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "ProjectGrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}}}},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
@@ -59,11 +59,11 @@ func TestAppendChangeGrantEvent(t *testing.T) {
|
||||
{
|
||||
name: "append change grant event",
|
||||
args: args{
|
||||
project: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}}}},
|
||||
grant: &ProjectGrant{GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"KeyChanged"}},
|
||||
project: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "ProjectGrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}}}},
|
||||
grant: &ProjectGrant{GrantID: "ProjectGrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"KeyChanged"}},
|
||||
event: &es_models.Event{},
|
||||
},
|
||||
result: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"KeyChanged"}}}},
|
||||
result: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "ProjectGrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"KeyChanged"}}}},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
@@ -97,8 +97,8 @@ func TestAppendRemoveGrantEvent(t *testing.T) {
|
||||
{
|
||||
name: "append remove role event",
|
||||
args: args{
|
||||
project: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}}}},
|
||||
grant: &ProjectGrant{GrantID: "GrantID"},
|
||||
project: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "ProjectGrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}}}},
|
||||
grant: &ProjectGrant{GrantID: "ProjectGrantID"},
|
||||
event: &es_models.Event{},
|
||||
},
|
||||
result: &Project{Grants: []*ProjectGrant{}},
|
||||
@@ -133,22 +133,22 @@ func TestAppendGrantStateEvent(t *testing.T) {
|
||||
{
|
||||
name: "append deactivate grant event",
|
||||
args: args{
|
||||
project: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}}}},
|
||||
grant: &ProjectGrantID{GrantID: "GrantID"},
|
||||
project: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "ProjectGrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}}}},
|
||||
grant: &ProjectGrantID{GrantID: "ProjectGrantID"},
|
||||
event: &es_models.Event{},
|
||||
state: model.ProjectGrantStateInactive,
|
||||
},
|
||||
result: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}, State: int32(model.ProjectGrantStateInactive)}}},
|
||||
result: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "ProjectGrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}, State: int32(model.ProjectGrantStateInactive)}}},
|
||||
},
|
||||
{
|
||||
name: "append reactivate grant event",
|
||||
args: args{
|
||||
project: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}}}},
|
||||
grant: &ProjectGrantID{GrantID: "GrantID"},
|
||||
project: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "ProjectGrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}}}},
|
||||
grant: &ProjectGrantID{GrantID: "ProjectGrantID"},
|
||||
event: &es_models.Event{},
|
||||
state: model.ProjectGrantStateActive,
|
||||
},
|
||||
result: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "GrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}, State: int32(model.ProjectGrantStateActive)}}},
|
||||
result: &Project{Grants: []*ProjectGrant{&ProjectGrant{GrantID: "ProjectGrantID", GrantedOrgID: "OrgID", RoleKeys: []string{"Key"}, State: int32(model.ProjectGrantStateActive)}}},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
||||
Reference in New Issue
Block a user