You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2026/08/06 08:14:01 UTC
(skywalking-banyandb) branch main updated: Fix flaky Canopy auth session test by mocking version probe (#1254)
This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
The following commit(s) were added to refs/heads/main by this push:
new 1ebeee40e Fix flaky Canopy auth session test by mocking version probe (#1254)
1ebeee40e is described below
commit 1ebeee40ec413fbeb38f701c0dfb10392e382536
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Thu Aug 6 16:13:56 2026 +0800
Fix flaky Canopy auth session test by mocking version probe (#1254)
---
canopy/server/test/bff.test.ts | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/canopy/server/test/bff.test.ts b/canopy/server/test/bff.test.ts
index 54b54c20d..b447d99e7 100644
--- a/canopy/server/test/bff.test.ts
+++ b/canopy/server/test/bff.test.ts
@@ -25,7 +25,7 @@ import { registerProxy } from '../src/plugins/proxy.js';
import { registerStatic } from '../src/plugins/static.js';
import type { Config } from '../src/config.js';
import bcrypt from 'bcryptjs';
-import { MockAgent, setGlobalDispatcher } from 'undici';
+import { getGlobalDispatcher, MockAgent, setGlobalDispatcher } from 'undici';
// Mock DNS so SSRF check passes for test hostnames (no real DNS in unit tests)
vi.mock('node:dns/promises', () => ({
@@ -88,9 +88,25 @@ async function loginAs(app: FastifyInstance, username: string, password: string)
describe('Auth routes', () => {
let app: FastifyInstance;
+ let mockAgent: MockAgent;
+ let previousDispatcher: ReturnType<typeof getGlobalDispatcher>;
- beforeEach(async () => { app = await buildTestApp(); });
- afterEach(async () => { await app.close(); });
+ beforeEach(async () => {
+ previousDispatcher = getGlobalDispatcher();
+ mockAgent = new MockAgent();
+ mockAgent.disableNetConnect();
+ setGlobalDispatcher(mockAgent);
+ mockAgent.get('http://upstream-a.test:17913')
+ .intercept({ path: '/api/v1/common/api/version', method: 'GET' })
+ .reply(200, { version: { version: 'test-version' } });
+ app = await buildTestApp();
+ });
+
+ afterEach(async () => {
+ await app.close();
+ setGlobalDispatcher(previousDispatcher);
+ await mockAgent.close();
+ });
it('POST /auth/login with valid credentials sets session', async () => {
const res = await app.inject({