keycloak-scim/js/libs/keycloak-admin-client/test/auth.spec.ts
Jon Koops 8cb202eb29
Add JavaScript admin client to repository (#16697)
* Add JavaScript admin client to repository

* Apply review feedback

Co-authored-by: Stian Thorgersen <stian@redhat.com>

---------

Co-authored-by: Stian Thorgersen <stian@redhat.com>
2023-02-03 10:45:11 +00:00

47 lines
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).to.equal("openid profile email");
});
});