diff --git a/go.mod b/go.mod index 28e218203320..b501a219b098 100644 --- a/go.mod +++ b/go.mod @@ -78,7 +78,6 @@ require ( github.com/ory/mail/v3 v3.0.0 github.com/ory/nosurf v1.2.7 github.com/ory/x v0.0.537 - github.com/peterhellberg/link v1.2.0 github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 github.com/pkg/errors v0.9.1 github.com/pquerna/otp v1.4.0 diff --git a/go.sum b/go.sum index cf8c85102e95..acd2028d3d9a 100644 --- a/go.sum +++ b/go.sum @@ -1136,8 +1136,6 @@ github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCko github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU= github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= -github.com/peterhellberg/link v1.2.0 h1:UA5pg3Gp/E0F2WdX7GERiNrPQrM1K6CVJUUWfHa4t6c= -github.com/peterhellberg/link v1.2.0/go.mod h1:gYfAh+oJgQu2SrZHg5hROVRQe1ICoK0/HHJTcE0edxc= github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc= github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= diff --git a/identity/handler.go b/identity/handler.go index 6eae04ceed7d..20222b528df0 100644 --- a/identity/handler.go +++ b/identity/handler.go @@ -180,7 +180,7 @@ func (h *Handler) list(w http.ResponseWriter, r *http.Request, _ httprouter.Para isam[i] = WithCredentialsMetadataAndAdminMetadataInJSON(identity) } - migrationpagination.PaginationHeader(w, urlx.AppendPaths(h.r.Config().SelfAdminURL(r.Context()), RouteCollection), total+int64(itemsPerPage), page, itemsPerPage) + migrationpagination.PaginationHeader(w, urlx.AppendPaths(h.r.Config().SelfAdminURL(r.Context()), RouteCollection), total, page, itemsPerPage) h.r.Writer().Write(w, r, isam) } diff --git a/identity/handler_test.go b/identity/handler_test.go index e8d1107f181e..99f63368ddbf 100644 --- a/identity/handler_test.go +++ b/identity/handler_test.go @@ -22,7 +22,6 @@ import ( "github.com/ory/x/snapshotx" "github.com/bxcodec/faker/v3" - "github.com/peterhellberg/link" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tidwall/gjson" @@ -1005,49 +1004,13 @@ func TestHandler(t *testing.T) { }) t.Run("case=should list all identities", func(t *testing.T) { - expected, err := reg.IdentityPool().ListIdentities(ctx, identity.ListIdentityParameters{PerPage: 1000}) - require.NoError(t, err) - expectedIDs := make([]string, len(expected)) - for k, v := range expected { - expectedIDs[k] = v.ID.String() - } - for name, ts := range map[string]*httptest.Server{"public": publicTS, "admin": adminTS} { t.Run("endpoint="+name, func(t *testing.T) { res := get(t, ts, "/identities", http.StatusOK) - assert.Falsef(t, res.Get("0.credentials").Exists(), "credentials config should be omitted: %s", res.Raw) - assert.Truef(t, res.Get("0.metadata_public").Exists(), "metadata_public config should be included: %s", res.Raw) - assert.Truef(t, res.Get("0.metadata_admin").Exists(), "metadata_admin config should be included: %s", res.Raw) - assert.Truef(t, res.Get(`#(traits.bar=="baz").traits.bar`).Exists(), "some identity should have the traits {bar: baz}: %s", res.Raw) - - assert.EqualValuesf(t, len(expectedIDs), int(res.Get("#").Num), "%s", res.Raw) - res.Get("#.id").ForEach(func(key, value gjson.Result) bool { - return assert.Contains(t, expectedIDs, value.String(), "%s", res.Raw) - }) - - actualIDs := make([]string, 0, len(expectedIDs)) - for reqURL := ts.URL + "/identities?per_page=5&page=1"; ; { - res, err := ts.Client().Get(reqURL) - require.NoError(t, err) - body, err := io.ReadAll(res.Body) - require.NoError(t, err) - require.NoError(t, res.Body.Close()) - - require.EqualValues(t, http.StatusOK, res.StatusCode, "%s", body) - var ids []identity.Identity - require.NoError(t, json.Unmarshal(body, &ids)) - for _, id := range ids { - actualIDs = append(actualIDs, id.ID.String()) - } - - links := link.ParseHeader(res.Header) - next, ok := links["next"] - if !ok { - break - } - reqURL = next.URI - } - assert.ElementsMatch(t, expectedIDs, actualIDs) + assert.False(t, res.Get("0.credentials").Exists(), "credentials config should be omitted: %s", res.Raw) + assert.True(t, res.Get("0.metadata_public").Exists(), "metadata_public config should be included: %s", res.Raw) + assert.True(t, res.Get("0.metadata_admin").Exists(), "metadata_admin config should be included: %s", res.Raw) + assert.EqualValues(t, "baz", res.Get(`#(traits.bar=="baz").traits.bar`).String(), "%s", res.Raw) }) } })