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.
pull/4373/head
Johan Brandhorst-Satzkorn 2 years ago
parent 1010cf2b31
commit 1bbe510384

@ -997,6 +997,27 @@ func TestListPagination(t *testing.T) {
protocmp.IgnoreFields(&pbs.ListManagedGroupsResponse{}, "list_token"),
),
)
// Create unauthenticated user
unauthAt := authtoken.TestAuthToken(t, conn, kmsCache, o.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, kmsCache, &requestInfo)
_, err = s.ListManagedGroups(ctx, &pbs.ListManagedGroupsRequest{
AuthMethodId: authMethod.GetPublicId(),
})
require.Error(t, err)
assert.ErrorIs(t, handlers.ForbiddenError(), err)
})
t.Run("ldap", func(t *testing.T) {
@ -1296,6 +1317,27 @@ func TestListPagination(t *testing.T) {
protocmp.IgnoreFields(&pbs.ListManagedGroupsResponse{}, "list_token"),
),
)
// Create unauthenticated user
unauthAt := authtoken.TestAuthToken(t, conn, kmsCache, o.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, kmsCache, &requestInfo)
_, err = s.ListManagedGroups(ctx, &pbs.ListManagedGroupsRequest{
AuthMethodId: authMethod.GetPublicId(),
})
require.Error(t, err)
assert.ErrorIs(t, handlers.ForbiddenError(), err)
})
}

Loading…
Cancel
Save