v0.5.167: 9 новых тестов — aggregateCIDRs, v2 config, v1_legacy

This commit is contained in:
2026-06-22 17:52:49 +04:00
parent 3d20c2a31d
commit ef546a9dcb
3 changed files with 34 additions and 2 deletions
+32
View File
@@ -214,6 +214,38 @@ const { doubleCsrfProtection: dp, generateCsrfToken: gct } = csrfMiddleware.init
test('initCsrf returns doubleCsrfProtection fn', typeof dp, 'function');
test('initCsrf returns generateCsrfToken fn', typeof gct, 'function');
// ────────────────────────────────────────────────────────────────
// 7. v2/src/config.js — IAM параметры
// ────────────────────────────────────────────────────────────────
section('v2 config');
const v2config = require('../v2/src/config');
test('iamApiBase default', v2config.iamApiBase, 'https://auth-api.ngcloud.ru/api/v1');
test('version present', typeof v2config.version, 'string');
// ────────────────────────────────────────────────────────────────
// 8. v2/src/validators — aggregateCIDRs
// ────────────────────────────────────────────────────────────────
section('v2 aggregateCIDRs');
const v2validators = require('../v2/src/validators');
test('256 /32 → /24', v2validators.aggregateCIDRs(Array.from({length:256}, (_,i)=>'1.1.0.'+i+'/32')).join(),
'1.1.0.0/24');
test('two /24 → /23', v2validators.aggregateCIDRs(['10.0.0.0/24','10.0.1.0/24']).join(),
'10.0.0.0/23');
test('two /32 → /31', v2validators.aggregateCIDRs(['192.168.1.0/32','192.168.1.1/32']).join(),
'192.168.1.0/31');
test('gap → 2 CIDRs', v2validators.aggregateCIDRs(['10.0.0.0/24','10.0.2.0/24']).length, 2);
test('single /32', v2validators.aggregateCIDRs(['5.5.5.5/32']).join(), '5.5.5.5/32');
// ────────────────────────────────────────────────────────────────
// 9. v1_legacy — старый код изолирован
// ────────────────────────────────────────────────────────────────
section('v1_legacy isolation');
test('ui/index moved', !!(() => { try { require('../ui/index'); return false; } catch { return true; }})(), true);
test('src/api/index moved', !!(() => { try { require('../src/api/index'); return false; } catch { return true; }})(), true);
// ────────────────────────────────────────────────────────────────