3 # ============LICENSE_START===============================================
4 # Copyright (C) 2020 Nordix Foundation. All rights reserved.
5 # ========================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END=================================================
20 # Automated test script for callback receiver container
22 # callbackreciver port
25 echo "Usage: ./basic_test.sh nonsecure|secure"
28 if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then
29 echo "Usage: ./basic_test.sh nonsecure|secure"
33 if [ $1 == "nonsecure" ]; then
34 #Default http port for the simulator
39 #Default https port for the simulator
45 # source function to do curl and check result
46 . ../common/do_curl_function.sh
48 echo "=== CR hello world ==="
53 echo "=== Get counter - callbacks ==="
55 do_curl GET /counter/received_callbacks 200
57 echo "=== Get counter - fetched events ==="
59 do_curl GET /counter/fetched_callbacks 200
61 echo "=== Get counter - current events ==="
63 do_curl GET /counter/current_messages 200
66 echo "=== Send a request ==="
69 echo "\"DATA-MSG\"" > .tmp.json
70 do_curl POST '/callbacks/test' 200 .tmp.json
73 echo "=== Fetch an event, wrong id==="
75 do_curl GET '/get-event/wrongid' 204
78 echo "=== Get counter - callbacks ==="
80 do_curl GET /counter/received_callbacks 200
82 echo "=== Get counter - fetched events ==="
84 do_curl GET /counter/fetched_callbacks 200
86 echo "=== Get counter - current events ==="
88 do_curl GET /counter/current_messages 200
91 echo "=== Fetch an event ==="
93 do_curl GET '/get-event/test' 200
95 echo "=== Fetch an event again ==="
97 do_curl GET '/get-event/test' 204
99 echo "=== Get counter - callbacks ==="
101 do_curl GET /counter/received_callbacks 200
103 echo "=== Get counter - fetched events ==="
105 do_curl GET /counter/fetched_callbacks 200
107 echo "=== Get counter - current events ==="
109 do_curl GET /counter/current_messages 200
111 echo "=== CR reset ==="
113 do_curl GET /reset 200
115 echo "=== Get counter - callbacks ==="
117 do_curl GET /counter/received_callbacks 200
119 echo "=== Get counter - fetched events ==="
121 do_curl GET /counter/fetched_callbacks 200
123 echo "=== Get counter - current events ==="
125 do_curl GET /counter/current_messages 200
128 echo "********************"
129 echo "*** All tests ok ***"
130 echo "********************"