mirror of
https://github.com/hansjone/dsh-ops-cron.git
synced 2026-10-10 03:20:46 +08:00
Fix cron cwd for super_admin and harden IM channel job isolation.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
b35bfde557
commit
b1bb0067a0
16 changed files with 714 additions and 49 deletions
|
|
@ -11,6 +11,7 @@ import {
|
|||
deliverRunToIm,
|
||||
mirrorRunToSession,
|
||||
jobVisibleToPeer,
|
||||
assertDeliveryAllowedForIdentity,
|
||||
} from '../lib/delivery.js'
|
||||
|
||||
test('normalizeDelivery defaults to dsh', () => {
|
||||
|
|
@ -439,3 +440,17 @@ test('formatRunResultBody matches IM delivery header', () => {
|
|||
const en = formatRunResultBody({ name: 'Daily' }, 'ok', 'en')
|
||||
assert.match(en, /^\[Scheduled tasks · Daily\]\n/)
|
||||
})
|
||||
|
||||
test('assertDeliveryAllowedForIdentity blocks non-admin web IM delivery', () => {
|
||||
const im = { kind: 'im', botId: 'b', targetId: 't' }
|
||||
assert.equal(
|
||||
assertDeliveryAllowedForIdentity(im, { empNo: 'a1', permissions: { canViewAllSessions: true } }),
|
||||
im,
|
||||
)
|
||||
assert.doesNotThrow(() => assertDeliveryAllowedForIdentity(im, { empNo: '__local__', permissions: { canViewAllSessions: true } }))
|
||||
assert.throws(
|
||||
() => assertDeliveryAllowedForIdentity(im, { empNo: 'u1', permissions: { canViewAllSessions: false } }),
|
||||
(error) => error.code === 'IM_DELIVERY_FORBIDDEN',
|
||||
)
|
||||
assert.doesNotThrow(() => assertDeliveryAllowedForIdentity({ kind: 'dsh' }, { empNo: 'u1', permissions: {} }))
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue