Added support for searching permission (#37001)

Signed-off-by: Agnieszka Gancarczyk <agagancarczyk@gmail.com>
This commit is contained in:
Agnieszka Gancarczyk 2025-02-04 10:36:37 +00:00 committed by GitHub
parent 48a6450b73
commit 1793af6fed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 38 additions and 0 deletions

View File

@ -774,6 +774,20 @@ export class Clients extends Resource<{ realm?: string }> {
urlParamKeys: ["id", "resourceName"],
});
public listPermissionScope = this.makeRequest<
{
id: string;
policyId?: string;
name?: string;
resource?: string;
} & PaginatedQuery,
PolicyRepresentation[]
>({
method: "GET",
path: "/{id}/authz/resource-server/permission/scope",
urlParamKeys: ["id"],
});
public createAuthorizationScope = this.makeUpdateRequest<
{ id: string },
ScopeRepresentation

View File

@ -1099,6 +1099,30 @@ describe("Clients", () => {
expect(result).to.deep.equal([]);
});
it("list permission scope", async () => {
permission = await kcAdminClient.clients.createPermission(
{
id: currentClient.id!,
type: "scope",
},
{
name: permissionConfig.name,
// @ts-ignore
resources: [resource._id],
policies: [policy.id!],
scopes: scopes.map((scope) => scope.id!),
},
);
const p = await kcAdminClient.clients.listPermissionScope({
id: currentClient.id!,
name: permissionConfig.name,
});
expect(p.length).to.be.eq(1);
expect(p[0].name).to.be.eq(permissionConfig.name);
});
it("import resource", async () => {
await kcAdminClient.clients.importResource(
{ id: currentClient.id! },