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>
47 lines
1.3 KiB
TypeScript
47 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 type UserRepresentation from "../src/defs/userRepresentation.js";
|
|
import { credentials } from "./constants.js";
|
|
|
|
const expect = chai.expect;
|
|
|
|
describe("Attack Detection", () => {
|
|
let kcAdminClient: KeycloakAdminClient;
|
|
let currentUser: UserRepresentation;
|
|
|
|
before(async () => {
|
|
kcAdminClient = new KeycloakAdminClient();
|
|
await kcAdminClient.auth(credentials);
|
|
|
|
const username = faker.internet.username();
|
|
currentUser = await kcAdminClient.users.create({
|
|
username,
|
|
});
|
|
});
|
|
|
|
after(async () => {
|
|
await kcAdminClient.users.del({ id: currentUser.id! });
|
|
});
|
|
|
|
it("list attack detection for user", async () => {
|
|
const attackDetection = await kcAdminClient.attackDetection.findOne({
|
|
id: currentUser.id!,
|
|
});
|
|
expect(attackDetection).to.deep.equal({
|
|
numFailures: 0,
|
|
disabled: false,
|
|
lastIPFailure: "n/a",
|
|
lastFailure: 0,
|
|
});
|
|
});
|
|
|
|
it("clear any user login failures for all users", async () => {
|
|
await kcAdminClient.attackDetection.delAll();
|
|
});
|
|
|
|
it("clear any user login failures for a user", async () => {
|
|
await kcAdminClient.attackDetection.del({ id: currentUser.id! });
|
|
});
|
|
});
|