Checkpoint: Remplacement complet de imap 0.8 par ImapFlow : OAuth2 moderne avec jeton brut, TLS strict, traitement séquentiel des messages non lus, verrou anti-concurrence conservé, marquage Seen uniquement après succès, test de connexion adapté, diagnostic OAuth2 et tests unitaires ajoutés. Validation : 31 tests, TypeScript, build et authentification réelle Microsoft 365 réussis.
This commit is contained in:
38
server/emailImportService.test.ts
Normal file
38
server/emailImportService.test.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { createImapFlowOptions, type EmailImportConfig } from "./emailImportService";
|
||||
|
||||
const baseConfig: EmailImportConfig = {
|
||||
userId: 2,
|
||||
emailAddress: "compta@example.org",
|
||||
password: "secret",
|
||||
host: "outlook.office365.com",
|
||||
port: 993,
|
||||
};
|
||||
|
||||
describe("createImapFlowOptions", () => {
|
||||
it("transmet le jeton brut à ImapFlow pour une authentification OAuth2", () => {
|
||||
const options = createImapFlowOptions(
|
||||
{ ...baseConfig, authMode: "oauth2" },
|
||||
"access-token-value",
|
||||
);
|
||||
|
||||
expect(options.secure).toBe(true);
|
||||
expect(options.auth).toEqual({
|
||||
user: "compta@example.org",
|
||||
accessToken: "access-token-value",
|
||||
});
|
||||
expect(options.auth).not.toHaveProperty("pass");
|
||||
expect(options.tls?.rejectUnauthorized).toBe(true);
|
||||
expect(options.disableAutoIdle).toBe(true);
|
||||
});
|
||||
|
||||
it("conserve le mot de passe uniquement pour le mode basique", () => {
|
||||
const options = createImapFlowOptions({ ...baseConfig, authMode: "basic" });
|
||||
|
||||
expect(options.auth).toEqual({
|
||||
user: "compta@example.org",
|
||||
pass: "secret",
|
||||
});
|
||||
expect(options.auth).not.toHaveProperty("accessToken");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user