handlers: always return pagination parameters in list (#4373)

* handlers/targets: always return pagination parameters in list

* handlers/authmethods: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/accounts: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/authtokens: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/credentiallibraries: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/credentials: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/credentialstores: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/groups: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/host_catalogs: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/host_sets: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/hosts: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/managed_groups: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/roles: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/scopes: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/sessions: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.

* handlers/users: test for pagination parameters

Note that this already always returned the pagination parameters,
but now we have a test that it does so.
This commit is contained in:
Johan Brandhorst-Satzkorn authored and GitHub committed 2024-02-15 09:26:29 -08:00
1 parent 4068829509
commit e95eda7ca2
24 files changed
+471 -33

No files matched your search

@@ -114,10 +114,6 @@ func (s Service) ListGroups(ctx context.Context, req *pbs.ListGroupsRequest) (*p
if err != nil {
return nil, err
}
// If no scopes match, return an empty response
if len(scopeIds) == 0 {
return &pbs.ListGroupsResponse{}, nil
}
pageSize := int(s.maxPageSize)
// Use the requested page size only if it is smaller than
@@ -801,6 +801,28 @@ func TestListPagination(t *testing.T) {
protocmp.IgnoreFields(&pbs.ListGroupsResponse{}, "list_token"),
),
)
// Create unauthenticated user
unauthAt := authtoken.TestAuthToken(t, conn, kms, oWithGroups.GetPublicId())
unauthR := iam.TestRole(t, conn, pWithGroups.GetPublicId())
_ = iam.TestUserRole(t, conn, unauthR.GetPublicId(), unauthAt.GetIamUserId())
// Make a request with the unauthenticated user,
// ensure the response is 403 forbidden.
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 = a.ListGroups(ctx, &pbs.ListGroupsRequest{
ScopeId: "global",
Recursive: true,
})
require.Error(t, err)
assert.Equal(t, handlers.ForbiddenError(), err)
}
func TestDelete(t *testing.T) {