This commit is contained in:
2026-08-28 10:38:58 +08:00
parent b34fbb2bd1
commit 1e5ce54858
37 changed files with 256 additions and 159 deletions
@@ -36,22 +36,30 @@ export async function run(context) {
const rolesResponse = await context.request('GET', '/api/platform/v1/iam/roles')
const roles = context.apiSuccess(MODULE, '查询三期仓库内置角色', rolesResponse, '', OPTIONS)
const warehouseRoles = new Map((Array.isArray(roles) ? roles : [])
.filter((item) => ['WAREHOUSE_OPERATOR', 'WAREHOUSE_PICKER', 'WAREHOUSE_TALLY'].includes(item.roleCode))
.filter((item) => ['WAREHOUSE_OPERATOR', 'OVERSEAS_WAREHOUSE_PDA_OPERATOR', 'WAREHOUSE_TALLY', 'CN_FIRSTLEG_PDA_OPERATOR'].includes(item.roleCode))
.map((item) => [item.roleCode, item]))
context.assert(MODULE, '操作员、拣货员、理货员三个系统角色已启用', rolesResponse,
warehouseRoles.size === 3 && [...warehouseRoles.values()]
context.assert(MODULE, '国内后台、国内PDA、海外PDA、理货复核四个系统角色已启用', rolesResponse,
warehouseRoles.size === 4 && [...warehouseRoles.values()]
.every((role) => role.roleType === 'SYSTEM' && role.status === 'ACTIVE'),
`roles=${[...warehouseRoles.keys()].join(',')}`, OPTIONS)
const roleCodes = (roleCode) => new Set((warehouseRoles.get(roleCode)?.permissionIds || [])
.map((permissionId) => permissionById.get(id(permissionId))).filter(Boolean))
const pickerCodes = roleCodes('WAREHOUSE_PICKER')
context.assert(MODULE, '拣货员只具备国内PDA查询作业与海外PDA入仓操作权限', rolesResponse,
pickerCodes.size === 3
&& pickerCodes.has('platform:firstleg:pda:view')
&& pickerCodes.has('platform:firstleg:pda:work')
&& pickerCodes.has('lastleg:pda:operate'),
`permissions=${[...pickerCodes].sort().join(',')}`, OPTIONS)
const domesticPdaCodes = roleCodes('CN_FIRSTLEG_PDA_OPERATOR')
context.assert(MODULE, '国内头程PDA角色只具备国内任务查询与作业权限', rolesResponse,
domesticPdaCodes.size === 2
&& domesticPdaCodes.has('platform:firstleg:pda:view')
&& domesticPdaCodes.has('platform:firstleg:pda:work')
&& !domesticPdaCodes.has('lastleg:pda:operate'),
`permissions=${[...domesticPdaCodes].sort().join(',')}`, OPTIONS)
const overseasPdaCodes = roleCodes('OVERSEAS_WAREHOUSE_PDA_OPERATOR')
context.assert(MODULE, '海外仓PDA角色只具备海外PDA作业权限', rolesResponse,
overseasPdaCodes.size === 1
&& overseasPdaCodes.has('lastleg:pda:operate')
&& !overseasPdaCodes.has('platform:firstleg:pda:view')
&& !overseasPdaCodes.has('platform:firstleg:pda:work'),
`permissions=${[...overseasPdaCodes].sort().join(',')}`, OPTIONS)
const operatorCodes = roleCodes('WAREHOUSE_OPERATOR')
context.assert(MODULE, '操作员具备国内入仓权限与四期十项只读权限', rolesResponse,
@@ -88,7 +96,7 @@ export async function run(context) {
`phase4ReadCodes=${PHASE4_READ_CODES.length}`, OPTIONS)
context.assert(MODULE, '仓库系统角色不包含任何客户侧权限', rolesResponse,
[...operatorCodes, ...pickerCodes, ...tallyCodes]
[...operatorCodes, ...domesticPdaCodes, ...overseasPdaCodes, ...tallyCodes]
.every((code) => code.startsWith('platform:') || code === 'lastleg:pda:operate'),
'warehouse roles may use platform:* plus the single overseas service authority lastleg:pda:operate', OPTIONS)