diff --git a/packages/core/src/middleware/koa-auth.ts b/packages/core/src/middleware/koa-auth.ts index 9d745adf0..51b7b2771 100644 --- a/packages/core/src/middleware/koa-auth.ts +++ b/packages/core/src/middleware/koa-auth.ts @@ -41,7 +41,7 @@ type UserInfo = { const getUserInfoFromRequest = async (request: Request): Promise => { const { isProduction, isIntegrationTest, developmentUserId, oidc } = envSet.values; - const userId = developmentUserId || request.headers['development-user-id']?.toString(); + const userId = request.headers['development-user-id']?.toString() ?? developmentUserId; if ((!isProduction || isIntegrationTest) && userId) { return { sub: userId, roleNames: [UserRole.Admin] }; diff --git a/packages/integration-tests/jest.setup.js b/packages/integration-tests/jest.setup.js index 3e107884d..1800b07d2 100644 --- a/packages/integration-tests/jest.setup.js +++ b/packages/integration-tests/jest.setup.js @@ -1,11 +1,14 @@ // Need to disable following rules to mock text-decode/text-encoder and crypto for jsdom // https://github.com/jsdom/jsdom/issues/1612 import { Crypto } from '@peculiar/webcrypto'; +import dotenv from 'dotenv'; import { TextDecoder, TextEncoder } from 'text-encoder'; // eslint-disable-next-line unicorn/prefer-module const fetch = require('node-fetch'); +dotenv.config(); + /* eslint-disable @silverhand/fp/no-mutation */ global.crypto = new Crypto(); global.fetch = fetch; diff --git a/packages/integration-tests/package.json b/packages/integration-tests/package.json index 2e01f3250..00de2e6f6 100644 --- a/packages/integration-tests/package.json +++ b/packages/integration-tests/package.json @@ -22,6 +22,7 @@ "@silverhand/ts-config": "^0.17.0", "@types/jest": "^27.4.1", "@types/node": "^16.0.0", + "dotenv": "^16.0.0", "eslint": "^8.19.0", "got": "^11.8.2", "jest": "^27.5.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cd2c8727d..9f6dae7fd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1142,6 +1142,7 @@ importers: '@silverhand/ts-config': ^0.17.0 '@types/jest': ^27.4.1 '@types/node': ^16.0.0 + dotenv: ^16.0.0 eslint: ^8.19.0 got: ^11.8.2 jest: ^27.5.1 @@ -1163,6 +1164,7 @@ importers: '@silverhand/ts-config': 0.17.0_typescript@4.6.4 '@types/jest': 27.4.1 '@types/node': 16.11.12 + dotenv: 16.0.0 eslint: 8.19.0 got: 11.8.3 jest: 27.5.1_ts-node@10.9.1 @@ -7594,7 +7596,6 @@ packages: /dotenv/16.0.0: resolution: {integrity: sha512-qD9WU0MPM4SWLPJy/r2Be+2WgQj8plChsyrCNQzW/0WjvcJQiKQJ9mH3ZgB3fxbUUxgc/11ZJ0Fi5KiimWGz2Q==} engines: {node: '>=12'} - dev: false /dotenv/7.0.0: resolution: {integrity: sha512-M3NhsLbV1i6HuGzBUH8vXrtxOk+tWmzWKDMbAVSUp3Zsjm7ywFeuwrUXhmhQyRK1q5B5GGy7hcXPbj3bnfZg2g==}