This repository is an example of trying to use Bruno instead of a Postman or Insomnia free account.
You can find complete Bruno documentation here.
Python local HTTP server can be used for tests. To start the server, run the following command:
cd ./Local\ HTTP\ server
python simple_http_server.py
The server will be started on port 3000. It contains the following endpoints:
- GET
/api/v1/hello - POST
/api/v1/greet - POST
/api/v1/register - GET
/api/v1/profile/{userId}
To start the local Hashicorp Vault, run the following command:
docker run --cap-add=IPC_LOCK -d --name=dev-vault -p 8200:8200 hashicorp/vault:latest
docker exec -it dev-vault vault operator init
You will get:
- Unseal Key
- Root Token
docker exec -it dev-vault vault operator unseal <unseal_key>
or
curl --request PUT \
--url http://localhost:8200/v1/sys/unseal \
--header 'content-type: application/json' \
--data '{"key":"<unseal_key>"}'
docker exec -it dev-vault vault ui
Open in web browser http://localhost:8200/ui
You can write a secret to the Vault using the following command:
docker exec -it dev-vault vault kv put secret/bruno vault_password=<any value>
or using the Web UI.
If you use Open Source or Pro licence, you won't be able to use Bruno's Integration with Secret Managers, as it is available only for Ultimate licence.
Anyway, you can get secrets from Secret Managers like Hashicorp Vault. To do that, you need to:
- Create a
.envas a copy of.env.samplefile and fill it with your Vault tokens. You can find more information about DotEnv File for Bruno here. - Investigate files in
./Bruno First Steps/Vault example/folder:folder.brufile and itsscript:pre-requestsection. It contains logic to import functions fromjsfiles.js/hashicorp-vault-secrets.jsfile. It contains functions to get secrets from Hashicorp Vault.js/time-for-secret.jsfile. It contains functions to reduce the number of Secret Manager calls.
- Update above files according to your needs.
Another way to get secrets from Secret Managers is utilizing external libraries like node-vault. Such an example you can find in Bruno First Steps/Vault via node-vault example/Get Request with Vault Secret via node-vault request. Check its Pre Request section. It is used to get secret/data/bruno secret and its value.
To make this example working do the follow:
- Enable Developer Mode.
- Set
truevalue foruseNodeVaultenvironment variable. - Open
Tools->Chrome Consoleto check console output.
You need to install the Bruno CLI:
npm install -g @usebruno/cli
After that, you will be able to run your collection in terminal using the following commands:
cd ./Bruno\ First\ Steps/
bru run --env Local --reporter-html results.html