-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.sh
executable file
·53 lines (48 loc) · 961 Bytes
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
set -e
HOST="flask-api.testing.leiarenee.io"
PORT=80
URL="http://$HOST:$PORT/api/replace"
DATA="The analysts of ABN did a great job!"
# Authorization user:pwd -> "replace:replace"
function fetch(){
curl "$URL" \
-X POST -d "{\"text\" : \"$DATA\"}" \
-H "Content-Type: application/json" \
-H "Authorization: Basic cmVwbGFjZTpyZXBsYWNl" \
| jq .
}
echo
echo "Infrastructure test initialized."
echo
echo "TEST 1"
echo "Checking if the port is open by netcat"
test/health-check.sh 5 $HOST:$PORT
echo
echo "--------------------------------------"
echo
echo "TEST 2"
echo "Testing $URL by curl."
echo
echo "Sending "
echo "{"
echo " \"test\" : \"$DATA\""
echo "}"
echo
echo "Result:"
fetch
echo
echo "--------------------------------------"
echo
echo "TEST 3"
DATA=$(cat test/files/test_input.txt)
echo "Sending "
echo "{"
echo " \"test\" : \"$DATA\""
echo "}"
echo
echo "Result:"
fetch
echo
echo "Test Ended Succesfully."
echo