backport of commit 5d42c35e84

pull/4419/head
Johan Brandhorst-Satzkorn 2 years ago
parent 59ff4e1afd
commit 855d634be6

@ -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.

@ -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) {

Loading…
Cancel
Save