2023-02-03 10:45:11 +00:00
|
|
|
// tslint:disable:no-unused-expression
|
|
|
|
import { faker } from "@faker-js/faker";
|
|
|
|
import * as chai from "chai";
|
|
|
|
import { KeycloakAdminClient } from "../src/client.js";
|
|
|
|
import type ComponentRepresentation from "../src/defs/componentRepresentation.js";
|
|
|
|
import { credentials } from "./constants.js";
|
|
|
|
|
|
|
|
const expect = chai.expect;
|
|
|
|
|
|
|
|
describe("Users federation provider", () => {
|
|
|
|
let kcAdminClient: KeycloakAdminClient;
|
|
|
|
let currentUserFed: ComponentRepresentation;
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
kcAdminClient = new KeycloakAdminClient();
|
|
|
|
await kcAdminClient.auth(credentials);
|
|
|
|
|
2024-10-30 11:14:02 +00:00
|
|
|
const name = faker.internet.username();
|
2023-02-03 10:45:11 +00:00
|
|
|
currentUserFed = await kcAdminClient.components.create({
|
|
|
|
name,
|
|
|
|
parentId: "master",
|
|
|
|
providerId: "ldap",
|
|
|
|
providerType: "org.keycloak.storage.UserStorageProvider",
|
|
|
|
config: {
|
|
|
|
editMode: ["READ_ONLY"],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
after(async () => {
|
|
|
|
await kcAdminClient.components.del({
|
|
|
|
id: currentUserFed.id!,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("list storage provider", async () => {
|
|
|
|
const name = await kcAdminClient.userStorageProvider.name({
|
|
|
|
id: currentUserFed.id!,
|
|
|
|
});
|
|
|
|
expect(name).to.be.ok;
|
|
|
|
});
|
|
|
|
|
|
|
|
it("remove imported users", async () => {
|
|
|
|
await kcAdminClient.userStorageProvider.removeImportedUsers({
|
|
|
|
id: currentUserFed.id!,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("unlink users", async () => {
|
|
|
|
await kcAdminClient.userStorageProvider.unlinkUsers({
|
|
|
|
id: currentUserFed.id!,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|