mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-13 09:25:12 +00:00
feat(api): allow filtering apps by client id and entity id (#11385)
# Which Problems Are Solved There's currently no way to retrieve a project based on the client_id of an application. A developer would need to iterate through all projects and their applications to make the correlation. # How the Problems Are Solved - Added a possibility to filter for `client_id` and `entity_id` on the ListApplications endpoint. - Added the `project_id` on the `Application` response (used on the ListApplications endpoint). # Additional Changes None # Additional Context - closes #11340 - requires backport to v4.x
This commit is contained in:
@@ -169,7 +169,7 @@ func TestListApplications(t *testing.T) {
|
||||
createdDeactivatedApiApp, deactivatedApiAppName := createAPIAppWithName(t, IAMOwnerCtx, instance, p.GetId())
|
||||
deactivateApp(t, createdDeactivatedApiApp, p.GetId())
|
||||
|
||||
_, createdSAMLApp, samlAppName := createSAMLAppWithName(t, integration.URL(), p.GetId())
|
||||
_, createdSAMLApp, samlAppName, samlEntityID := createSAMLAppWithName(t, integration.URL(), p.GetId())
|
||||
|
||||
createdOIDCApp, oidcAppName := createOIDCAppWithName(t, integration.URL(), p.GetId())
|
||||
|
||||
@@ -480,6 +480,99 @@ func TestListApplications(t *testing.T) {
|
||||
creationDates[i] = a.GetCreationDate().AsTime()
|
||||
}
|
||||
|
||||
return creationDates
|
||||
},
|
||||
},
|
||||
{
|
||||
testName: "when filtering by clientID should return matching OIDC app only",
|
||||
inputCtx: IAMOwnerCtx,
|
||||
inputRequest: &application.ListApplicationsRequest{
|
||||
Pagination: &filter.PaginationRequest{Asc: true},
|
||||
Filters: []*application.ApplicationSearchFilter{
|
||||
{
|
||||
Filter: &application.ApplicationSearchFilter_ClientIdFilter{
|
||||
ClientIdFilter: &application.ClientIDFilter{ClientId: createdOIDCApp.GetOidcConfiguration().GetClientId()},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedOrderedList: []appWithName{{name: oidcAppName, app: createdOIDCApp}},
|
||||
expectedOrderedKeys: func(apps []appWithName) any {
|
||||
creationDates := make([]time.Time, len(apps))
|
||||
for i, a := range apps {
|
||||
creationDates[i] = a.app.GetCreationDate().AsTime()
|
||||
}
|
||||
|
||||
return creationDates
|
||||
},
|
||||
actualOrderedKeys: func(apps []*application.Application) any {
|
||||
creationDates := make([]time.Time, len(apps))
|
||||
for i, a := range apps {
|
||||
creationDates[i] = a.GetCreationDate().AsTime()
|
||||
}
|
||||
|
||||
return creationDates
|
||||
},
|
||||
},
|
||||
{
|
||||
testName: "when filtering by clientID should return matching API app only",
|
||||
inputCtx: IAMOwnerCtx,
|
||||
inputRequest: &application.ListApplicationsRequest{
|
||||
Pagination: &filter.PaginationRequest{Asc: true},
|
||||
Filters: []*application.ApplicationSearchFilter{
|
||||
{
|
||||
Filter: &application.ApplicationSearchFilter_ClientIdFilter{
|
||||
ClientIdFilter: &application.ClientIDFilter{ClientId: createdApiApp.GetApiConfiguration().GetClientId()},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedOrderedList: []appWithName{{name: apiAppName, app: createdApiApp}},
|
||||
expectedOrderedKeys: func(apps []appWithName) any {
|
||||
creationDates := make([]time.Time, len(apps))
|
||||
for i, a := range apps {
|
||||
creationDates[i] = a.app.GetCreationDate().AsTime()
|
||||
}
|
||||
|
||||
return creationDates
|
||||
},
|
||||
actualOrderedKeys: func(apps []*application.Application) any {
|
||||
creationDates := make([]time.Time, len(apps))
|
||||
for i, a := range apps {
|
||||
creationDates[i] = a.GetCreationDate().AsTime()
|
||||
}
|
||||
|
||||
return creationDates
|
||||
},
|
||||
},
|
||||
{
|
||||
testName: "when filtering by entityID should return matching SAML app only",
|
||||
inputCtx: IAMOwnerCtx,
|
||||
inputRequest: &application.ListApplicationsRequest{
|
||||
Pagination: &filter.PaginationRequest{Asc: true},
|
||||
Filters: []*application.ApplicationSearchFilter{
|
||||
{
|
||||
Filter: &application.ApplicationSearchFilter_EntityIdFilter{
|
||||
EntityIdFilter: &application.EntityIDFilter{EntityId: samlEntityID},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedOrderedList: []appWithName{{name: samlAppName, app: createdSAMLApp}},
|
||||
expectedOrderedKeys: func(apps []appWithName) any {
|
||||
creationDates := make([]time.Time, len(apps))
|
||||
for i, a := range apps {
|
||||
creationDates[i] = a.app.GetCreationDate().AsTime()
|
||||
}
|
||||
|
||||
return creationDates
|
||||
},
|
||||
actualOrderedKeys: func(apps []*application.Application) any {
|
||||
creationDates := make([]time.Time, len(apps))
|
||||
for i, a := range apps {
|
||||
creationDates[i] = a.GetCreationDate().AsTime()
|
||||
}
|
||||
|
||||
return creationDates
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user