Files
ihasmail-inbuxa/web/src/jmap/__tests__/legacy-protocols.test.ts
T
jcoffey-dev 4cac9088dd Security says why a mail app won't connect, when legacy protocols are off
When the mail server has turned off legacy mail protocols -- IMAP, POP3,
ManageSieve and sending from mail apps -- for this account, whether for
the whole server or for the account's organization, Settings › Security
says so at the top of App passwords, the section people come to when a
phone won't connect:

  Your organization allows only {app} and JMAP apps, so phone and desktop
  mail apps can't connect to this account.

This is INBUXA's legacy-protocols LP-19. The server reports it per
account as legacyProtocols on the urn:inbuxa:jmap account capability
(contract C-1); anything short of a plain "disabled" -- an older server,
another server, no session yet -- reads as on, so the line never appears
where it isn't true.

The app's name comes from {app}, as everywhere else. Translated into all
nine languages, in the register each catalog already uses.
2026-09-21 13:44:50 -07:00

30 lines
1.4 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { INBUXA_CAP, legacyProtocolsOff } from "../client";
import type { JmapSession } from "../types";
/**
* The server says, per account, whether legacy mail protocols are off for it
* (legacy-protocols LP-19, contract C-1). Anything short of a plain
* "disabled" -- an older server, another server, no session yet -- reads as
* on, so the notice never appears where it isn't true.
*/
describe("legacyProtocolsOff", () => {
const session = (cap: Record<string, unknown> | undefined) =>
({
accounts: { a: { name: "[email protected]", accountCapabilities: cap ? { [INBUXA_CAP]: cap } : {} } },
}) as unknown as JmapSession;
it("is on only when the account's capability says disabled", () => {
expect(legacyProtocolsOff(session({ legacyProtocols: "disabled" }), "a")).toBe(true);
expect(legacyProtocolsOff(session({ legacyProtocols: "enabled" }), "a")).toBe(false);
});
it("reads an older or other server, or no session, as on", () => {
expect(legacyProtocolsOff(session({ logo: null }), "a")).toBe(false);
expect(legacyProtocolsOff(session(undefined), "a")).toBe(false);
expect(legacyProtocolsOff(session({ legacyProtocols: "disabled" }), "b")).toBe(false);
expect(legacyProtocolsOff(null, "a")).toBe(false);
expect(legacyProtocolsOff(session({ legacyProtocols: "disabled" }), null)).toBe(false);
});
});