From 23c59c1aae826c47c8141a94825cf198f74881cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Fri, 12 Jun 2026 22:29:24 +0400 Subject: [PATCH] =?UTF-8?q?v2:=20fix=20switch=20case=20in=20test=20API=20(?= =?UTF-8?q?=D0=B1=D1=8B=D0=BB=20=D1=81=D0=BB=D0=BE=D0=BC=D0=B0=D0=BD=20sed?= =?UTF-8?q?-=D0=BE=D0=BC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- v2/src/config/index.js | 2 +- v2/src/test/index.js | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1366068..c4a8b5c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ipwhitelist", - "version": "0.5.83", + "version": "0.5.84", "description": "IP WhiteList microservice for cloud provider", "main": "server.js", "scripts": { diff --git a/v2/src/config/index.js b/v2/src/config/index.js index c04b1e9..6046b98 100644 --- a/v2/src/config/index.js +++ b/v2/src/config/index.js @@ -6,7 +6,7 @@ // ═══════════════════════════════════════════════════════════════════════════════ module.exports = { - version: '0.5.83', + version: '0.5.84', iamUrl: process.env.V2_IAM_API_URL || 'https://auth-api.ngcloud.ru', appUrl: process.env.V2_APP_URL || 'https://whitelist.nodejsk8s.services.ngcloud.ru', }; diff --git a/v2/src/test/index.js b/v2/src/test/index.js index 4705ec3..e2b3d9c 100644 --- a/v2/src/test/index.js +++ b/v2/src/test/index.js @@ -61,6 +61,17 @@ function createTestRouter() { case 'limit': return res.json({ ok: true, limit: await q.getLimit(company) }); + // ── SWITCH ── + case 'switch': { + const to = req.query.to; + if (!to) return res.json({ ok: false, error: 'no to parameter' }); + if (!user.allClientIds.includes(to)) return res.json({ ok: false, error: 'not in allClientIds' }); + user.activeClientId = to; + const p = user.profiles.find(p => p.client_id === to); + if (p) { p.is_active_profile = true; user.profiles.forEach(x => { if (x !== p) x.is_active_profile = false; }); } + return res.json({ ok: true, switchedTo: to }); + } + // ── CLEANUP ── case 'cleanup': { const cids = (req.query.cids || '').split(',');