Published: 11 Sept 2019 › Updated: 11 Sept 2019
Bash script - challenge. Writing API tests using the curl program
Let’s start
First, Let’s check if we have curl package installed
curl -V
Preparation and start of the test
In the API for steem documentation, we can find examples of API calls using the curl program.
e.g.
curl -s --data '{"jsonrpc":"2.0", "method":"database_api.find_accounts", "params": {"accounts":["steemit", "grzesiekb"]}, "id":1}' https://api.steemit.com
I assume the API works properly if it returns a result containing 'about'
curl -s --data '{"jsonrpc":"2.0", "method":"database_api.find_accounts", "params": {"accounts":["steemit", "grzesiekb"]}, "id":1}' https://api.steemit.com | grep about -q && echo ‘find_accounts works’ || echo ‘find_accounts is not work’
I passed the result to the grep program, in which I check if it contains an 'about' string of characters. If the test is positive, grep returns 'find_accounts works'. If the test is negative, grep returns 'find_accounts is not work'.
In the near future, I'm going to present my idea for
- Authentication test (session) using the curl program.
- Authentication test (token) using the curl program.
- Reporting test results written using bash script.
- Keeping (supporting) the tests written with bash scripts.
- Summary (test in bash)
Leave Bash script - challenge. Writing API tests using the curl program to:
Read more #utopian-io posts
Best Posts From grzesiek
We have not curated any of grzesiekb's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From grzesiek
- Bash script - challenge [part 3]. Authentication test (token) using the curl program.
- Bash script challenge [part 2]. Authentication test (session) using the curl program.
- Bash script - challenge. Writing API tests using the curl program
- Adding description for datasource state [develop Scada-LTS]
- New option in HttpRetriver datasource [Scada-LTS]
- New Export/Import pointHierarchy. [ScadaLTS]
- [Scada-LTS] The possibility to add image sets without requiring a reboot
- [Scada-LTS] The possibility to add image sets without a restart
- New Project “shop-at-everything”.
- A successful attempt on adding switch language option in the angular app and integrating it with crowdin.com
- Add login component [EN/PL]
- Generating data (multistate) for simulations in Scada-LTS. [EN/PL]
- Correct the api rest authentication [EN/PL]
- How the data of virtual multisate points in the Scada-LTS program change
- We add a virtual point with the ** multistate ** type (increment) in Scada-LTS
- Generating data (binary) for simulations in Scada-LTS / Generowanie danych (binarnych) do symulacji w Scadzie-LTS [EN/PL]
- Preview how data from "virtual-data source" (type binary - Alternate, No Change, Random) changes every second
- Add "virtual point" in "virual data-source" - with Binary type in Scada-LTS
- Add a "virtual data-source" in Scada-LTS
- Add permission mask decoding