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

in #utopian-io5 years ago (edited)

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)
Sort:  

Thank you very much for the article. Is that a chance that you will continue publishing articles related to bash scripting? I am very interest in using curl to get some raw data from google sheets.

Congratulations @grzesiekb! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You published more than 20 posts. Your next target is to reach 30 posts.

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Congratulations @grzesiekb! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.033
BTC 64534.17
ETH 3150.15
USDT 1.00
SBD 4.01