Add optional mailbox (UPN/SMTP) routing on email/folder/thread tools via
users/{upn}/... and X-AnchorMailbox. New list-mailboxes probes primary,
OUTLOOK_SHARED_MAILBOXES seeds, cache, and candidates. Send supports
mailbox-rooted sendMail and onBehalfOf. MSAL requests Mail.*.Shared;
check-auth-status reports token scp gaps. Docs, env example, tests.
33 lines
1 KiB
JavaScript
33 lines
1 KiB
JavaScript
/**
|
|
* Unit tests for shared send path selection (pure logic mirror).
|
|
* Run: node tests/mailbox-send-path.test.js
|
|
*/
|
|
const assert = require('assert');
|
|
const { normalizeMailbox, buildPath } = require('../utils/mailbox');
|
|
|
|
function resolveSendPath(args) {
|
|
const mb = normalizeMailbox(args.mailbox);
|
|
const onBehalf = args.onBehalfOf === true || args.onBehalfOf === 'true';
|
|
if (mb.kind === 'user' && !onBehalf) {
|
|
return buildPath(mb, 'sendMail');
|
|
}
|
|
return 'me/sendMail';
|
|
}
|
|
|
|
assert.strictEqual(resolveSendPath({}), 'me/sendMail');
|
|
assert.strictEqual(resolveSendPath({ mailbox: 'me' }), 'me/sendMail');
|
|
assert.strictEqual(
|
|
resolveSendPath({ mailbox: 'helpdesk@contoso.com' }),
|
|
'users/helpdesk@contoso.com/sendMail'
|
|
);
|
|
assert.strictEqual(
|
|
resolveSendPath({ mailbox: 'helpdesk@contoso.com', onBehalfOf: true }),
|
|
'me/sendMail'
|
|
);
|
|
assert.strictEqual(
|
|
resolveSendPath({ mailbox: 'helpdesk@contoso.com', onBehalfOf: 'true' }),
|
|
'me/sendMail'
|
|
);
|
|
|
|
console.log('✅ send path selection');
|
|
console.log('\nAll mailbox-send-path tests passed.');
|