From 6d261ecdeefbf0f3e0738ca58a89d592f1701fca Mon Sep 17 00:00:00 2001 From: Yichen Jiang Date: Wed, 2 Sep 2026 10:51:20 +0800 Subject: [PATCH] test(app-boot): assert the home .env proxy contract without pinning a casing Windows folds `https_proxy` and `HTTPS_PROXY` into one variable, so the exported spelling shadowed the file's lowercase one and the case failed there. Each spelling now gets its own name: the file supplies a name the shell did not export, and the shell outranks the file for the one it did. --- packages/boot/app-boot/tests/app-boot.spec.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/boot/app-boot/tests/app-boot.spec.ts b/packages/boot/app-boot/tests/app-boot.spec.ts index d39d38e82c..644acd4892 100644 --- a/packages/boot/app-boot/tests/app-boot.spec.ts +++ b/packages/boot/app-boot/tests/app-boot.spec.ts @@ -157,19 +157,22 @@ describe('loadLayeredEnv', () => { it('accepts the proxy names from the Harness-home .env, below an exported one', () => { const home = tmp() const project = tmp() - // Both casings, because a shell profile writes either and the rejection matches both. - writeFileSync(join(home, '.env'), 'HTTP_PROXY=http://from-home:8080\nhttps_proxy=http://from-home-lower:8080\nNO_PROXY=example.com\n') + // Both casings, because a shell profile writes either and the rejection matches both. Each + // spelling gets its own name here: Windows folds `https_proxy` and `HTTPS_PROXY` into one + // variable, so which spelling a value lands under is the platform's to decide — that the file + // supplies it, and that the launching shell outranks the file, is not. + writeFileSync(join(home, '.env'), 'HTTP_PROXY=http://from-home:8080\nno_proxy=example.com\nHTTPS_PROXY=http://from-home:8443\n') clear(); clearProxy() vi.stubEnv('DSH_HOME', home) vi.stubEnv('HTTPS_PROXY', 'http://exported:8080') try { const snapshot = loadLayeredEnv(NAME, project, vi.fn()) expect(snapshot.get('HTTP_PROXY')).toEqual({ value: 'http://from-home:8080', source: 'user-env', path: join(home, '.env') }) - expect(snapshot.get('https_proxy')).toEqual({ value: 'http://from-home-lower:8080', source: 'user-env', path: join(home, '.env') }) - expect(snapshot.get('NO_PROXY')?.value).toBe('example.com') - // The launching shell still outranks the file. + expect(snapshot.get('no_proxy')).toEqual({ value: 'example.com', source: 'user-env', path: join(home, '.env') }) + // The launching shell still outranks the file for the same variable. expect(snapshot.get('HTTPS_PROXY')).toEqual({ value: 'http://exported:8080', source: 'process' }) expect(process.env.HTTP_PROXY).toBe('http://from-home:8080') + expect(process.env.HTTPS_PROXY).toBe('http://exported:8080') } finally { clear(); clearProxy() vi.unstubAllEnvs()