fix: enforce platform role menu access

This commit is contained in:
2026-07-27 12:48:35 +08:00
parent cd58e1f6b6
commit 160172bf10
33 changed files with 481 additions and 107 deletions

View File

@@ -143,3 +143,32 @@ test('树页面通过资源归档接口归档节点', () => {
assert.match(source, /resourceApi\.archive/);
assert.match(source, /Modal\.(warning|confirm)/);
});
test('route access uses authenticated role and assigned menu codes', () => {
const routeDir = fromProjectRoot('src/router/routes/modules');
const routeSource = fs.readdirSync(routeDir)
.filter((name) => name.endsWith('.ts'))
.map((name) => fs.readFileSync(path.join(routeDir, name), 'utf8'))
.join('\n');
const userStore = fs.readFileSync(fromProjectRoot('src/store/modules/user/index.ts'), 'utf8');
const permission = fs.readFileSync(fromProjectRoot('src/hooks/permission.ts'), 'utf8');
assert.doesNotMatch(routeSource, /roles:\s*\[\s*['"]\*['"]\s*\]/);
assert.match(routeSource, /menuCode:\s*['"]finance['"]/);
assert.match(userStore, /profile\.role_code/);
assert.match(userStore, /menuCodes/);
assert.match(permission, /menuCode/);
});
test('platform role UI replaces assigned menu identities through the singular contract URL', () => {
const resources = fs.readFileSync(fromProjectRoot('src/api/resources.ts'), 'utf8');
const crudPage = fs.readFileSync(fromProjectRoot('src/views/shared/CrudListPage.vue'), 'utf8');
const platformApi = fs.readFileSync(fromProjectRoot('src/api/platform.ts'), 'utf8');
assert.match(resources, /platform_role[\s\S]*\/platform\/platform_role\/:identity\/menu/);
assert.match(resources, /menu-identities/);
assert.match(crudPage, /multiple/);
assert.match(crudPage, /menu_identities/);
assert.match(platformApi, /\/platform\/platform_role\/\$\{identity\}\/menu/);
assert.match(platformApi, /method:\s*['"]PUT['"]/);
});