Ricardo Martin 93812a6e14
Enable unit tests for keycloak-admin-client
Closes #44268

Signed-off-by: rmartinc <rmartinc@redhat.com>
2025-12-08 18:14:13 +01:00

52 lines
1.1 KiB
TypeScript

import * as chai from "chai";
import { getToken } from "../src/utils/auth.js";
import { credentials } from "./constants.js";
const expect = chai.expect;
describe("Authorization", () => {
it("should get token from local keycloak", async () => {
const data = await getToken({
credentials,
});
expect(data).to.have.all.keys(
"accessToken",
"expiresIn",
"refreshExpiresIn",
"refreshToken",
"tokenType",
"notBeforePolicy",
"sessionState",
"scope",
);
});
it("should get token from local keycloak with custom scope", async () => {
const data = await getToken({
credentials: {
...credentials,
scopes: ["openid", "profile"],
},
});
expect(data).to.have.all.keys(
"accessToken",
"expiresIn",
"refreshExpiresIn",
"refreshToken",
"tokenType",
"notBeforePolicy",
"sessionState",
"scope",
"idToken",
);
expect(data.scope.split(" ")).to.have.members([
"openid",
"email",
"profile",
]);
});
});