feat: gate overseas receiving and harden phase4 workflows
This commit is contained in:
@@ -1,5 +1,18 @@
|
||||
const MODULE = 'phase3-warehouse-rbac'
|
||||
const OPTIONS = { scenario: 'warehouse-role-boundary', deploymentBlocker: true }
|
||||
const PHASE4_READ_CODES = [
|
||||
'platform:overseas-warehouse:last-mile-order:list',
|
||||
'platform:overseas-warehouse:inbound-order:list',
|
||||
'platform:overseas-warehouse:relabel-order:list',
|
||||
'platform:overseas-warehouse:inventory:list',
|
||||
'platform:overseas-warehouse:warehouse:list',
|
||||
'platform:overseas-warehouse:location:list',
|
||||
'platform:overseas-warehouse:pallet:list',
|
||||
'platform:overseas-business:purchase:list',
|
||||
'platform:overseas-business:truck:list',
|
||||
'platform:overseas-business:looseboard:list',
|
||||
]
|
||||
const PHASE4_WRITE_SUFFIXES = [':create', ':edit', ':status', ':export', ':adjust', ':delete', ':review']
|
||||
|
||||
function id(value) { return value == null ? '' : String(value) }
|
||||
|
||||
@@ -41,14 +54,17 @@ export async function run(context) {
|
||||
`permissions=${[...pickerCodes].sort().join(',')}`, OPTIONS)
|
||||
|
||||
const operatorCodes = roleCodes('WAREHOUSE_OPERATOR')
|
||||
context.assert(MODULE, '操作员仅具备入仓查看和后台证据维护权限', rolesResponse,
|
||||
context.assert(MODULE, '操作员具备国内入仓权限与四期十项只读权限', rolesResponse,
|
||||
operatorCodes.has('platform:firstleg:inbound:loading:view')
|
||||
&& operatorCodes.has('platform:firstleg:inbound:loading:edit')
|
||||
&& operatorCodes.size === 5
|
||||
&& operatorCodes.size === 15
|
||||
&& PHASE4_READ_CODES.every((code) => operatorCodes.has(code))
|
||||
&& !operatorCodes.has('platform:firstleg:inbound:loading:complete')
|
||||
&& !operatorCodes.has('platform:firstleg:pda:assign')
|
||||
&& !operatorCodes.has('platform:firstleg:outbound-dispatch:confirm')
|
||||
&& !operatorCodes.has('platform:firstleg:outbound-dispatch:reverse'),
|
||||
&& !operatorCodes.has('platform:firstleg:outbound-dispatch:reverse')
|
||||
&& [...operatorCodes].filter((code) => code.startsWith('platform:overseas-'))
|
||||
.every((code) => !PHASE4_WRITE_SUFFIXES.some((suffix) => code.endsWith(suffix))),
|
||||
`permissionCount=${operatorCodes.size}`, OPTIONS)
|
||||
|
||||
const tallyCodes = roleCodes('WAREHOUSE_TALLY')
|
||||
@@ -56,10 +72,21 @@ export async function run(context) {
|
||||
tallyCodes.has('platform:firstleg:inbound:loading:view')
|
||||
&& tallyCodes.has('platform:firstleg:inbound:loading:edit')
|
||||
&& tallyCodes.has('platform:firstleg:pda:review')
|
||||
&& tallyCodes.size === 22
|
||||
&& PHASE4_READ_CODES.every((code) => tallyCodes.has(code))
|
||||
&& !tallyCodes.has('platform:firstleg:inbound:loading:complete')
|
||||
&& !tallyCodes.has('platform:firstleg:outbound-dispatch:confirm'),
|
||||
&& !tallyCodes.has('platform:firstleg:outbound-dispatch:confirm')
|
||||
&& [...tallyCodes].filter((code) => code.startsWith('platform:overseas-'))
|
||||
.every((code) => !PHASE4_WRITE_SUFFIXES.some((suffix) => code.endsWith(suffix))),
|
||||
`permissionCount=${tallyCodes.size}`, OPTIONS)
|
||||
|
||||
context.assert(MODULE, '四期list权限同时用于列表与详情且不隐含写权限', rolesResponse,
|
||||
PHASE4_READ_CODES.every((code) => code.endsWith(':list'))
|
||||
&& [...operatorCodes, ...tallyCodes]
|
||||
.filter((code) => code.startsWith('platform:overseas-'))
|
||||
.every((code) => PHASE4_READ_CODES.includes(code)),
|
||||
`phase4ReadCodes=${PHASE4_READ_CODES.length}`, OPTIONS)
|
||||
|
||||
context.assert(MODULE, '仓库系统角色不包含任何客户侧权限', rolesResponse,
|
||||
[...operatorCodes, ...pickerCodes, ...tallyCodes]
|
||||
.every((code) => code.startsWith('platform:') || code === 'lastleg:pda:operate'),
|
||||
|
||||
Reference in New Issue
Block a user