From 52afbad2f029636561900f864c2866d30118342a Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Mon, 3 Jan 2022 17:26:15 +0100 Subject: [PATCH] added list policy providers endpoint (#355) --- src/defs/policyProviderRepresentation.ts | 5 +++++ src/resources/clients.ts | 10 ++++++++++ test/clients.spec.ts | 7 +++++++ 3 files changed, 22 insertions(+) create mode 100644 src/defs/policyProviderRepresentation.ts diff --git a/src/defs/policyProviderRepresentation.ts b/src/defs/policyProviderRepresentation.ts new file mode 100644 index 00000000..2ef1b7a2 --- /dev/null +++ b/src/defs/policyProviderRepresentation.ts @@ -0,0 +1,5 @@ +export interface PolicyProviderRepresentation { + type?: string; + name?: string; + group?: string; +} diff --git a/src/resources/clients.ts b/src/resources/clients.ts index 2cae0119..f5545237 100644 --- a/src/resources/clients.ts +++ b/src/resources/clients.ts @@ -16,6 +16,7 @@ import CertificateRepresentation from '../defs/certificateRepresentation'; import KeyStoreConfig from '../defs/keystoreConfig'; import ResourceServerRepresentation from '../defs/resourceServerRepresentation'; import ScopeRepresentation from '../defs/scopeRepresentation'; +import {PolicyProviderRepresentation} from '../defs/policyProviderRepresentation'; export interface PaginatedQuery { first?: number; @@ -622,6 +623,15 @@ export class Clients extends Resource<{realm?: string}> { urlParamKeys: ['id', 'policyId'], }); + public listPolicyProviders = this.makeRequest< + {id: string}, + PolicyProviderRepresentation + >({ + method: 'GET', + path: '/{id}/authz/resource-server/policy/providers', + urlParamKeys: ['id'], + }); + public async createOrUpdatePolicy(payload: { id: string; policyName: string; diff --git a/test/clients.spec.ts b/test/clients.spec.ts index 1e42610b..a62bd264 100644 --- a/test/clients.spec.ts +++ b/test/clients.spec.ts @@ -1260,5 +1260,12 @@ describe('Clients', () => { }, ]); }); + + it('list policy providers', async () => { + const result = await kcAdminClient.clients.listPolicyProviders({ + id: currentClient.id!, + }); + expect(result).to.be.ok; + }); }); });