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.
pull/4373/head
Johan Brandhorst-Satzkorn 2 years ago
parent c9c086dd6d
commit fd959d15a6

@ -103,10 +103,6 @@ func (s Service) ListAuthTokens(ctx context.Context, req *pbs.ListAuthTokensRequ
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
// If no scopes match, return an empty response
if len(scopeIds) == 0 {
return &pbs.ListAuthTokensResponse{}, nil
}
pageSize := int(s.maxPageSize)
// Use the requested page size only if it is smaller than

@ -790,6 +790,31 @@ func TestListPagination(t *testing.T) {
protocmp.IgnoreFields(&pbs.ListAuthTokensResponse{}, "list_token"),
),
)
// Create unauthenticated user
unauthAt := authtoken.TestAuthToken(t, conn, kms, orgWithTokens.GetPublicId())
unauthR := iam.TestRole(t, conn, pwt.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)
got, err = a.ListAuthTokens(ctx, &pbs.ListAuthTokensRequest{
ScopeId: "global",
Recursive: true,
})
require.NoError(t, err)
assert.Len(t, got.Items, 1) // There will always be at least one token, the token used to authenticate
assert.Equal(t, "created_time", got.SortBy)
assert.Equal(t, "desc", got.SortDir)
assert.Equal(t, "complete", got.ResponseType)
}
func TestDeleteSelf(t *testing.T) {

Loading…
Cancel
Save