fix(auth): align restricted header and logout state
This commit is contained in:
@@ -1,5 +1,36 @@
|
||||
import authOptions from "./options";
|
||||
|
||||
describe("Keycloak profile mapping", () => {
|
||||
const mapProfile = authOptions.providers[0].profile as (profile: {
|
||||
sub: string;
|
||||
preferred_username: string;
|
||||
name?: string;
|
||||
email?: string;
|
||||
picture?: string;
|
||||
}) => { image?: string | null };
|
||||
|
||||
it("uses the Keycloak picture instead of a shared local avatar", () => {
|
||||
expect(
|
||||
mapProfile({
|
||||
sub: "user-1",
|
||||
preferred_username: "zjb",
|
||||
picture: "https://keycloak.example/avatar/zjb.png",
|
||||
}),
|
||||
).toMatchObject({
|
||||
image: "https://keycloak.example/avatar/zjb.png",
|
||||
});
|
||||
});
|
||||
|
||||
it("leaves the image empty when Keycloak has no picture", () => {
|
||||
const profile = mapProfile({
|
||||
sub: "user-1",
|
||||
preferred_username: "zjb",
|
||||
});
|
||||
|
||||
expect(profile.image).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("NextAuth access token refresh", () => {
|
||||
it("forces a Keycloak refresh for an agent credential request", async () => {
|
||||
const previousEnv = {
|
||||
|
||||
Reference in New Issue
Block a user