diff --git a/internal/daemon/controller/handlers/groups/grants_test.go b/internal/daemon/controller/handlers/groups/grants_test.go index a95e1d3e4f0..ca2b799c003 100644 --- a/internal/daemon/controller/handlers/groups/grants_test.go +++ b/internal/daemon/controller/handlers/groups/grants_test.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + package groups_test import ( @@ -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}, }, { @@ -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(), }, }, { @@ -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(), }, }, { @@ -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, }, }, { @@ -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(), }, }, { @@ -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, }, }, { @@ -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(), }, }, { @@ -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, }, }, { @@ -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, }, }, { @@ -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, }, }, { @@ -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(), }, }, { @@ -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, }, }, { @@ -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, }, }, { @@ -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, }, }, }