keycloak-scim/js/libs/keycloak-admin-client/test/clientPolicies.spec.ts
Jon Koops 8cb202eb29
Add JavaScript admin client to repository (#16697)
* Add JavaScript admin client to repository

* Apply review feedback

Co-authored-by: Stian Thorgersen <stian@redhat.com>

---------

Co-authored-by: Stian Thorgersen <stian@redhat.com>
2023-02-03 10:45:11 +00:00

58 lines
1.5 KiB
TypeScript

// tslint:disable:no-unused-expression
import * as chai from "chai";
import { KeycloakAdminClient } from "../src/client.js";
import { credentials } from "./constants.js";
const expect = chai.expect;
describe("Client Policies", () => {
let kcAdminClient: KeycloakAdminClient;
const newPolicy = {
name: "new_test_policy",
};
before(async () => {
kcAdminClient = new KeycloakAdminClient();
await kcAdminClient.auth(credentials);
});
it("creates/updates client policy", async () => {
const createdPolicy = await kcAdminClient.clientPolicies.updatePolicy({
policies: [newPolicy],
});
expect(createdPolicy).to.be.deep.eq("");
});
it("lists client policy profiles", async () => {
const profiles = await kcAdminClient.clientPolicies.listProfiles({
includeGlobalProfiles: true,
});
expect(profiles).to.be.ok;
});
it("create client policy profiles", async () => {
const profiles = await kcAdminClient.clientPolicies.listProfiles({
includeGlobalProfiles: true,
});
const globalProfiles = profiles.globalProfiles;
const newClientProfiles = {
profiles: [
{
name: "test",
executors: [],
},
],
globalProfiles,
};
const createdClientProfile =
await kcAdminClient.clientPolicies.createProfiles(newClientProfiles);
expect(createdClientProfile).to.be.deep.eq("");
});
it("lists client policy policies", async () => {
const policies = await kcAdminClient.clientPolicies.listPolicies();
expect(policies).to.be.ok;
});
});