usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
27.56k stars 1.27k forks source link

Bruno CLI: Auth doesn't work #3492

Open HaikoF opened 6 days ago

HaikoF commented 6 days ago

I have checked the following:

Describe the bug

I have an auth by apikey in the headers defined for my endpoint. Using the Client works absolutely fine, but calling the same using the CLI it fails. So, I tested to put the api-key directly into the header and the CLI execution was successful. Also using Auth as queryparams fails but works if i put it directly into the Params.

Infrastructure: I'm checking an API endpoint in an azure APIManagement Service. All requests to this API operation get a 200 in return if the auth is correct.

.bru file to reproduce the bug

meta { name: HealthCheck type: http seq: 1 }

head { url: {{ApimEndpoint}}/health body: none auth: apikey }

auth:apikey { key: Ocp-Apim-Subscription-Key value: {{ApimKey}} placement: header }

tests { test("Successful request", function () { expect(res.getStatus()).to.eql(200); }); }

Screenshots/Live demo link

Running Request

.\HealthCheck (401 Access Denied) - 98 ms [Function: AssertionError] AssertionError: expected 401 to deeply equal 200 at VM2 Wrapper.apply (C:\Users\client_se\AppData\Roaming\nvm\v20.18.0\node_modules\@usebruno\cli\node_modules\@usebruno\vm2\lib/bridge.js:485:11) at C:\Dev\Quorix\ApiTesting\vm.js:2:32 at VM2 Wrapper.apply (C:\Users\client_se\AppData\Roaming\nvm\v20.18.0\node_modules\@usebruno\cli\node_modules\@usebruno\vm2\lib\bridge.js:485:11) at C:\Users\client_se\AppData\Roaming\nvm\v20.18.0\node_modules\@usebruno\cli\node_modules\@usebruno\js\src\test.js:3:11 at VM2 Wrapper.apply (C:\Users\client_se\AppData\Roaming\nvm\v20.18.0\node_modules\@usebruno\cli\node_modules\@usebruno\vm2\lib/bridge.js:485:11) at module.exports (C:\Dev\Quorix\ApiTesting\vm.js:1:94) at VM2 Wrapper.apply (C:\Users\client_se\AppData\Roaming\nvm\v20.18.0\node_modules\@usebruno\cli\node_modules\@usebruno\vm2\lib\bridge.js:485:11) at TestRuntime.runTests (C:\Users\client_se\AppData\Roaming\nvm\v20.18.0\node_modules\@usebruno\cli\node_modules\@usebruno\js\src\runtime\test-runtime.js:161:13) at runSingleRequest (C:\Users\client_se\AppData\Roaming\nvm\v20.18.0\node_modules\@usebruno\cli\src\runner\run-single-request.js:341:40) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Object.handler (C:\Users\client_se\AppData\Roaming\nvm\v20.18.0\node_modules\@usebruno\cli\src\commands\run.js:609:24) { showDiff: true, actual: 401, expected: 200, operator: 'strictEqual' } ✕ Successful request

Requests: 1 passed, 1 total Tests: 0 passed, 1 failed, 1 total Assertions: 0 passed, 0 total Ran all requests - 98 ms

Requests: 1 passed, 1 total Tests: 0 passed, 1 failed, 1 total Assertions: 0 passed, 0 total

ganesh-bruno commented 1 day ago

Hey @HaikoF,

Thanks for reporting this issue. I've been able to reproduce it. There seems to be an incompatibility with the CLI, and we're working on it.