diff --git a/internal/daemon/controller/handlers/host_catalogs/host_catalog_service.go b/internal/daemon/controller/handlers/host_catalogs/host_catalog_service.go index 93af971732..1e96304983 100644 --- a/internal/daemon/controller/handlers/host_catalogs/host_catalog_service.go +++ b/internal/daemon/controller/handlers/host_catalogs/host_catalog_service.go @@ -174,10 +174,6 @@ func (s Service) ListHostCatalogs(ctx context.Context, req *pbs.ListHostCatalogs if err != nil { return nil, errors.Wrap(ctx, err, op) } - // If no scopes match, return an empty response - if len(scopeIds) == 0 { - return &pbs.ListHostCatalogsResponse{}, nil - } pageSize := int(s.maxPageSize) // Use the requested page size only if it is smaller than // the configured max. diff --git a/internal/daemon/controller/handlers/host_catalogs/host_catalog_service_test.go b/internal/daemon/controller/handlers/host_catalogs/host_catalog_service_test.go index 92e9d69997..a7a6fcd629 100644 --- a/internal/daemon/controller/handlers/host_catalogs/host_catalog_service_test.go +++ b/internal/daemon/controller/handlers/host_catalogs/host_catalog_service_test.go @@ -886,6 +886,28 @@ func TestListPagination(t *testing.T) { protocmp.IgnoreFields(&pbs.ListHostCatalogsResponse{}, "list_token"), ), ) + + // Create unauthenticated user + unauthAt := authtoken.TestAuthToken(t, conn, kms, org.GetPublicId()) + unauthR := iam.TestRole(t, conn, proj.GetPublicId()) + _ = iam.TestUserRole(t, conn, unauthR.GetPublicId(), unauthAt.GetIamUserId()) + + // Make a request with the unauthenticated user, + // ensure the response contains the pagination parameters. + requestInfo = authpb.RequestInfo{ + TokenFormat: uint32(auth.AuthTokenTypeBearer), + PublicId: unauthAt.GetPublicId(), + Token: unauthAt.GetToken(), + } + requestContext = context.WithValue(context.Background(), requests.ContextRequestInformationKey, &requests.RequestContext{}) + ctx = auth.NewVerifierContext(requestContext, iamRepoFn, tokenRepoFn, serversRepoFn, kms, &requestInfo) + + _, err = s.ListHostCatalogs(ctx, &pbs.ListHostCatalogsRequest{ + ScopeId: "global", + Recursive: true, + }) + require.Error(t, err) + assert.ErrorIs(t, handlers.ForbiddenError(), err) } func TestDelete_Static(t *testing.T) {