usebruno / bruno

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

Not possible to specify client certificate in BrunoCLI #2730

Open angelaatskandia opened 1 month ago

angelaatskandia commented 1 month ago

I have checked the following:

Describe the bug

In the Bruno application it is possible to configure a client certificate by defining paths to cert and key files on collection level. However, this option seems to be missing when running BrunoCLI - one can only configure path to cacert through command line, not paths to client certificates.

This hinders from running Bruno tests in continuous testing / continuous integration environments.

.bru file to reproduce the bug

No response

Screenshots/Live demo link

It is a bit tricky to take a screenshot of something that is missing :-)

pietrygamat commented 1 month ago

In current implementation, the CA file is an application level setting, so it makes sense to have a cli switch for that. The mTLS certificates however are configured at collection level, so they are read when executing cli already, as any other request configuration. Also, the fields storing paths and passwords support variables already, so the cli invocation can be customized easily.

Would you elaborate how you expect the additional cli switches to work and what --keywords you need?

angelaatskandia commented 1 month ago

Good to hear that it is easy to customize the cli :-)

One solution would be to read the paths, domain and phrases from the bruno.json when triggering tests from BrunoCLI. However, the drawback would be that the paths to the certificate files might differ between local machines (where tests are developed) and CI-servers. So when the tester commits the collection, the local settings will be the ones used when running the committed tests on the pipeline server.

So a solution where paths, domain and phrases can be injected using arguments/keywords over command line would be preferable from a CI/CT perspective. Regarding the switches, maybe reusing the ones from the application could be suitable? Keywords could then be something like: --domain --clientcertfile --clientcertkey

This would give a command like: bru run --env test --cacert D:/rootcert.cer --domain *.company.org --clientcertfile D:/clientcert.cer --clientcertkey D:/clientcert.pem --output results.xml --format junit