v0.5.147: /v2/impersonation-check — сравнение auth-api vs lk-api-gateway
This commit is contained in:
+20
-11
@@ -90,29 +90,38 @@ function createV2Router() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// ── GET /v2/impersonation-check — IAM impersonation: 3 GET эндпоинта ──
|
// ── GET /v2/impersonation-check — сравнение auth-api vs lk-api-gateway ──
|
||||||
router.get('/impersonation-check', async (req, res) => {
|
router.get('/impersonation-check', async (req, res) => {
|
||||||
const token = req.session && req.session.token;
|
const token = req.session && req.session.token;
|
||||||
if (!token) return res.send('<h2>Нет токена</h2><p><a href="/v2/login">Войти</a></p>');
|
if (!token) return res.send('<h2>Нет токена</h2><p><a href="/v2/login">Войти</a></p>');
|
||||||
|
|
||||||
const endpoints = [
|
const tests = [
|
||||||
{ name: 'status', url: 'https://auth-api.ngcloud.ru/api/v1/impersonation/status' },
|
{
|
||||||
{ name: 'history', url: 'https://auth-api.ngcloud.ru/api/v1/impersonation/history' },
|
name: 'auth-api /auth/user',
|
||||||
{ name: 'history/all', url: 'https://auth-api.ngcloud.ru/api/v1/impersonation/history/all' },
|
url: 'https://auth-api.ngcloud.ru/api/v1/auth/user',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'lk-api-gateway /iam/auth/user',
|
||||||
|
url: 'https://lk-api-gateway.ngcloud.ru/api/v1/iam/auth/user',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'auth-api /impersonation/status',
|
||||||
|
url: 'https://auth-api.ngcloud.ru/api/v1/impersonation/status',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const results = {};
|
const results = {};
|
||||||
for (const ep of endpoints) {
|
for (const t of tests) {
|
||||||
try {
|
try {
|
||||||
const data = await iamFetch(token, ep.url);
|
const data = await iamFetch(token, t.url);
|
||||||
results[ep.name] = { ok: true, data };
|
results[t.name] = { ok: true, data };
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
results[ep.name] = { ok: false, error: e.message };
|
results[t.name] = { ok: false, error: e.message };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res.set('Content-Type', 'text/html; charset=utf-8');
|
res.set('Content-Type', 'text/html; charset=utf-8');
|
||||||
res.send(iamStatPage(results));
|
res.send(iamComparePage(results));
|
||||||
});
|
});
|
||||||
|
|
||||||
// ── /v2/app — пользовательский CRUD (только с сессией) ──────────────
|
// ── /v2/app — пользовательский CRUD (только с сессией) ──────────────
|
||||||
@@ -187,7 +196,7 @@ function debugPage(u, version) {
|
|||||||
</body></html>`;
|
</body></html>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function iamStatPage(results) {
|
function iamComparePage(results) {
|
||||||
function fmt(data, depth) {
|
function fmt(data, depth) {
|
||||||
if (data === null || data === undefined) return '<span style="color:#888">null</span>';
|
if (data === null || data === undefined) return '<span style="color:#888">null</span>';
|
||||||
if (typeof data === 'string') return '<span style="color:#ce93d8">"' + data.replace(/</g, '<') + '"</span>';
|
if (typeof data === 'string') return '<span style="color:#ce93d8">"' + data.replace(/</g, '<') + '"</span>';
|
||||||
|
|||||||
Reference in New Issue
Block a user