1 | #!/usr/bin/bash
|
2 |
|
3 | set -e
|
4 |
|
5 | NUMBER=$RANDOM
|
6 | curl -i -X GET -H 'Content-Type: application/json' localhost:3000/ > GET
|
7 | if [[ ! $(cat GET | head -1| cut -f2 -d" ") == "200" || ! $(cat GET | tail -1| cut -f4 -d"\"") == "home page" ]] ; then
|
8 | exit 1
|
9 | fi;
|
10 | curl -i -X POST -H 'Content-Type: application/json' localhost:3000/post/$NUMBER --data {} > POST
|
11 | if [[ ! $(cat POST | head -1| cut -f2 -d" ") == "201" || ! $(cat POST | tail -1| cut -f4 -d"\"") == $(echo $NUMBER) ]]; then
|
12 | exit 1
|
13 | fi;
|
14 | curl -i -X PUT -H 'Content-Type: application/json' localhost:3000/put/$NUMBER --data {} > PUT
|
15 | if [[ ! $(cat PUT | head -1| cut -f2 -d" ") == "200" || ! $(cat PUT | tail -1| cut -f4 -d"\"") == $(echo $NUMBER) ]]; then
|
16 | exit 1
|
17 | fi;
|
18 | curl -i -X DELETE -H 'Content-Type: application/json' localhost:3000/delete/$NUMBER --data {} > DELETE
|
19 | if [[ ! $(cat DELETE | head -1| cut -f2 -d" ") == "204" ]]; then
|
20 | exit 1
|
21 | fi;
|
22 |
|
23 | rm -f GET POST PUT DELETE
|