diff --git a/package.json b/package.json index 44ea5ec..0417ec5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ipwhitelist", - "version": "0.5.166", + "version": "0.5.167", "description": "IP WhiteList microservice for cloud provider", "main": "server.js", "scripts": { diff --git a/tests/run-tests.js b/tests/run-tests.js index dd19003..4a97ed4 100644 --- a/tests/run-tests.js +++ b/tests/run-tests.js @@ -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); + // ──────────────────────────────────────────────────────────────── diff --git a/v2/src/config/index.js b/v2/src/config/index.js index 591af30..651539e 100644 --- a/v2/src/config/index.js +++ b/v2/src/config/index.js @@ -8,7 +8,7 @@ // ═══════════════════════════════════════════════════════════════════════════════ module.exports = { - version: '0.5.166', + version: '0.5.167', // ── IAM ────────────────────────────────────────────────────────────────── iamUrl: process.env.V2_IAM_URL || 'https://auth-api.ngcloud.ru/api/v1/auth/user',