Bash script - challenge. Writing API tests using the curl program

20229352_122422448376375_8167359585774756489_n.jpg

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)
H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now