diff --git a/internal/tests/cluster/anon_listing_test.go b/internal/tests/cluster/anon_listing_test.go index 88ee3fddd..03f4d1a0a 100644 --- a/internal/tests/cluster/anon_listing_test.go +++ b/internal/tests/cluster/anon_listing_test.go @@ -1,10 +1,8 @@ package cluster import ( - "fmt" "testing" - "github.com/hashicorp/boundary/api/roles" "github.com/hashicorp/boundary/api/scopes" "github.com/hashicorp/boundary/internal/cmd/config" "github.com/hashicorp/boundary/internal/servers/controller" @@ -29,31 +27,10 @@ func TestAnonListing(t *testing.T) { }) defer c1.Shutdown() - // Should get no scopes back because anon user doesn't have permissions + // Anon user has list and read permissions on scopes by default, + // verify that list scopes returns expected scope without setting token client := c1.Client() scps, err := scopes.NewClient(client).List(c1.Context(), scope.Global.String()) require.NoError(err) - require.Len(scps.Items, 0) - - // Authenticate as admin - client.SetToken(c1.Token().Token) - - // Should get an org scope back - scps, err = scopes.NewClient(client).List(c1.Context(), scope.Global.String()) - require.NoError(err) - require.Len(scps.Items, 1) - - // Create a new role, give read action on the scope, add u_anon - orgId := scps.Items[0].Id - role, err := roles.NewClient(client).Create(c1.Context(), scope.Global.String()) - require.NoError(err) - _, err = roles.NewClient(client).AddGrants(c1.Context(), role.Item.Id, 0, []string{fmt.Sprintf("id=%s;actions=read", orgId)}, roles.WithAutomaticVersioning(true)) - require.NoError(err) - _, err = roles.NewClient(client).AddPrincipals(c1.Context(), role.Item.Id, 0, []string{"u_anon"}, roles.WithAutomaticVersioning(true)) - require.NoError(err) - // Go back to anonymous - client.SetToken("") - scps, err = scopes.NewClient(client).List(c1.Context(), scope.Global.String()) - require.NoError(err) require.Len(scps.Items, 1) }