97727dbed5
* Bump @faker-js/faker from 9.0.3 to 9.1.0 Bumps [@faker-js/faker](https://github.com/faker-js/faker) from 9.0.3 to 9.1.0. - [Release notes](https://github.com/faker-js/faker/releases) - [Changelog](https://github.com/faker-js/faker/blob/next/CHANGELOG.md) - [Commits](https://github.com/faker-js/faker/compare/v9.0.3...v9.1.0) --- updated-dependencies: - dependency-name: "@faker-js/faker" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * removed use of deprecated userName() Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
// tslint:disable:no-unused-expression
|
|
import { faker } from "@faker-js/faker";
|
|
import * as chai from "chai";
|
|
import { KeycloakAdminClient } from "../src/client.js";
|
|
import { credentials } from "./constants.js";
|
|
|
|
const expect = chai.expect;
|
|
|
|
describe("Realms", () => {
|
|
let kcAdminClient: KeycloakAdminClient;
|
|
let currentRealmId: string;
|
|
|
|
before(async () => {
|
|
kcAdminClient = new KeycloakAdminClient();
|
|
await kcAdminClient.auth(credentials);
|
|
|
|
const realmId = faker.internet.username();
|
|
const realm = await kcAdminClient.realms.create({
|
|
id: realmId,
|
|
realm: realmId,
|
|
});
|
|
expect(realm.realmName).to.be.ok;
|
|
currentRealmId = realmId;
|
|
});
|
|
|
|
after(async () => {
|
|
await kcAdminClient.realms.del({ realm: currentRealmId });
|
|
});
|
|
|
|
it("add a user to another realm", async () => {
|
|
const username = faker.internet.username().toLowerCase();
|
|
const user = await kcAdminClient.users.create({
|
|
realm: currentRealmId,
|
|
username,
|
|
email: "test@keycloak.org",
|
|
// enabled required to be true in order to send actions email
|
|
emailVerified: true,
|
|
enabled: true,
|
|
});
|
|
const foundUser = (await kcAdminClient.users.findOne({
|
|
realm: currentRealmId,
|
|
id: user.id,
|
|
}))!;
|
|
expect(foundUser.username).to.be.eql(username);
|
|
});
|
|
});
|