From 929d2b529990de4e834b63be0e0dfc7ecd181b76 Mon Sep 17 00:00:00 2001 From: lohit Date: Fri, 21 Jun 2024 10:44:24 +0530 Subject: [PATCH] fix/generate code auth header validation (#2490) * geenrate code for request to include collection auth headers only if request auth is of type inherit * validations --- packages/bruno-app/src/utils/codegenerator/auth.js | 8 ++++---- .../bruno-electron/src/ipc/network/prepare-request.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/bruno-app/src/utils/codegenerator/auth.js b/packages/bruno-app/src/utils/codegenerator/auth.js index 4b3d23e64..981d6cec2 100644 --- a/packages/bruno-app/src/utils/codegenerator/auth.js +++ b/packages/bruno-app/src/utils/codegenerator/auth.js @@ -1,12 +1,12 @@ import get from 'lodash/get'; export const getAuthHeaders = (collectionRootAuth, requestAuth) => { - const auth = collectionRootAuth && ['inherit', 'none'].includes(requestAuth.mode) ? collectionRootAuth : requestAuth; + const auth = collectionRootAuth && ['inherit'].includes(requestAuth?.mode) ? collectionRootAuth : requestAuth; switch (auth.mode) { case 'basic': - const username = get(auth, 'basic.username'); - const password = get(auth, 'basic.password'); + const username = get(auth, 'basic.username', ''); + const password = get(auth, 'basic.password', ''); const basicToken = Buffer.from(`${username}:${password}`).toString('base64'); return [ @@ -21,7 +21,7 @@ export const getAuthHeaders = (collectionRootAuth, requestAuth) => { { enabled: true, name: 'Authorization', - value: `Bearer ${get(auth, 'bearer.token')}` + value: `Bearer ${get(auth, 'bearer.token', '')}` } ]; default: diff --git a/packages/bruno-electron/src/ipc/network/prepare-request.js b/packages/bruno-electron/src/ipc/network/prepare-request.js index eaa6c8de0..bd09619f4 100644 --- a/packages/bruno-electron/src/ipc/network/prepare-request.js +++ b/packages/bruno-electron/src/ipc/network/prepare-request.js @@ -162,7 +162,7 @@ const prepareRequest = (request, collectionRoot, collectionPath) => { method: request.method, url, headers, - pathParams: request.params.filter((param) => param.type === 'path'), + pathParams: request?.params?.filter((param) => param.type === 'path'), responseType: 'arraybuffer' };