AkurAI Build
Menu

Public repository / 275d4fa11a39ecc30e2caf604d5a0d499910e8db

AkurAI-Mail / src/lib/webmail/session.test.ts

Latest change 22202d1bde69be4ace8a299dffd91f8ff24378df - Recover deployed webmail frontend (frontend parity with EC2 a6afffc) by Ólafur Búi Ólafsson

import { describe, expect, test } from "bun:test";
import { webmailSession } from "./session";

describe("webmailSession", () => {
  test("OIDC session: mailbox is the signed-in user, not an admin", () => {
    expect(webmailSession({ authenticated: true, user: "me@x.is", method: "oidc" })).toEqual({ signedIn: true, email: "me@x.is", admin: false });
  });

  test("explicit admin/email fields win", () => {
    expect(webmailSession({ authenticated: true, admin: true, email: "a@x.is", user: "root" })).toEqual({ signedIn: true, email: "a@x.is", admin: true });
  });

  test("password admin login is an admin", () => {
    expect(webmailSession({ authenticated: true, user: "admin", method: "password", mailbox: "" }).admin).toBe(true);
  });

  test("no session", () => {
    expect(webmailSession({ authenticated: false, mailbox: "", method: "none" })).toEqual({ signedIn: false, email: "", admin: false });
  });
});