Keycloak
47 строк · 1.0 Кб
1import * as chai from "chai";
2import { getToken } from "../src/utils/auth.js";
3import { credentials } from "./constants.js";
4
5const expect = chai.expect;
6
7describe("Authorization", () => {
8it("should get token from local keycloak", async () => {
9const data = await getToken({
10credentials,
11});
12
13expect(data).to.have.all.keys(
14"accessToken",
15"expiresIn",
16"refreshExpiresIn",
17"refreshToken",
18"tokenType",
19"notBeforePolicy",
20"sessionState",
21"scope",
22);
23});
24
25it("should get token from local keycloak with custom scope", async () => {
26const data = await getToken({
27credentials: {
28...credentials,
29scopes: ["openid", "profile"],
30},
31});
32
33expect(data).to.have.all.keys(
34"accessToken",
35"expiresIn",
36"refreshExpiresIn",
37"refreshToken",
38"tokenType",
39"notBeforePolicy",
40"sessionState",
41"scope",
42"idToken",
43);
44
45expect(data.scope).to.equal("openid email profile");
46});
47});
48