Skip to content

Commit

Permalink
ran make gen
Browse files Browse the repository at this point in the history
  • Loading branch information
bosorawis committed Jan 3, 2025
1 parent e18100e commit fa1bac8
Showing 1 changed file with 51 additions and 44 deletions.
95 changes: 51 additions & 44 deletions internal/daemon/controller/handlers/groups/grants_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1

package groups_test

import (
Expand Down Expand Up @@ -156,7 +159,7 @@ func TestGrants_ReadActions(t *testing.T) {
wantErr: nil,
// TODO (Bo 20-dec-2024): expect 3 groups but only getting 1 back
// need to investigate further
//wantIDs: []string{globalGroup.PublicId, org1Group.PublicId, org2Group.PublicId},
// wantIDs: []string{globalGroup.PublicId, org1Group.PublicId, org2Group.PublicId},
wantIDs: []string{globalGroup.PublicId},
},
{
Expand Down Expand Up @@ -261,9 +264,9 @@ func TestGrants_ReadActions(t *testing.T) {
},
},
inputWantErrMap: map[*pbs.GetGroupRequest]error{
&pbs.GetGroupRequest{Id: globalGroup.PublicId}: nil,
&pbs.GetGroupRequest{Id: org1Group.PublicId}: handlers.ForbiddenError(),
&pbs.GetGroupRequest{Id: proj1Group.PublicId}: handlers.ForbiddenError(),
{Id: globalGroup.PublicId}: nil,
{Id: org1Group.PublicId}: handlers.ForbiddenError(),
{Id: proj1Group.PublicId}: handlers.ForbiddenError(),
},
},
{
Expand All @@ -276,9 +279,9 @@ func TestGrants_ReadActions(t *testing.T) {
},
},
inputWantErrMap: map[*pbs.GetGroupRequest]error{
&pbs.GetGroupRequest{Id: globalGroup.PublicId}: handlers.ForbiddenError(),
&pbs.GetGroupRequest{Id: org1Group.PublicId}: nil,
&pbs.GetGroupRequest{Id: proj1Group.PublicId}: handlers.ForbiddenError(),
{Id: globalGroup.PublicId}: handlers.ForbiddenError(),
{Id: org1Group.PublicId}: nil,
{Id: proj1Group.PublicId}: handlers.ForbiddenError(),
},
},
{
Expand All @@ -291,9 +294,9 @@ func TestGrants_ReadActions(t *testing.T) {
},
},
inputWantErrMap: map[*pbs.GetGroupRequest]error{
&pbs.GetGroupRequest{Id: globalGroup.PublicId}: handlers.ForbiddenError(),
&pbs.GetGroupRequest{Id: org1Group.PublicId}: nil,
&pbs.GetGroupRequest{Id: proj1Group.PublicId}: nil,
{Id: globalGroup.PublicId}: handlers.ForbiddenError(),
{Id: org1Group.PublicId}: nil,
{Id: proj1Group.PublicId}: nil,
},
},
{
Expand All @@ -306,9 +309,9 @@ func TestGrants_ReadActions(t *testing.T) {
},
},
inputWantErrMap: map[*pbs.GetGroupRequest]error{
&pbs.GetGroupRequest{Id: globalGroup.PublicId}: nil,
&pbs.GetGroupRequest{Id: org1Group.PublicId}: nil,
&pbs.GetGroupRequest{Id: proj1Group.PublicId}: handlers.ForbiddenError(),
{Id: globalGroup.PublicId}: nil,
{Id: org1Group.PublicId}: nil,
{Id: proj1Group.PublicId}: handlers.ForbiddenError(),
},
},
{
Expand All @@ -321,9 +324,9 @@ func TestGrants_ReadActions(t *testing.T) {
},
},
inputWantErrMap: map[*pbs.GetGroupRequest]error{
&pbs.GetGroupRequest{Id: globalGroup.PublicId}: nil,
&pbs.GetGroupRequest{Id: org1Group.PublicId}: nil,
&pbs.GetGroupRequest{Id: proj1Group.PublicId}: nil,
{Id: globalGroup.PublicId}: nil,
{Id: org1Group.PublicId}: nil,
{Id: proj1Group.PublicId}: nil,
},
},
{
Expand All @@ -336,9 +339,9 @@ func TestGrants_ReadActions(t *testing.T) {
},
},
inputWantErrMap: map[*pbs.GetGroupRequest]error{
&pbs.GetGroupRequest{Id: globalGroup.PublicId}: handlers.ForbiddenError(),
&pbs.GetGroupRequest{Id: org1Group.PublicId}: nil,
&pbs.GetGroupRequest{Id: proj1Group.PublicId}: handlers.ForbiddenError(),
{Id: globalGroup.PublicId}: handlers.ForbiddenError(),
{Id: org1Group.PublicId}: nil,
{Id: proj1Group.PublicId}: handlers.ForbiddenError(),
},
},
{
Expand All @@ -351,9 +354,9 @@ func TestGrants_ReadActions(t *testing.T) {
},
},
inputWantErrMap: map[*pbs.GetGroupRequest]error{
&pbs.GetGroupRequest{Id: globalGroup.PublicId}: handlers.ForbiddenError(),
&pbs.GetGroupRequest{Id: org1Group.PublicId}: handlers.ForbiddenError(),
&pbs.GetGroupRequest{Id: proj1Group.PublicId}: nil,
{Id: globalGroup.PublicId}: handlers.ForbiddenError(),
{Id: org1Group.PublicId}: handlers.ForbiddenError(),
{Id: proj1Group.PublicId}: nil,
},
},
{
Expand All @@ -366,9 +369,9 @@ func TestGrants_ReadActions(t *testing.T) {
},
},
inputWantErrMap: map[*pbs.GetGroupRequest]error{
&pbs.GetGroupRequest{Id: globalGroup.PublicId}: handlers.ForbiddenError(),
&pbs.GetGroupRequest{Id: org1Group.PublicId}: nil,
&pbs.GetGroupRequest{Id: proj1Group.PublicId}: nil,
{Id: globalGroup.PublicId}: handlers.ForbiddenError(),
{Id: org1Group.PublicId}: nil,
{Id: proj1Group.PublicId}: nil,
},
},
{
Expand All @@ -381,9 +384,9 @@ func TestGrants_ReadActions(t *testing.T) {
},
},
inputWantErrMap: map[*pbs.GetGroupRequest]error{
&pbs.GetGroupRequest{Id: globalGroup.PublicId}: handlers.ForbiddenError(),
&pbs.GetGroupRequest{Id: org1Group.PublicId}: handlers.ForbiddenError(),
&pbs.GetGroupRequest{Id: proj1Group.PublicId}: nil,
{Id: globalGroup.PublicId}: handlers.ForbiddenError(),
{Id: org1Group.PublicId}: handlers.ForbiddenError(),
{Id: proj1Group.PublicId}: nil,
},
},
{
Expand All @@ -396,9 +399,9 @@ func TestGrants_ReadActions(t *testing.T) {
},
},
inputWantErrMap: map[*pbs.GetGroupRequest]error{
&pbs.GetGroupRequest{Id: globalGroup.PublicId}: handlers.ForbiddenError(),
&pbs.GetGroupRequest{Id: org1Group.PublicId}: nil,
&pbs.GetGroupRequest{Id: proj1Group.PublicId}: handlers.ForbiddenError(),
{Id: globalGroup.PublicId}: handlers.ForbiddenError(),
{Id: org1Group.PublicId}: nil,
{Id: proj1Group.PublicId}: handlers.ForbiddenError(),
},
},
{
Expand All @@ -408,14 +411,15 @@ func TestGrants_ReadActions(t *testing.T) {
roleScopeID: globals.GlobalPrefix,
grantStrings: []string{
fmt.Sprintf("ids=%s;types=group;actions=read", org1Group.PublicId),
fmt.Sprintf("ids=%s;types=group;actions=read", proj1Group.PublicId)},
fmt.Sprintf("ids=%s;types=group;actions=read", proj1Group.PublicId),
},
grantScopes: []string{org1.PublicId, proj1.PublicId},
},
},
inputWantErrMap: map[*pbs.GetGroupRequest]error{
&pbs.GetGroupRequest{Id: globalGroup.PublicId}: handlers.ForbiddenError(),
&pbs.GetGroupRequest{Id: org1Group.PublicId}: nil,
&pbs.GetGroupRequest{Id: proj1Group.PublicId}: nil,
{Id: globalGroup.PublicId}: handlers.ForbiddenError(),
{Id: org1Group.PublicId}: nil,
{Id: proj1Group.PublicId}: nil,
},
},
{
Expand All @@ -425,14 +429,15 @@ func TestGrants_ReadActions(t *testing.T) {
roleScopeID: globals.GlobalPrefix,
grantStrings: []string{
fmt.Sprintf("ids=%s;types=group;actions=read", org1Group.PublicId),
fmt.Sprintf("ids=%s;types=group;actions=read", proj1Group.PublicId)},
fmt.Sprintf("ids=%s;types=group;actions=read", proj1Group.PublicId),
},
grantScopes: []string{org1.PublicId, proj1.PublicId},
},
},
inputWantErrMap: map[*pbs.GetGroupRequest]error{
&pbs.GetGroupRequest{Id: globalGroup.PublicId}: handlers.ForbiddenError(),
&pbs.GetGroupRequest{Id: org1Group.PublicId}: nil,
&pbs.GetGroupRequest{Id: proj1Group.PublicId}: nil,
{Id: globalGroup.PublicId}: handlers.ForbiddenError(),
{Id: org1Group.PublicId}: nil,
{Id: proj1Group.PublicId}: nil,
},
},
{
Expand All @@ -441,21 +446,23 @@ func TestGrants_ReadActions(t *testing.T) {
{
roleScopeID: globals.GlobalPrefix,
grantStrings: []string{
fmt.Sprintf("ids=%s;types=group;actions=read", globalGroup.PublicId)},
fmt.Sprintf("ids=%s;types=group;actions=read", globalGroup.PublicId),
},
grantScopes: []string{globals.GrantScopeThis},
},
{
roleScopeID: org1.GetPublicId(),
grantStrings: []string{
fmt.Sprintf("ids=%s;types=group;actions=read", org1Group.PublicId),
fmt.Sprintf("ids=%s;types=group;actions=read", proj1Group.PublicId)},
fmt.Sprintf("ids=%s;types=group;actions=read", proj1Group.PublicId),
},
grantScopes: []string{globals.GrantScopeThis, globals.GrantScopeChildren},
},
},
inputWantErrMap: map[*pbs.GetGroupRequest]error{
&pbs.GetGroupRequest{Id: globalGroup.PublicId}: nil,
&pbs.GetGroupRequest{Id: org1Group.PublicId}: nil,
&pbs.GetGroupRequest{Id: proj1Group.PublicId}: nil,
{Id: globalGroup.PublicId}: nil,
{Id: org1Group.PublicId}: nil,
{Id: proj1Group.PublicId}: nil,
},
},
}
Expand Down

0 comments on commit fa1bac8

Please sign in to comment.