Keycloak
58 строк · 1.5 Кб
1// tslint:disable:no-unused-expression
2import * as chai from "chai";
3import { KeycloakAdminClient } from "../src/client.js";
4import { credentials } from "./constants.js";
5
6const expect = chai.expect;
7
8describe("Client Policies", () => {
9let kcAdminClient: KeycloakAdminClient;
10const newPolicy = {
11name: "new_test_policy",
12};
13
14before(async () => {
15kcAdminClient = new KeycloakAdminClient();
16await kcAdminClient.auth(credentials);
17});
18
19it("creates/updates client policy", async () => {
20const createdPolicy = await kcAdminClient.clientPolicies.updatePolicy({
21policies: [newPolicy],
22});
23expect(createdPolicy).to.be.deep.eq("");
24});
25
26it("lists client policy profiles", async () => {
27const profiles = await kcAdminClient.clientPolicies.listProfiles({
28includeGlobalProfiles: true,
29});
30expect(profiles).to.be.ok;
31});
32
33it("create client policy profiles", async () => {
34const profiles = await kcAdminClient.clientPolicies.listProfiles({
35includeGlobalProfiles: true,
36});
37const globalProfiles = profiles.globalProfiles;
38const newClientProfiles = {
39profiles: [
40{
41name: "test",
42executors: [],
43},
44],
45globalProfiles,
46};
47
48const createdClientProfile =
49await kcAdminClient.clientPolicies.createProfiles(newClientProfiles);
50
51expect(createdClientProfile).to.be.deep.eq("");
52});
53
54it("lists client policy policies", async () => {
55const policies = await kcAdminClient.clientPolicies.listPolicies();
56expect(policies).to.be.ok;
57});
58});
59