-
Notifications
You must be signed in to change notification settings - Fork 970
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow listing identities by organization ID (#4115)
- Loading branch information
1 parent
4d5f644
commit b4c453b
Showing
11 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1472,6 +1472,44 @@ func TestHandler(t *testing.T) { | |
} | ||
}) | ||
|
||
t.Run("organizations", func(t *testing.T) { | ||
t.Run("case=should list organization identities", func(t *testing.T) { | ||
for name, ts := range map[string]*httptest.Server{"admin": adminTS} { | ||
t.Run("endpoint="+name, func(t *testing.T) { | ||
orgID := uuid.Must(uuid.NewV4()) | ||
email := x.NewUUID().String() + "@ory.sh" | ||
reg.IdentityManager().Create(ctx, &identity.Identity{ | ||
Traits: identity.Traits(`{"email":"` + email + `"}`), | ||
OrganizationID: uuid.NullUUID{UUID: orgID, Valid: true}, | ||
}) | ||
|
||
res := get(t, ts, "/identities?organization_id="+orgID.String(), http.StatusOK) | ||
assert.Len(t, res.Array(), 1) | ||
assert.EqualValues(t, email, res.Get(`0.traits.email`).String(), "%s", res.Raw) | ||
}) | ||
} | ||
}) | ||
|
||
t.Run("case=malformed organization id should return an error", func(t *testing.T) { | ||
for name, ts := range map[string]*httptest.Server{"admin": adminTS} { | ||
t.Run("endpoint="+name, func(t *testing.T) { | ||
res := get(t, ts, "/identities?organization_id=not-a-uuid", http.StatusBadRequest) | ||
assert.Contains(t, res.Get("error.reason").String(), "Invalid UUID value `not-a-uuid` for parameter `organization_id`.", "%s", res.Raw) | ||
}) | ||
} | ||
}) | ||
|
||
t.Run("case=unknown organization id should return an empty list", func(t *testing.T) { | ||
for name, ts := range map[string]*httptest.Server{"admin": adminTS} { | ||
t.Run("endpoint="+name, func(t *testing.T) { | ||
id := x.NewUUID() | ||
res := get(t, ts, "/identities?organization_id="+id.String(), http.StatusOK) | ||
assert.Len(t, res.Array(), 0) | ||
}) | ||
} | ||
}) | ||
}) | ||
|
||
t.Run("case=should list all identities with credentials", func(t *testing.T) { | ||
t.Run("include_credential=oidc should include OIDC credentials config", func(t *testing.T) { | ||
res := get(t, adminTS, "/identities?include_credential=oidc&credentials_identifier=bar:[email protected]", http.StatusOK) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20240923095000000001_organization_id_index.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP INDEX identities_nid_organization_id_idx; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20240923095000000001_organization_id_index.mysql.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP INDEX identities_nid_organization_id_idx ON identities; |
1 change: 1 addition & 0 deletions
1
persistence/sql/migrations/sql/20240923095000000001_organization_id_index.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE INDEX identities_nid_organization_id_idx ON identities (organization_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters